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.
|
|---|