X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fread_454;h=96c6a4f0f8bdec096e9b85530dd71055b6dd47c7;hb=5de6112b70b59420b245ce636a8b2e3c90acbe00;hp=012bc3391525e83b1a7ecd958c2c9476e6265302;hpb=1ce139b812a363b40b1ce094a8b93e6df777ed99;p=biopieces.git diff --git a/bp_bin/read_454 b/bp_bin/read_454 index 012bc33..96c6a4f 100755 --- a/bp_bin/read_454 +++ b/bp_bin/read_454 @@ -42,13 +42,9 @@ my ( $options, $in, $out, $record, $data_in, $qual_in, $num, $fasta, $qual, @seq $options = Maasha::Biopieces::parse_options( [ - { long => 'data_in', short => 'i', type => 'file!', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef }, - { long => 'qual_in', short => 'q', type => 'file!', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef }, - { long => 'num', short => 'n', type => 'uint', mandatory => 'no', default => undef, allowed => undef, disallowed => '0' }, - { long => 'convert2dec', short => 'c', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef }, - { long => 'cutoff', short => 'C', type => 'int', mandatory => 'no', default => 20, allowed => undef, disallowed => undef }, - { long => 'soft_mask', short => 's', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef }, - { long => 'mean', short => 'm', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef }, + { long => 'data_in', short => 'i', type => 'file!', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef }, + { long => 'qual_in', short => 'q', type => 'file!', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef }, + { long => 'num', short => 'n', type => 'uint', mandatory => 'no', default => undef, allowed => undef, disallowed => '0' }, ] ); @@ -71,6 +67,7 @@ if ( $options->{ 'data_in' } ) $qual = get_qual( $qual_in ); check_names( $fasta, $qual ); + check_lengths( $fasta, $qual ); $record = { SEQ_NAME => $fasta->[ 0 ], @@ -79,11 +76,6 @@ if ( $options->{ 'data_in' } ) SCORES => $qual->[ 1 ], }; - $record->{ 'SCORES_MEAN' } = sprintf "%.2f", Maasha::Fastq::solexa_str_mean( $qual->[ 1 ] ) if $options->{ 'mean' }; - - Maasha::Fastq::softmask_solexa_str( $record->{ 'SEQ' }, $record->{ 'SCORES' }, $options->{ 'cutoff' } ) if $options->{ 'soft_mask' }; - $record->{ 'SCORES' } = Maasha::Fastq::solexa_str2dec_str( $record->{ 'SCORES' } ) if $options->{ 'convert2dec' }; - Maasha::Biopieces::put_record( $record, $out ); last if $options->{ "num" } and $num == $options->{ "num" }; @@ -138,7 +130,7 @@ sub get_qual $qual =~ tr/ \n\r/;;;/; $qual =~ s/;;/;/g; - $scores = Maasha::Fastq::dec_str2solexa_str( $qual ); + $scores = Maasha::Fastq::dec_str2phred_str( $qual ); $entry = [ $name, $scores ]; @@ -173,6 +165,28 @@ sub check_names } +sub check_lengths +{ + # Martin A. Hansen, April 2011. + + # Check if the lengths of the fasta and qual strings are the same + # and raise an error if not. + + my ( $fasta, # fasta entry + $qual, # qual entry + ) = @_; + + # Returns nothing. + + my ( $f_len, $q_len ); + + $f_len = length $fasta->[ 1 ]; + $q_len = length $qual->[ 1 ]; + + Maasha::Common::error( qq(lengths don't match "$f_len" != "$q_len") ) if $f_len != $q_len; +} + + # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<