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?