Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: counting the number of 16384 pattern matches in a large DNA sequence

by kennethk (Monsignor)
on Jun 14, 2012 at 16:47 UTC ( #976254=note: print w/ replies, xml ) Need Help??


in reply to Re^2: counting the number of 16384 pattern matches in a large DNA sequence
in thread counting the number of 16384 pattern matches in a large DNA sequence

Please see How do I post a question effectively? Once you have a discrete test case that you have run through Devel::NYTProf, and as well run test cases with Benchmark for versions both including and excluding study, we can help you understand your results.

You may also want to check out index, since you the regex engine is more power than you really need.


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


Comment on Re^3: counting the number of 16384 pattern matches in a large DNA sequence
Re^4: counting the number of 16384 pattern matches in a large DNA sequence
by anonym (Acolyte) on Jun 14, 2012 at 17:30 UTC

    Is there any other way instead of storing the matches in an array @matches to make the code faster? Thanks

      I would expect swapping
      my @matches = ($seq{$key} =~ /$string/ig); #print "@matches\n"; $result{$string} = scalar(@matches);
      to

              $result{$string} =()= ($seq{$key} =~ /$string/ig);

      would hit the spec of this request, but I would also expect the speed-up achieved would be negligible. The compound of two = operators with an empty list (()) puts the regex in list context, thus obtaining a count of all matches.


      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

        Thanks.I tried this line

        $result{$string} =()= ($seq{$key} =~ /$string/ig);

        but it is nt printing anything.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2014-07-22 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (109 votes), past polls