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

Re^2: Perl regular expression for amino acid sequence

by Roy Johnson (Monsignor)
on Dec 01, 2004 at 21:45 UTC ( #411588=note: print w/replies, xml ) Need Help??


in reply to Re: Perl regular expression for amino acid sequence
in thread Perl regular expression for amino acid sequence

Here's a pure regex solution that works:
use strict; use warnings; while(<DATA>) { print "$_---\n"; my $m; while (/([QGYN]{2} # First two characters of the desired class (?: # Followed by the complex expression... # Lookback at the previous two chars (?<=(.)(.)) # Check that the next char differs from at least one of th +em (?:(?!\2)|(?!\3)) [QGYN] # Then take another of the desired class ){1,4} # ...1 to 4 times )/gx) { $m = $1; printf "---> $m starting at %d\n", pos($_)-length($m); } print "=====\n"; } __DATA__ QYGNGNG GGGGGNYGNQYNNNQGYQ QGYNNN xxxxxxxGNNNxxxxxxxNNNGYGYxxxxxxxGYGYNNNxxxxxxxNNNGNNNxxxxxxx

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^3: Perl regular expression for amino acid sequence
by hv (Parson) on Dec 02, 2004 at 13:34 UTC

    This is a very nice solution, I haven't seen that trick before.

    Hugo

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (1)
As of 2021-12-02 04:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (17 votes). Check out past polls.

    Notices?