]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed bug in sort_records
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 4 Jun 2009 13:43:56 +0000 (13:43 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 4 Jun 2009 13:43:56 +0000 (13:43 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@473 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/sort_records

index 32d59dfc38c6e337b25d815f0375ba9487f70c85..9c551b097dbb775ff8864869ac01b781a8770aa4 100755 (executable)
@@ -33,7 +33,7 @@ use Maasha::Biopieces;
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $run_time_beg, $run_time_end, $options, $in, $out, @keys, $key, @sort_cmd, $sort_str, $sort_sub, @records, $record, $i );
+my ( $run_time_beg, $run_time_end, $options, $in, $out, @keys, $key, @sort_cmd, $sort_str, $sort_sub, @records, $record, $i, $ok );
 
 $options = Maasha::Biopieces::parse_options(
     [
@@ -57,8 +57,19 @@ foreach $key ( @{ $options->{ "keys" } } )
 $sort_str = join " or ", @sort_cmd;
 $sort_sub = eval "sub { $sort_str }";   # NB security issue!
 
-while ( $record = Maasha::Biopieces::get_record( $in ) ) {
-    push @records, $record;
+while ( $record = Maasha::Biopieces::get_record( $in ) )
+{
+    $ok = 1;
+    foreach $key ( @{ $options->{ "keys" } } )
+    {
+        if ( not exists $record->{ $key } )
+        {
+            $ok = 0;
+            last;
+        }
+    }
+
+    push @records, $record if $ok;
 }
 
 @records = sort $sort_sub @records;