]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/read_tab
adding bzip2 support in ruby
[biopieces.git] / bp_bin / read_tab
index 0fda36bedd3aebc05a4c31cb1eeb1ae4a310ba2c..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;