Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

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


in reply to Re^4: 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

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.


Comment on Re^5: counting the number of 16384 pattern matches in a large DNA sequence
Select or Download Code
Re^6: counting the number of 16384 pattern matches in a large DNA sequence
by anonym (Acolyte) on Jun 14, 2012 at 20:20 UTC

    Thanks.I tried this line

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

    but it is nt printing anything.

      As described in I know what I mean. Why don't you?, come up with a simple, replicatable piece of code that displays the bug. For example,
      use strict; use warnings; my %result; my %seq = (key => 'asdfasdfasdf'); my @string = 'asdf'; foreach my $string (@string) { chomp $string; foreach my $key (keys %seq) { $result{$string} =()= ($seq{$key} =~ /$string/ig); } foreach my $s (keys %result) { print "$s => $result{$s}\n"; } }
      outputs asdf => 3 as expected.

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2014-11-24 08:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (137 votes), past polls