]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/read_454
removed debug message
[biopieces.git] / bp_bin / read_454
index 732e81df50f8850a94c9e5cfe360cad8d66f49fe..96c6a4f0f8bdec096e9b85530dd71055b6dd47c7 100755 (executable)
@@ -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,18 +67,15 @@ 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 ],
+            SEQ_LEN     => length $fasta->[ 1 ],
             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" };
@@ -137,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 ];
 
@@ -172,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;
+}
+
+
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<