X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fread_454;h=96c6a4f0f8bdec096e9b85530dd71055b6dd47c7;hb=5de6112b70b59420b245ce636a8b2e3c90acbe00;hp=b84ab12770a270471f997e4d469c5f59c5c6b731;hpb=510346353f3669b1bd7595acf0efab26b11c1f71;p=biopieces.git diff --git a/bp_bin/read_454 b/bp_bin/read_454 index b84ab12..96c6a4f 100755 --- a/bp_bin/read_454 +++ b/bp_bin/read_454 @@ -42,12 +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 => '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' }, ] ); @@ -70,15 +67,14 @@ if ( $options->{ 'data_in' } ) $qual = get_qual( $qual_in ); check_names( $fasta, $qual ); + check_lengths( $fasta, $qual ); $record = { - SEQ_NAME => $fasta->[ 0 ], - SEQ => $fasta->[ 1 ], - SCORES => $qual->[ 1 ], + SEQ_NAME => $fasta->[ 0 ], + SEQ => $fasta->[ 1 ], + SEQ_LEN => length $fasta->[ 1 ], + SCORES => $qual->[ 1 ], }; - - 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 ); @@ -134,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 ]; @@ -169,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; +} + + # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<