Hi! i have a program that is working fine except that i have huge data sets to work with and the script that i wrote is slow. is there are way to make it work faster.
thanks
while (<FILE1>) {
my ($a,$s,$p,$c) = $_ =~ /^(.+)\t(\d+)\t(\d+)\t(.+)/;
$n=$a."\t".$s."\t".$c;
$hash1{$n} = $p;
}
close(FILE1);
while (<FILE2>) {
@raw_data=<FILE2>;
}
close(FILE2);
foreach $n (keys %hash1){
foreach $raw (@raw_data){
my ($a, $s, $c) = split(/\t/, $n);
my @parts = split(/\t/,$raw);
if ($a eq $parts[0] && $parts[2] >= $s){
if ($parts[3] <=$hash1{$n}){
open(FILE4, ">>sorted33_mRNA/$c.txt") or die "$!";
$string = join("\t",@parts);
$string =~ s/\n//;
print FILE3 "$c\t$s\t$hash1{$n}\t$string\n";
print FILE4 "$c\t$s\t$hash1{$n}\t$string\n";
}
}
}
}
Is there a way to use 'if exists', when we are comparing values in the first file that are greater than and less than the values in the second file.
thanks
while (<FILE1>) {
my ($a,$s,$p,$c) = $_ =~ /^(.+)\t(\d+)\t(\d+)\t(.+)/;
$n=$a."\t".$s."\t".$c;
$hash1{$n} = $p;
}
close(FILE1);
while (<FILE2>) {
@raw_data=<FILE2>;
}
close(FILE2);
foreach $n (keys %hash1){
foreach $raw (@raw_data){
my ($a, $s, $c) = split(/\t/, $n);
my @parts = split(/\t/,$raw);
if ($a eq $parts[0] && $parts[2] >= $s){
if ($parts[3] <=$hash1{$n}){
open(FILE4, ">>sorted33_mRNA/$c.txt") or die "$!";
$string = join("\t",@parts);
$string =~ s/\n//;
print FILE3 "$c\t$s\t$hash1{$n}\t$string\n";
print FILE4 "$c\t$s\t$hash1{$n}\t$string\n";
}
}
}
}
Is there a way to use 'if exists', when we are comparing values in the first file that are greater than and less than the values in the second file.