Try it this way. Provided I haven't made any elementary mistakes, it shoudl produce the same result and run in a fraction of the time:
#!/usr/bin/perl -w use strict; use warnings; if( @ARGV < 3){ print "usage: A message here\n"; exit 0; } open(INPUT1,$ARGV[0]) || die "Cannot open file \"$ARGV[0]\""; #Orginal + IDs and four letter codes open(INPUT2,$ARGV[1]) || die "Cannot open file \"$ARGV[1]\""; #Orginal + IDs in the second column open(RESULTS,">$ARGV[2]")|| die "Cannot open the Results file \"$ARGV[ +2]\""; # Origanl IDs will change to four letter code my %origins; while (<INPUT1>) { chomp; my @columns = split '\t'; $origins{ $columns[0] } = $columns[1]; } close(INPUT1); while( <INPUT2> ) { chomp; my( $bioC, $contig_id, $pip ) = split("\t", $_); print RESULTS "$bioC\t$origins{ $contig_id }\t$pip\n"; } } close(INPUT2); close(RESULTS);
How small a fraction? If input file 1 contains 1000 lines, then < 1/1000th of the time
In reply to Re: Make my script faster and more efficient
by BrowserUk
in thread Make my script faster and more efficient
by sesemin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |