Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Pattern Searching

by CountZero (Bishop)
on Nov 10, 2012 at 21:19 UTC ( #1003279=note: print w/ replies, xml ) Need Help??


in reply to Pattern Searching

I must be missing something obvious, but I can reproduce the basics of your output by a few nested loops and a regex.

use Modern::Perl; my @patterns = qw/GAATTC CCWGG/; while ( my $sequence = <DATA> ) { my @matches; while ( $sequence =~ m/($patterns[0]|$patterns[1])/g ) { for my $expr ( 1 .. $#- ) { push @matches, $-[$expr] .. $+[$expr] - 1; } } say "@matches"; } __DATA__ GAATTCACGGATAGCCWGGTACGATGATAGATGAATTCGACTAGAATGCCWGGAAGAATgGAATTC GAATTCACGGATAGCCWGGTACGATGATAGATGAATTCGACTAGAATGCCWGGAAGAATgGAATTC GAATTCACGGATAGCCWGGTACGATGATAGATGAATTCGACTAGAATGCCWGGAAGAATgGAATTC
Output:
0 1 2 3 4 5 14 15 16 17 18 32 33 34 35 36 37 48 49 50 51 52 60 61 62 6 +3 64 65 0 1 2 3 4 5 14 15 16 17 18 32 33 34 35 36 37 48 49 50 51 52 60 61 62 6 +3 64 65 0 1 2 3 4 5 14 15 16 17 18 32 33 34 35 36 37 48 49 50 51 52 60 61 62 6 +3 64 65

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics


Comment on Re: Pattern Searching
Select or Download Code
Re^2: Pattern Searching
by Anonymous Monk on Nov 12, 2012 at 15:34 UTC
    Thanks to all of you. I have solved my problem.I learn many things from you people. Now I have to call java code by using the Perl. Can you provide me some example or a link which thoroughly cover this.
      Your question is not related to the previous one. Please, start a new thread.
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2014-08-20 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (108 votes), past polls