Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Identifying Overlapping Matches in Nucleotide Sequence

by thanos1983 (Parson)
on Oct 27, 2017 at 08:11 UTC ( [id://1202127]=note: print w/replies, xml ) Need Help??


in reply to Identifying Overlapping Matches in Nucleotide Sequence

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!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1202127]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found