Hello FIJI42,

I am not a biologist or bioinformatics engineer but I will try to tackle your question based on simple logic. I am a bit confused as why the nucleoside sequence should be 6? If you want to count the number of occurrences of a string as 'AA' then the correct answer is 5. For example AAGAATGCCAGTTTGTAAGTACTGACTTTGGAAAA is equal to 5.

In case you want to count the number of occurrences of sets of characters (which means individual sets even apart from each other not in a sequence) then yes the number of occurrences is 6.

If this is the case you are trying to resolve then you can simply count the number of occurrences and divide by 2 (which is the number of sets/pairs) that you are interested. But because when you divide by odd number then you will have a remainder. In this case you can use modulo e.g. Modulo operation to return quotient and remainder.

Sample of code:

#!/usr/bin/perl use strict; use warnings; use feature 'say'; my $seq = 'AAGAATGCCAGTTTGTAAGTACTGACTTTGGAAAA'; my $x = 'A'; my $c = () = $seq =~ /$x/g; # $c is now 13 my $mod = 2; my ($quot, $rem) = (int $c / $mod, $c % $mod); say "Number of occurences: " . $c; say "Number of pairs: " . $quot; say "Remainder: " . $rem; __END__ $ perl test.pl Number of occurences: 13 Number of pairs: 6 Remainder: 1

Hope this helps, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re: Identifying Overlapping Matches in Nucleotide Sequence by thanos1983
in thread Identifying Overlapping Matches in Nucleotide Sequence by FIJI42

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.