Ok, so if i understood you correctly you have two problems here:
1. You need to know which codons are homologous and which are not. Is that correct ??
2. After you figure out the first you wish to know where are the changes within the proper reading frame ???

Are my assumptions correct ?? Or the sequences are already aligned and you just wish to count the differences ?

In both cases, when alignment is done to count the diff you just iterate through both arrays count triplets, hash them and the for every triplet make a subhash that will record the type and the count of a specific change.

Example:

use strict; use Data::Dumper; my $r = 'AAATGTGATGTGAACGT'; my $t = 'AATGTGTCGT-TG-ATG'; my @a = split('',$r); my @v = split('',$t); my %hash =(); my $tt = @a>@v ? @a : @v; for(my $i = 0 ; $i<$tt;$i++){ my $z = 1+$i %3; # Update - suggested by Perlbotics, better ! unless ($a[$i] eq $v[$i]){ $hash{$z}->{"$a[$i]2$v[$i]"}++; } } print Dumper(\%hash);
Result:
$VAR1 = { '1' => { 'G2T' => 3, 'T2G' => 1, 'A2G' => 1 }, '3' => { 'G2T' => 1, 'C2A' => 1, 'T2G' => 2, 'A2T' => 1 }, '2' => { 'G2T' => 1, 'T2G' => 1, 'A2-' => 1, 'A2C' => 1, 'T2-' => 1 } };

In reply to Re: How can I count the types of changes in 1st, 2nd and 3rd positions of all 3-letter words in comparing two separate strings of unequal length? by baxy77bax
in thread How can I count the types of changes in 1st, 2nd and 3rd positions of all 3-letter words in comparing two separate strings of unequal length? by supriyoch_2008

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.