Hi Perlmonks,
I am a beginner in perl programming. I have two strings of unequal sizes (15 & 12 letters)
i.e. $a="AGAGATATTCAAATT"; and $b="TCGAACGTCGAG"; In comparing the two given strings $a and $b,
I am interested to count the types of changes (A to T i.e. A2T, G2A, A2G etc.) for 1st, 2nd and 3rd positions
of all 3-letter words between two strings. Use of hash and dumper together appears very complicated to me.
I donot know which perl code I should use
in such counting. Since the two strings are small, one can do it manually. I wish if perl code could
do the same task then it can be used in comparing two strings as long as 100 letters (which is difficult
to do manually). May I expect to get help from Perlmonks in counting the types of changes between two
strings?
#!/usr/bin/perl-w
use strict;
use Data::Dump qw[ pp ];
my $a="AGAGATATTCAAATT";
my $b="TCGAACGTCGAG";
my (%first,%second,%third);
my @trilet1 = $a =~ /.../g;
my @trilet2 = $b =~ /.../g;
use Data::Dump qw[ pp ];
Code?????
for my $p ( 0 .. length( $seq1 ) - 1 ) {
my $c1 = substr $seq1, $p, 1;
my $c2 = substr $seq2, $p, 1;
next if $c1 eq $c2;
++$subs{ $c1 . '2' . $c2 };
}
pp \%first,%second, %third;
exit;
<p>The result should look like:</p>
<code>Counting Results:
{ For 1st position of all 3-letter words:
A2T=> 1,
G2A=> 1,
A2G=> 1,
C2G=> 1,
For 2nd position of all 3-letter words:
G2C=> 1,
For 3rd position of all 3-letter words:
A2G=> 2,
T2C=> 2,
}