X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fbowtie_seq;h=2b9254d882c8ac728f6c59b2ec2c2dc9c9bc49c5;hb=65dca98102521647b2ccb2168b095bfc808a9c40;hp=c69d29c9f8d71560c94c911351320aeb90cc97ec;hpb=7473792b77113ead9bf77a7b4d184464f3b7f41c;p=biopieces.git diff --git a/bp_bin/bowtie_seq b/bp_bin/bowtie_seq index c69d29c..2b9254d 100755 --- a/bp_bin/bowtie_seq +++ b/bp_bin/bowtie_seq @@ -42,16 +42,26 @@ my ( $options, $in, $out, $index, $tmp_dir, $tmp_in, $tmp_out, $fh_in, $fh_out, $options = Maasha::Biopieces::parse_options( [ - { long => 'genome', short => 'g', type => 'genome', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef }, - { long => 'mismatches', short => 'm', type => 'uint', mandatory => 'no', default => 2, allowed => "0,1,2,3", disallowed => undef }, - { long => 'max_hits', short => 'h', type => 'uint', mandatory => 'no', default => undef, allowed => undef, disallowed => 0 }, + { long => 'genome', short => 'g', type => 'genome', mandatory => 'no', default => undef, allowed => undef, disallowed => undef }, + { long => 'index_name', short => 'i', type => 'string', mandatory => 'no', default => undef, allowed => undef, disallowed => undef }, + { long => 'mismatches', short => 'm', type => 'uint', mandatory => 'no', default => 0, allowed => "0,1,2,3", disallowed => undef }, + { long => 'max_hits', short => 'h', type => 'uint', mandatory => 'no', default => undef, allowed => undef, disallowed => 0 }, + { long => 'seed_length', short => 's', type => 'uint', mandatory => 'no', default => 28, allowed => undef, disallowed => 0 }, + { long => 'cpus', short => 'c', type => 'uint', mandatory => 'no', default => 1, allowed => undef, disallowed => 0 }, ] ); +Maasha::Common::error( qq(both --index_hame 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" } ); $out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } ); -$index = "$ENV{ 'BP_DATA' }/genomes/$options->{ 'genome' }/bowtie/$options->{ 'genome' }"; +if ( defined $options->{ 'genome' } ) { + $index = "$ENV{ 'BP_DATA' }/genomes/$options->{ 'genome' }/bowtie/$options->{ 'genome' }"; +} elsif (defined $options->{ 'index_name' } ) { + $index = $options->{ 'index_name' }; +} $tmp_dir = Maasha::Biopieces::get_tmpdir(); $tmp_in = "$tmp_dir/bowtie.seq"; @@ -82,7 +92,9 @@ 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' }"; if ( defined $options->{ 'max_hits' } ) { push @args, "-k $options->{ 'max_hits' }"; @@ -92,9 +104,13 @@ if ( defined $options->{ 'max_hits' } ) { $arg = join " ", @args; -if ( $options->{ 'verbose' } ) { +if ( $options->{ 'verbose' } ) +{ + print STDERR qq(Running: bowtie $arg $index $tmp_in $tmp_out\n); Maasha::Common::run( "bowtie", "$arg $index $tmp_in $tmp_out" ); -} else { +} +else +{ Maasha::Common::run( "bowtie", "$arg $index $tmp_in $tmp_out > /dev/null 2>&1" ); } @@ -107,7 +123,6 @@ while ( $line = <$fh_in> ) chomp $line; @fields = split /\t/, $line; - $record = bowtie2biopiece( \@fields ); Maasha::Biopieces::put_record( $record, $out ); @@ -137,14 +152,14 @@ sub bowtie2biopiece 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 ]; - + $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->{ 'DESCRIPTOR' } = $entry->[ 7 ]; $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