I am beginner in perl programming. Suppose, I have two strings i.e. $seq1="AAAGATCGTG";
and $seq2="AGTACTTTCC"; I am interested in counting the number of
substitutions of A in $seq1 by G in $seq2 i.e. $A2G and similarly, $G2A, $C2T, $T2C,
$A2T, $A2C, $G2T and $G2C. Some sites like 0 and 5 are same in $seq1 and $seq2. Which
perl code should I use to find out the number of such substitutions? I don't know the code
that I should write in the places marked ?????? in the following program to find the correct
results. Can any perlmonk help me to count the substitutions?
#!usr/bin/perl-w
use strict;
my $seq1="AAAGATCGTG";
my $seq2="AGTACTTTCC";
my ($A2G,$G2A,$C2T,$T2C,$A2T,$A2C,$G2T,$G2C)
for (0..length($seq1)-1){
if (substr($seq1, ???) eq substr($seq2, ??))
{$A2G++;$G2A++;$C2T++;$T2C++;$A2T++;$A2C++;$G2T++;$G2C++;}
else { ?????}
}
print"\n No. of Substitutions:\n
A2G=$A2G; G2A=$G2A; C2T=$C2T; T2C=$T2C; A2T=$A2T; A2C=$A2C; G2T=$G2T
+; G2C=$G2C.\n";
exit;
The results should look like:
A2G=1; G2A=1; C2T=1; T2C=1; A2T=1; A2C=1; G2T=1; G2C=1.