I can't help but thinking your inner loop is unnecessary. You're scanning through your list of mappings until you find the one for the current line. But you're missing the beauty of hashes - direct access to the value you want..
Consider this: while (<INPUT2>) {
$_ =~ s/[\r\n]+\z//s; # I don't use chomp, sorry
my ( $bioC, $contig_id, $pip ) = split( "\t", $_ );
my $origin = $origins{$contig_id};
print RESULTS "$bioC\t$origin\t$pip\n";
}
Update: you could also DIE with an error message in the event that the file contained a code that wasn't in your mapping table: my $origin = $origins{$contig_id};
if ( ! defined( $origin ) ) {
die( "No mapping for \"$contig_id\" found in origins table" );
}
-
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.
|