Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: unique sequences

by AnomalousMonk (Archbishop)
on Dec 11, 2017 at 21:25 UTC ( [id://1205305]=note: print w/replies, xml ) Need Help??


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:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (None)
    As of 2024-04-25 04:02 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found