]> git.donarmstrong.com Git - biopieces.git/commitdiff
added a skip_scores switch to read_solexa and read_fastq
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 4 Aug 2009 15:20:57 +0000 (15:20 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 4 Aug 2009 15:20:57 +0000 (15:20 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@624 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/read_fastq
bp_bin/read_solexa
code_perl/Maasha/Fastq.pm

index 088f8d6f06adf21dd5b109fe6097a3a34ecbfa15..df2ad6e088d786fa12bce015627d0ce89a3a250e 100755 (executable)
@@ -40,9 +40,10 @@ my ( $options, $in, $out, $record, $data_in, $num, $entry );
 
 $options = Maasha::Biopieces::parse_options(
     [
-        { long => 'data_in', short => 'i', type => 'files!', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
-        { long => 'num',     short => 'n', type => 'uint',   mandatory => 'no', default => undef, allowed => undef, disallowed => 0     },
-        { long => 'quality', short => 'q', type => 'uint',   mandatory => 'no', default => 20,    allowed => undef, disallowed => undef },
+        { long => 'data_in',     short => 'i', type => 'files!', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+        { long => 'num',         short => 'n', type => 'uint',   mandatory => 'no', default => undef, allowed => undef, disallowed => 0     },
+        { long => 'quality',     short => 'q', type => 'uint',   mandatory => 'no', default => 20,    allowed => undef, disallowed => undef },
+        { long => 'skip_scores', short => 's', type => 'flag',   mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
     ]   
 );
 
@@ -63,10 +64,13 @@ if ( $options->{ 'data_in' } )
     {
         if ( $record = Maasha::Fastq::fastq2biopiece( $entry ) )
         {
-            Maasha::Fastq::lowercase_low_scores( $record->{ 'SEQ' }, $record->{ 'SCORES' }, $options->{ 'quality' } );
+            if ( not $options->{ 'skip_scores' } )
+            {
+                Maasha::Fastq::lowercase_low_scores( $record->{ 'SEQ' }, $record->{ 'SCORES' }, $options->{ 'quality' } );
 
-            $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/(.)/ord( $1 ) - 33 . ";"/ge; # http://maq.sourceforge.net/fastq.shtml
+                $record->{ 'SCORE_MEAN' } = sprintf( "%.2f", Maasha::Calc::mean( [ split /;/, $record->{ 'SCORES' } ] ) );
+            }
 
             Maasha::Biopieces::put_record( $record, $out );
         }
index 9bb251afca9b9dce7cfa189b9050bb63d5a77b26..b1a84a49f50feca875b85f42ba43fa3bd12a35a0 100755 (executable)
@@ -42,10 +42,11 @@ my ( $options, $in, $out, $record, $data_in, $num, $entry, @seqs, @scores, $i );
 
 $options = Maasha::Biopieces::parse_options(
     [
-        { long => 'data_in', short => 'i', type => 'files!', mandatory => 'no', default => undef,   allowed => undef,           disallowed => undef },
-        { long => 'num',     short => 'n', type => 'uint',   mandatory => 'no', default => undef,   allowed => undef,           disallowed => '0' },
-        { long => 'format',  short => 'f', type => 'string', mandatory => 'no', default => 'octal', allowed => 'octal,decimal', disallowed => undef },
-        { long => 'quality', short => 'q', type => 'uint',   mandatory => 'no', default => 20,      allowed => undef,           disallowed => undef },
+        { long => 'data_in',     short => 'i', type => 'files!', mandatory => 'no', default => undef,   allowed => undef,           disallowed => undef },
+        { long => 'num',         short => 'n', type => 'uint',   mandatory => 'no', default => undef,   allowed => undef,           disallowed => '0' },
+        { long => 'format',      short => 'f', type => 'string', mandatory => 'no', default => 'octal', allowed => 'octal,decimal', disallowed => undef },
+        { long => 'quality',     short => 'q', type => 'uint',   mandatory => 'no', default => 20,      allowed => undef,           disallowed => undef },
+        { long => 'skip_scores', short => 's', type => 'flag',   mandatory => 'no', default => undef,   allowed => undef,           disallowed => undef },
     ]   
 );
 
@@ -66,12 +67,15 @@ if ( $options->{ 'data_in' } )
     {
         if ( $record = Maasha::Fastq::fastq2biopiece( $entry ) )
         {
-            $record->{ 'SCORES' } =~ s/(\d+) ?/Maasha::Fastq::score2phred( $1 )/ge if $options->{ 'format' } eq 'decimal';
-            Maasha::Fastq::solexa2phred( $record->{ 'SCORES' } );
-            Maasha::Fastq::lowercase_low_scores( $record->{ 'SEQ' }, $record->{ 'SCORES' }, $options->{ 'quality' } );
-
-            $record->{ 'SCORES' }     =~ s/(.)/ord( $1 ) - 33 . ";"/ge; # http://maq.sourceforge.net/fastq.shtml
-            $record->{ 'SCORE_MEAN' } = sprintf( "%.2f", Maasha::Calc::mean( [ split /;/, $record->{ 'SCORES' } ] ) );
+            if ( not $options->{ 'skip_scores' } )
+            {
+                $record->{ 'SCORES' } =~ s/(\d+) ?/Maasha::Fastq::score2phred( $1 )/ge if $options->{ 'format' } eq 'decimal';
+                Maasha::Fastq::solexa2phred( $record->{ 'SCORES' } );
+                Maasha::Fastq::lowercase_low_scores( $record->{ 'SEQ' }, $record->{ 'SCORES' }, $options->{ 'quality' } );
+
+                $record->{ 'SCORES' }     =~ s/(.)/ord( $1 ) - 33 . ";"/ge; # http://maq.sourceforge.net/fastq.shtml
+                $record->{ 'SCORE_MEAN' } = sprintf( "%.2f", Maasha::Calc::mean( [ split /;/, $record->{ 'SCORES' } ] ) );
+            }
 
             Maasha::Biopieces::put_record( $record, $out );
         }
index 4782486eeb072f358766786bb931c7b918c3d9b2..38ce4712705e49898dcd6e50ccc32fd2c81a5901 100644 (file)
@@ -220,6 +220,7 @@ sub fastq2biopiece
     $record->{ 'SEQ' }        = $entry->[ SEQ ];
     $record->{ 'SEQ_NAME' }   = $entry->[ SEQ_NAME ];
     $record->{ 'SCORES' }     = $entry->[ SCORES ];
+    $record->{ 'SEQ_LEN' }    = length $entry->[ SEQ ];
 
     return wantarray ? %{ $record } : $record;
 }