UPDATE: I tried InjunJoel's approach, and it blazed through all 6.5 million bases very quickly. I now see that using regexps for this type of problem is not the way to go... could someone perhaps explain to me precisely why the regexp approach that I initially tried brought my machine to a screeching halt? I presume it is has something to do with the way it stores the string in memory while traversing it with the regexp....
******************************************************
Hello,
I have a massive DNA sequence ( a string of ~600,000 (CORRECTION: 6.5million) "A"s "G"s "C"s and "T"s ) and I need to count the number of occurences of every possible 1, 2, and 3 letter combination in this sequence. I'm trying to use the following approach:
while ( $seq =~ /$term/g ) { $count++; }
Unfortunately, this is proving prohibitively slow. I would greatly appreciate any advice on how to speed this up (I tried adding /o, but it made little to no difference).
Also, while I have your ear, I was wondering if anyone could tell me how I can use a variable in a tr// regexp?
Thanks!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.