Hello Perl Monks, The same question was asked here:Well thanks for providing that link :). What do you mean by "seems like it wasn't answered correctly" though? You're not sure about whether the answer is there or not?
http://stackoverflow.com/questions/40414018/perl-program-to-look-for-k-mer-with-specific-sequence
but seems like it wasn't answered correctly or wasn't finished.
It would be helpful if you actually provided the real expected output from the input you give, not "a hint", so that you could tell us exactly how the output you do obtain differs.
If I understand you correctly, you have two issues: only display unique sequences, and limit to the first 1000. There is more than one way to do it, because this is perl, but one way you could do that is store both the number of occurences and the position for each sequence:
You can then filter the sequences that have a Count equal to 1 using grep: my @uniq = grep { $sequences{$_}{Count} == 1 } keys %sequences;if ($windowSeq =~ /GG$/) { $sequences{$windowSeq}{Count}++; $sequences{$windowSeq}{Position} = $windowStart; }
Taking the first 1000 sequences from that array is left as an exercise to the reader ;-).
Edit: I don't know if you want to find overlapping sequences (like in AAAGGG, you either have AAAGG or AAGGG as 5 letter sequences ending in GG), but if not, the logic should be :
if ($windowSeq =~ /GG$/) { $windowStart += $windowSize; } else { $windowStart += $stepSize; }
In reply to Re: program to look for specific K-mer sequence
by Eily
in thread program to look for specific K-mer sequence
by pearllearner315
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |