]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/bowtie_seq
added join_seq biopiece
[biopieces.git] / bp_bin / bowtie_seq
index 3505771466ccdecd4e0f50d12e290984d63b6bb0..cd0aeb2eddc5790a7e4dadca38476e06878115c3 100755 (executable)
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
-# Use bowtie to map sequences in the stream against a specified genome.
+# Use bowtie to map sequences in the stream against a specified genome or index.
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
 use warnings;
 use strict;
+use Data::Dumper;
 use Maasha::Biopieces;
 use Maasha::Common;
 use Maasha::Fastq;
@@ -51,7 +52,7 @@ $options = Maasha::Biopieces::parse_options(
     ]   
 );
 
-Maasha::Common::error( qq(both --index_hame and --genome specified) ) if     $options->{ "genome" } and     $options->{ "index_name" };
+Maasha::Common::error( qq(both --index_name and --genome specified) ) if     $options->{ "genome" } and     $options->{ "index_name" };
 Maasha::Common::error( qq(no --index_name or --genome specified) )    if not $options->{ "genome" } and not $options->{ "index_name" };
 
 $in  = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
@@ -94,6 +95,8 @@ close $fh_out;
 push @args, "-n $options->{ 'mismatches' }";
 push @args, "-v $options->{ 'mismatches' }";  # DANGER: using seed mismatches as alignment mismatches - may work, may not!
 push @args, "-f" if $type eq "FASTA";
+push @args, "-p $options->{ 'cpus' }";
+push @args, "--phred64-quals";
 
 if ( defined $options->{ 'max_hits' } ) {
     push @args, "-k $options->{ 'max_hits' }";
@@ -122,7 +125,6 @@ while ( $line = <$fh_in> )
     chomp $line;
 
     @fields = split /\t/, $line;
-
     $record = bowtie2biopiece( \@fields );
 
     Maasha::Biopieces::put_record( $record, $out );
@@ -150,7 +152,7 @@ sub bowtie2biopiece
 
     # Returns a hash.
 
-    my ( $record, @scores );
+    my ( $record, $s_id, $s_len, $hits );
 
     $record->{ 'Q_ID' }       = $entry->[ 0 ];
     $record->{ 'STRAND' }     = $entry->[ 1 ];
@@ -158,14 +160,14 @@ sub bowtie2biopiece
     $record->{ 'S_BEG' }      = $entry->[ 3 ];
     $record->{ 'SEQ' }        = $entry->[ 4 ];
     $record->{ 'SCORES' }     = $entry->[ 5 ];
-    $record->{ 'MAP_COUNT' }  = $entry->[ 6 ];
-    $record->{ 'DESCRIPTOR' } = $entry->[ 7 ];
-
+    $record->{ 'SCORE' }      = $entry->[ 6 ] + 1;
+    $record->{ 'ALIGN' }      = $entry->[ 7 ] || '.';
+    $record->{ 'S_LEN' }      = length $entry->[ 4 ];
     $record->{ 'SEQ_LEN' }    = length $entry->[ 4 ];
     $record->{ 'S_END' }      = $record->{ 'S_BEG' } + $record->{ 'SEQ_LEN' } - 1;
-    $record->{ 'SCORES' }     =~ s/(.)/ord( $1 ) - 33 . ";"/ge; # http://maq.sourceforge.net/fastq.shtml
-    $record->{ 'SCORE_MEAN' } = sprintf( "%.2f", Maasha::Calc::mean( [ split /;/, $record->{ 'SCORES' } ] ) );
+    $record->{ 'SCORES' }     =~ s/(.)/chr( ( ord( $1 ) - 33 ) + 64 )/ge; # convert phred scores to illumina scores
 
+    $record->{ 'HITS' }       = '.';
     $record->{ 'REC_TYPE' } = "BOWTIE";
 
     return wantarray ? %{ $record } : $record;