]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/sort_records
removed debug message
[biopieces.git] / bp_bin / sort_records
index 32d59dfc38c6e337b25d815f0375ba9487f70c85..af8edbc8c189489eb1a32d65043af37d1551f32a 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl -w
+#!/usr/bin/env perl
 
 # Copyright (C) 2007-2009 Martin A. Hansen.
 
@@ -26,6 +26,7 @@
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
+use warnings;
 use strict;
 use Maasha::Biopieces;
 
@@ -33,7 +34,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 ( $options, $in, $out, @keys, $key, @sort_cmd, $sort_str, $sort_sub, @records, $record, $i, $ok );
 
 $options = Maasha::Biopieces::parse_options(
     [
@@ -57,8 +58,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;
@@ -76,26 +88,22 @@ else
     }
 }
 
+Maasha::Biopieces::close_stream( $in );
+Maasha::Biopieces::close_stream( $out );
+
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
 BEGIN
 {
-    $run_time_beg = Maasha::Biopieces::run_time();
-
-    Maasha::Biopieces::log_biopiece();
+    Maasha::Biopieces::status_set();
 }
 
 
 END
 {
-    Maasha::Biopieces::close_stream( $in );
-    Maasha::Biopieces::close_stream( $out );
-
-    $run_time_end = Maasha::Biopieces::run_time();
-
-    Maasha::Biopieces::run_time_print( $run_time_beg, $run_time_end, $options );
+    Maasha::Biopieces::status_log();
 }
 
 
@@ -103,4 +111,3 @@ END
 
 
 __END__
-