Hello! I am trying to write a script that detects SNPs and their position in DNA sequences. Simply put, A SNP is when there is a change in A, T, C, or G between sequences, therefore...

A could change to T, C, to G

T could change to C, G, or A

G could change to C, T or A

C could change to G, T or A

For Example:

Sequence 1: ATGGAT

Sequence 2: ACGGAG

There are 2 SNPs here.

SNP 1 is the T --> C is position 2 of the sequence. SNP 2 is the T -->G in position 6 of the sequence.

Criteria for the script:

Only 2 sequences can be entered on the command line The 2 sequences must be equal length Find the SNP and the position of the SNP (starting from position 1 not 0) Print out data- for example using the sample above

Pos 2: T => C

Pos 6: T =>G

Found 2 SNPs.

This is what I have so far, but I am not sure how to proceed...

#!/usr/bin/env perl # file: 08-snps.pl use strict; use warnings; use autodie; my $number_seqs = scalar @ARGV; if($number_seqs != 2){ print "Please provide two sequences \n"; } for (my $i=0; $i<$number_seqs; $i++){ if(length($ARGV[$i]) != length($ARGV[0])){ print "Please ensure the sequences are the same length \n"; } } my $var = $ARGV[0]; print $var,"\n"; my $var2 = my $var[0]; print $var2,"\n";

In reply to Help tracking changes in array by reebee3

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.