Hello,

I'm just writing a script that will perform a number of different, very simple regular expressions on a large (up to 300 million characters) string. The searches are really simple, things like:

while ( $sequence =~ /CACGTG/g ) { print join("\t", $chr, '+', pos($sequence)-6), "\n"; } while ( $sequence =~ /GTGCAC/g ) { print join("\t", $chr, '-', pos($sequence)-6), "\n"; }

I have two questions about this. First, am I right to be doing these searches sequentially? Or ought I be trying to combine them all into one single regular expression? I chose the sequential approach because it seemed far more readable and easily scalable, but I didn't know if there was any reason to believe it was horribly inefficient or silly.

Second, is my use of pos($sequence) - match_length to find the starting point of the match appropriate, or is there a simpler way of getting the match start?

Many thanks in advance for any thoughts/advice/comments.


In reply to Multiple Regex's on a Big Sequence by bernanke01

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.