in reply to help speeding up my perl code
You've completely missed the point of using a hash. You do not need to iterate every key to see if it contains the value you want, you just use the value as the key.
Try this. It should (untested) produce the same output and run much, much (much:), faster:
#!/usr/bin/perl -w # perl.ID.match.pl use strict; use warnings; open(KEY, "<chr1.coverage.txt") or die "error reading file"; my %Chr; my (@Key,@line); while (my $key = <KEY>) { chomp $key; @Key=split("\t",$key); $Chr{$Key[0]} = undef; } open(FULL, "<chr1.txt") or die "error reading file"; open(OUT, ">chr1.match.txt") or die "error reading file"; while (my $line=<FULL>) { chomp $line; @line=split("\t",$line); if( exists $Chr{ $line[0] } ) { print OUT "$line\n"; } } close KEY; close FULL; close OUT; exit;
|
|---|