X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fbowtie_seq;h=07374216593d0a6f24d7fd858f6de3b21c6377ec;hb=5de6112b70b59420b245ce636a8b2e3c90acbe00;hp=f7229f106fba9abe71105bd6adca0758237c9848;hpb=15fc1cc28abfb41e8630c731fd6459dcdcd08e10;p=biopieces.git diff --git a/bp_bin/bowtie_seq b/bp_bin/bowtie_seq index f7229f1..0737421 100755 --- a/bp_bin/bowtie_seq +++ b/bp_bin/bowtie_seq @@ -21,19 +21,25 @@ # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 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; use Maasha::Fasta; use Maasha::Calc; +use constant { + SEQ_NAME => 0, + SEQ => 1, + SCORES => 2, +}; # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @@ -51,7 +57,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" } ); @@ -74,6 +80,7 @@ while ( $record = Maasha::Biopieces::get_record( $in ) ) if ( $entry = Maasha::Fastq::biopiece2fastq( $record ) ) { Maasha::Common::error( "Mixed FASTA and FASTQ entries in stream" ) if defined $type and $type ne "FASTQ"; + Maasha::Common::error( "Sequence longer than 1024 not allowed") if length( $entry->[ SEQ ] ) > 1024; Maasha::Fastq::put_entry( $entry, $fh_out ); $type = "FASTQ"; @@ -81,6 +88,7 @@ while ( $record = Maasha::Biopieces::get_record( $in ) ) elsif ( $entry = Maasha::Fasta::biopiece2fasta( $record ) ) { Maasha::Common::error( "Mixed FASTA and FASTQ entries in stream" ) if defined $type and $type ne "FASTA"; + Maasha::Common::error( "Sequence longer than 1024 not allowed") if length( $entry->[ SEQ ] ) > 1024; Maasha::Fasta::put_entry( $entry, $fh_out ); $type = "FASTA"; @@ -92,7 +100,10 @@ while ( $record = Maasha::Biopieces::get_record( $in ) ) 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, "--phred33-quals" unless $type eq "FASTA"; if ( defined $options->{ 'max_hits' } ) { push @args, "-k $options->{ 'max_hits' }"; @@ -121,7 +132,6 @@ while ( $line = <$fh_in> ) chomp $line; @fields = split /\t/, $line; - $record = bowtie2biopiece( \@fields ); Maasha::Biopieces::put_record( $record, $out ); @@ -149,21 +159,22 @@ sub bowtie2biopiece # Returns a hash. - my ( $record, @scores ); - - $record->{ 'Q_ID' } = $entry->[ 0 ]; - $record->{ 'STRAND' } = $entry->[ 1 ]; - $record->{ 'S_ID' } = $entry->[ 2 ]; - $record->{ 'S_BEG' } = $entry->[ 3 ]; - $record->{ 'SEQ' } = $entry->[ 4 ]; - $record->{ 'SCORES' } = $entry->[ 5 ]; - $record->{ 'MISMATCH' } = $entry->[ 6 ]; - + my ( $record, $s_id, $s_len, $hits ); + + $record->{ 'Q_ID' } = $entry->[ 0 ]; + $record->{ 'STRAND' } = $entry->[ 1 ]; + $record->{ 'S_ID' } = $entry->[ 2 ]; + $record->{ 'S_BEG' } = $entry->[ 3 ]; + $record->{ 'SEQ' } = $entry->[ 4 ]; + $record->{ 'SCORES' } = $entry->[ 5 ]; + $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;