从以下文件中,我需要打印由最低Dope score
组成的行。我正面临着如何解析列并找到最低Dope score
。
感谢任何帮助。
Summary of successfully produced models:
Filename molpdf DOPE score GA341 score
----------------------------------------------------------------------
1A4SA.B99990001.pdb 3116.26953 -54055.24609 1.00000
1A4SA.B99990002.pdb 3081.24854 -54028.02734 1.00000
1A4SA.B99990003.pdb 3188.48535 -53395.08594 1.00000
1A4SA.B99990004.pdb 3093.55493 -54574.60156 1.00000
1A4SA.B99990005.pdb 3141.67847 -53716.92188 1.00000
1A4SA.B99990006.pdb 3084.89136 -54276.48828 1.00000
1A4SA.B99990007.pdb 3081.57983 -53949.57031 1.00000
1A4SA.B99990008.pdb 3060.45142 -54121.53125 1.00000
1A4SA.B99990009.pdb 3080.59766 -54202.00000 1.00000
1A4SA.B99990010.pdb 3065.07520 -54293.01172 1.00000
答案 0 :(得分:0)
@lines
中的所有行... 以下说明了该过程:
use strict;
use warnings;
use Scalar::Util qw<looks_like_number>;
# putting a scalar as a list receiver,
# guarantees that, you'll only get one--and only one--value.
my ( $low_line )
=
# unpack the bundled cargo
map { $_->[1] }
# sort the lines by DOPE score...
sort { $a->[0] <=> $b->[0] }
# having attained that score by filtering
# out by those that look like a number...
grep { looks_like_number( $_->[0] ) }
# having paired the 3rd column (delimited by spaces)
# and the line...
map { [ (split)[2], $_ ] }
# from all the lines in the file.
@lines
;
我不打算讨论开放输入和那个,但我会告诉你一个等价物 while loop:
my ( $min_score, $min_line );
while ( <$input_file> ) {
# here we're invoking the most *standard* behavior of the split function...
next unless my $score = (split)[2];
# forget non-numbers...
next unless looks_like_number( $score );
# if we don't have a min score defined, or our current
# score is less, then store the min and the payload.
if ( !defined( $min_score ) || $score < $min_score ) {
( $min_score, $min_line ) = ( $score, $_ );
}
}
say $min_line;