Hey everyone. So I have a nucleotide sequence to parse through in order to find all the matching pairs of dinucleotides (ex. AA, AT, CG, etc.). I'm having problems with the code for matching - I cannot figure out how to get matches for nucleotide pairs that overlap.
For example, here's a section from my nucleotide sequence and the code I utilize for matching 'AA':
$seq = AAGAATGCCAGTTTGTAAGTACTGACTTTGGAAAA
sub dtNTfreq {
my ($seq = '';
my $AA = 0;
while ($myseq =~ /(AA)/gi ){
$AA =$AA+1;
}
Using that perl code for matching, I find 5 possible matches for 'AA'.
However, the actual number of matches is 6, since the last section of $seq has 'AAAA' which match as follows:
[AA] [AA]
or
A [AA] A
I'm guessing I need to move through the sequence two nucleotides at a time to see if the match is true, but I'm unsure how to do so. Possibly by putting the while loop inside of a for loop that increments through the $seq string?
Any help is greatly appreciated.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.