Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: how can I speed up this perl??

by Abigail-II (Bishop)
on Nov 24, 2003 at 11:00 UTC ( [id://309489]=note: print w/replies, xml ) Need Help??


in reply to how can I speed up this perl??

Use a hash.
$counts {$genome [$i] . $genome [$i + 1]} ++;
Note: the line above assumes that you are using separate counters for "aa" and "tt", unlike your own code.

Abigail

Replies are listed 'Best First'.
Re: Re: how can I speed up this perl??
by moxliukas (Curate) on Nov 24, 2003 at 11:16 UTC

    According to the original code there are six diferent instances which go to the same counters. Of course this is no problem, as you can combine the counters after the solution provided by Abigail-II like this:

    $counts{tt} += $counts{aa}; $counts{ag} += $counts{ct}; $counts{ac} += $counts{gt}; $counts{tg} += $counts{ca}; $counts{ga} += $counts{tc}; $counts{cc} += $counts{gg};
Re: Re: how can I speed up this perl??
by Anonymous Monk on Nov 24, 2003 at 11:09 UTC
    Thanks Abigail-II, but i'm new and dont get how this.. where do I define each pair e.g. $counts == aa. ? how does this counter know what to look for?
      It's a hash. If you encounter "aa", it'll add 1 to its "aa" entry. If you encounter "cg", it'll add 1 to its "cg" entry, etc.

      Abigail

        so how do I access the frequency of each pair using your code?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (7)
As of 2024-03-28 20:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found