Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-19 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found