Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Perl regular expression for amino acid sequence

by ikegami (Patriarch)
on Dec 01, 2004 at 21:21 UTC ( [id://411577]=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

>perl script.pl Match: GNN at 7 Match: GNN at 7 Match: GNN at 7 Match: GNN at 7 Match: GNN at 7 Match: GNN at 7 Match: GNN at 7 Match: GNN at 7 ...

It seems my Perl's tr/// clears pos for all strings. Workaround:

use strict; use warnings; my %seq; my $k = 0; $seq{$k} = 'xxxxxxxGNNNxxxxxxxNNNGYGYxxxxxxxGYGYNNNxxxxxxxNNNGNNNxxxxx +xx'; # break up three character repeats, inserting spaces while ($seq{$k} =~ s/([QGYN])\1\1/$1$1 $1$1/g) { } while ($seq{$k} =~ m/([QGYN]{3,5})/g) { my $saved_pos = pos($seq{$k}); printf("Match: %s at %d\n", $1, pos($seq{$k}) - length($1)-2*(substr($seq{$k}, 0, pos($seq{$k})) + =~ tr/ / /), ); pos($seq{$k}) = $saved_pos; }

Finally, a solution that works!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2024-04-19 14:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found