N
Nina
My file looks like this,
4 350 -140.8445
What I want is pick the third column's biggest score, then get output
like this,
I made the script as,
#!/usr/bin/perl -w
my $file=$ARGV[0];
open (FILE, "$file") or die "Cannot open file.\n";
open (OUT, "> $file.position_bigscore") or die "Cannot open file.\n";
while ($line=<FILE>)
{
if ($line=~/>.+/)
{
$current_seq=$line;
print OUT $current_seq, "\n";
}
else
{
my @columns=split(/\t/,$line);
$current_score=$columns[2];
if ($max_score>$current_score)
{
$max_score=$current_score;
$max_line=$line;
}
print OUT $max_line, "\n";
}
}
close OUT;
close FILE;
I CANNOT get the expected result, because the loop has problems.
if ($max_score>$current_score)
{
$max_score=$current_score;
$max_line=$line;
}
Is there anybody very kind can help me out?
Thanks.
4 250 -170.9308A1 0 550 -235.6974
0 650 -185.2378
0 750 -193.6359
1 250 -137.9132
1 350 -182.881
1 450 -139.7555
1 550 -170.2239
A3 2 250 6.5954
A4 3 250 -162.1777
3 350 -129.308
3 450 -105.5604
A5
4 350 -140.8445
What I want is pick the third column's biggest score, then get output
like this,
4 350 -140.84A1 0 650 -185.24
3 450 -105.56
A5
I made the script as,
#!/usr/bin/perl -w
my $file=$ARGV[0];
open (FILE, "$file") or die "Cannot open file.\n";
open (OUT, "> $file.position_bigscore") or die "Cannot open file.\n";
while ($line=<FILE>)
{
if ($line=~/>.+/)
{
$current_seq=$line;
print OUT $current_seq, "\n";
}
else
{
my @columns=split(/\t/,$line);
$current_score=$columns[2];
if ($max_score>$current_score)
{
$max_score=$current_score;
$max_line=$line;
}
print OUT $max_line, "\n";
}
}
close OUT;
close FILE;
I CANNOT get the expected result, because the loop has problems.
if ($max_score>$current_score)
{
$max_score=$current_score;
$max_line=$line;
}
Is there anybody very kind can help me out?
Thanks.