]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/bowtie_seq
fixed bowtie_seq
[biopieces.git] / bp_bin / bowtie_seq
index 92a511869107faf713e4771833509443d8072210..3dd3ddc9ceef293da023bd018088c8df07fae630 100755 (executable)
@@ -30,6 +30,7 @@ use warnings;
 use strict;
 use Maasha::Biopieces;
 use Maasha::Common;
+use Maasha::Fastq;
 use Maasha::Fasta;
 use Maasha::Calc;
 
@@ -37,7 +38,7 @@ use Maasha::Calc;
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $options, $in, $out, $index, $tmp_dir, $tmp_in, $tmp_out, $fh_in, $fh_out, $record, $entry, $line, @fields );
+my ( $options, $in, $out, $index, $tmp_dir, $tmp_in, $tmp_out, $fh_in, $fh_out, $record, $entry, $line, @fields, $type, $args );
 
 $options = Maasha::Biopieces::parse_options(
     [
@@ -58,8 +59,19 @@ $fh_out = Maasha::Filesys::file_write_open( $tmp_in );
 
 while ( $record = Maasha::Biopieces::get_record( $in ) ) 
 {
-    if ( $entry = Maasha::Fasta::biopiece2fasta( $record ) ) {
+    if ( $entry = Maasha::Fastq::biopiece2fastq( $record ) )
+    {
+        Maasha::Common::error( "Mixed FASTA and FASTQ entries in stream" ) if defined $type and $type ne "FASTQ";
+        Maasha::Fastq::put_entry( $entry, $fh_out );
+
+        $type = "FASTQ";
+    }
+    elsif ( $entry = Maasha::Fasta::biopiece2fasta( $record ) )
+    {
+        Maasha::Common::error( "Mixed FASTA and FASTQ entries in stream" ) if defined $type and $type ne "FASTA";
         Maasha::Fasta::put_entry( $entry, $fh_out );
+
+        $type = "FASTA";
     }
 
     Maasha::Biopieces::put_record( $record, $out );
@@ -67,10 +79,13 @@ while ( $record = Maasha::Biopieces::get_record( $in ) )
 
 close $fh_out;
 
+$args = "";
+$args = "-f" if $type eq "FASTA";
+
 if ( $options->{ 'verbose' } ) {
-    Maasha::Common::run( "bowtie", "-f $index $tmp_in $tmp_out" );
+    Maasha::Common::run( "bowtie", "$args $index $tmp_in $tmp_out" );
 } else {
-    Maasha::Common::run( "bowtie", "-f $index $tmp_in $tmp_out > /dev/null 2>&1" );
+    Maasha::Common::run( "bowtie", "$args $index $tmp_in $tmp_out > /dev/null 2>&1" );
 }
 
 unlink $tmp_in;