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, }

In reply to 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.