]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed issues in fastq handling
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 2 Sep 2009 10:20:14 +0000 (10:20 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 2 Sep 2009 10:20:14 +0000 (10:20 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@648 74ccb610-7750-0410-82ae-013aeee3265d

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

index df2ad6e088d786fa12bce015627d0ce89a3a250e..a5f82bce3313d605ddd72b20f49de352a36a40d6 100755 (executable)
@@ -40,10 +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 => 'skip_scores', short => 's', type => 'flag',   mandatory => 'no', default => undef, 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_quality', short => 's', type => 'flag',   mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
     ]   
 );
 
@@ -64,7 +64,7 @@ if ( $options->{ 'data_in' } )
     {
         if ( $record = Maasha::Fastq::fastq2biopiece( $entry ) )
         {
-            if ( not $options->{ 'skip_scores' } )
+            if ( not $options->{ 'skip_quality' } )
             {
                 Maasha::Fastq::lowercase_low_scores( $record->{ 'SEQ' }, $record->{ 'SCORES' }, $options->{ 'quality' } );
 
index b1a84a49f50feca875b85f42ba43fa3bd12a35a0..c1b4f0ba1be06dbb945ceec512ee389ff7cef67b 100755 (executable)
@@ -42,11 +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 => 'skip_scores', short => 's', type => 'flag',   mandatory => 'no', default => undef,   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_quality', short => 's', type => 'flag',   mandatory => 'no', default => undef,   allowed => undef,           disallowed => undef },
     ]   
 );
 
@@ -67,7 +67,7 @@ if ( $options->{ 'data_in' } )
     {
         if ( $record = Maasha::Fastq::fastq2biopiece( $entry ) )
         {
-            if ( not $options->{ 'skip_scores' } )
+            if ( not $options->{ 'skip_quality' } )
             {
                 $record->{ 'SCORES' } =~ s/(\d+) ?/Maasha::Fastq::score2phred( $1 )/ge if $options->{ 'format' } eq 'decimal';
                 Maasha::Fastq::solexa2phred( $record->{ 'SCORES' } );
index 38ce4712705e49898dcd6e50ccc32fd2c81a5901..cc895203672dc241ffe90773994508e4b73c178c 100644 (file)
@@ -105,24 +105,6 @@ char score2phred( int score )
 }
 
 
-void lowercase_low_scores( char *seq, char *scores, int threshold )
-{
-    /* Martin A. Hansen, July 2009 */
-
-    /* Given a sequence string and a score string (in FASTQ/Phread range) */
-    /* lowercases all residues where the decimal score is below a given threshold. */
-
-    int i = 0;
-
-    for ( i = 0; i < strlen( seq ); i++ )
-    {
-        if ( phred2score( scores[ i ] ) < threshold ) {
-            seq[ i ] = tolower( seq[ i ] );
-        }
-    }
-}
-
-
 void solexa2phred( char *scores )
 {
     /* Martin A. Hansen, July 2009 */
@@ -135,8 +117,8 @@ void solexa2phred( char *scores )
 
     for ( i = 0; i < strlen( scores ); i++ )
     {
-        score       = solexa2score( scores[ i ] );
-        c           = score2phred( score );
+        score = solexa2score( scores[ i ] );
+        c     = score2phred( score );
 
 //        printf( "scores[i]: %c  score: %d  char: %c\n", scores[ i ], score, c );
 
@@ -145,6 +127,24 @@ void solexa2phred( char *scores )
 }
 
 
+void lowercase_low_scores( char *seq, char *scores, int threshold )
+{
+    /* Martin A. Hansen, July 2009 */
+
+    /* Given a sequence string and a score string (in FASTQ/Phread range) */
+    /* lowercases all residues where the decimal score is below a given threshold. */
+
+    int i = 0;
+
+    for ( i = 0; i < strlen( seq ); i++ )
+    {
+        if ( phred2score( scores[ i ] ) < threshold ) {
+            seq[ i ] = tolower( seq[ i ] );
+        }
+    }
+}
+
+
 END_C