]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/read_tab
adding bzip2 support in ruby
[biopieces.git] / bp_bin / read_tab
index 152c0d5f26fd8e715afc2b8a6c26ff7dbc6eab56..a8dede9d9ce979fb12c20718de8c993b1027cf2b 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl -w
+#!/usr/bin/env perl
 
 # Copyright (C) 2007-2009 Martin A. Hansen.
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
+use warnings;
 use strict;
-use Maasha::Common;
-use Maasha::Fasta;
+use Data::Dumper;
+use Maasha::Filesys;
 use Maasha::Biopieces;
 
 
@@ -57,22 +58,31 @@ while ( $record = Maasha::Biopieces::get_record( $in ) ) {
 
 if ( $options->{ 'data_in' } )
 {
-    $data_in = Maasha::Common::read_open_multi( $options->{ 'data_in' } );
+    $data_in = Maasha::Filesys::files_read_open( $options->{ 'data_in' } );
 
     $num  = 1;
     $skip = $options->{ 'skip' };
 
     while ( $line = <$data_in> ) 
     {
+        chomp $line;
+
         if ( $skip )
         {
             $skip--;
             next;
         }
 
-        next if $line =~ /^#|^$/;
+        next if $line =~ /^$/;  # skip empty lines.
 
-        chomp $line;
+        if ( $line =~ /^#.+/ and not defined $options->{ 'keys' } )
+        {
+            $line = substr $line, 1;
+
+            $options->{ 'keys' } = [ split /$options->{'delimit'}/, $line ];
+
+            next;
+        }
 
         undef $record;
         undef @fields2;
@@ -104,25 +114,22 @@ if ( $options->{ 'data_in' } )
     close $data_in;
 }
 
+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();
 }
 
 
@@ -130,7 +137,3 @@ END
 
 
 __END__
-
-
-
-