I am having problems sorting a fairly simple list. Here is the list:
It needs to be sorted by the fourth and fifth columns and will only print an entry to a file if column 5 is greater than or equal to 25 and column 4 is greater than or equal to 95. here is what i have so far.
i have no idea why it is not working. Any help would be great.
Code:
>NM_001100917.1 >NM_001100917.1 1019 100 1019 1 1
>NM_020388.3 >NM_001100917.1 0 0 0 . .
>NM_001001395.1 >NM_001100917.1 18 95 20 647 2404
>NM_001048210.1 >NM_001100917.1 0 0 0 . .
>NM_033157.2 >NM_001100917.1 18 95 20 889 2961
>NM_199229.1 >NM_001100917.1 18 100 18 903 1938
>NM_001077637.1 >NM_001100917.1 0 0 0 . .
>NM_152449.2 >NM_001100917.1 0 0 0 . .
>NM_006916.1 >NM_001100917.1 18 100 18 903 1941
>NM_033481.3 >NM_001100917.1 0 0 0 . .
>NM_033140.2 >NM_001100917.1 18 95 20 889 2619
>NM_033138.2 >NM_001100917.1 18 95 20 889 3648
>NM_007039.3 >NM_001100917.1 0 0 0 . .
>NM_033480.2 >NM_001100917.1 0 0 0 . .
>NM_004342.5 >NM_001100917.1 18 95 20 889 2883
>NM_033139.2 >NM_001100917.1 18 95 20 889 2697
>NM_013296.4 >NM_001100917.1 18 95 20 217 2875
Code:
use warnings;
$infile = <STDIN>;
$outfile = <STDIN>;
open (IN, $infile);
open (OUT, ">>$outfile");
while(<IN>) {
@comp = split (/\t/, $_);
if ($comp[4] >= 25 && $comp[3] >= 95) {
print OUT "@comp\n";
}
}