in reply to Re^3: unique sequences
in thread unique sequences

I thought the capturing parenthesis would capture the look-behind pattern as well.

It does — except I wouldn't think of what was captured as "the look-behind pattern", but simply as "the pattern" or maybe "the match." Look-around doesn't really enter in to it, and I don't see any need to bring in substr either; you already seem to have everything you need in $1, e.g. (with one repeated sequence):

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $line = 'AAAATTTTCCCCGGGGAAAGGxAAAACCCCTTTTGGGGAAAGGxAAAATTTTCCCCGGGGAAAGG' ; ;; my (%unique_data, $count); while ($line =~ m{ (.{9} [ATCG]{10} GG) }xmsg) { print qq{>crispr_@{[ ++$count ]} '$1'} unless $unique_data{$1}++; } ;; dd \%unique_data; " >crispr_1 'AAAATTTTCCCCGGGGAAAGG' >crispr_2 'AAAACCCCTTTTGGGGAAAGG' { "AAAACCCCTTTTGGGGAAAGG" => 1, "AAAATTTTCCCCGGGGAAAGG" => 2 }

However, I think the line-by-line processing of your code here is problematic. In the OPed code, the function  loadSequence() (supposedly) concatenates all lines of  ATCG bases in a file together before trying to extract sub-sequences of interest. In line-by-line processing, a sub-sequence may be interrupted by a newline and thus be missed.

(OTOH, the whole 21-base-versus-12-base aspect of the OPed code leaves me puzzled; I can't quite figure out what the OPer was going for there.)


Give a man a fish:  <%-{-{-{-<