The first thing I would suggest is running 'monitor' while the program is running. This should give you an idea is the time is being spent in your Perl script or in the database. This would help you focus your optimization effort. I worked with bioinformatic data professionally myself, and the way I would typically do these type of problems is to pull in all the data I could into memory first (hashes work wonders), process your results in memory, and then do your table inserts and updates (updates first). You want to do multiple updates and inserts in a single transaction block, but be sure to commit every so often so your backtrack space doesn't fill up.
Here are a few coding comments I have:
- Use $INPUT_RECORD_SEPARATOR instead of $/
- We can eliminate a lot of lexical scoping on the parse routines since the m// function returns as a list the substring matched by the capturing parentheses. If there is no match, the list item will be undef.
# Get type. Right now, all are BAC's.
if ($line =~ m/\b((B|Y)AC)\b/)
{
$type = $1;
}
# Get reference number.
if ($line =~ m/BAC:\s*(.*)\s*$/)
{
$ac_id = $1;
}
# Get whether forward or reverse
if ($line =~ m/ORIENTATION:\s*(\w)_(\d)\s*$/)
{
$orient = $1;
$read_frame = $2;
}
becomes
# Get type. Right now, all are BAC's.
($type) = $line =~ m/\b([BY]AC)\b/; # regex change
# Get reference number.
($ac_id) = $line =~ m/BAC:\s*(.*)\s*$/;
# Get whether forward or reverse
($orient, $read_frame) =
$line =~ m/ORIENTATION:\s*(\w)_(\d)/; # regex change
- Watch all the *'s (especially .*'s) in regex's, they may not all be necessary.
I think everything else has been said already. I'd like to reiterate the utter stupidity of the CS department not allowing you to take their classes.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|