]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/read_fastq
disable validity check
[biopieces.git] / bp_bin / read_fastq
index a1206f5183faa23934785a1b76372a9bf6b96b05..44a69ed871cd40f686d4f9be675258377b4c6ebf 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env ruby
 
-# Copyright (C) 2007-2011 Martin A. Hansen.
+# Copyright (C) 2007-2013 Martin A. Hansen.
 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -40,8 +40,9 @@ casts << {:long=>'encoding', :short=>'e', :type=>'string', :mandatory=>false, :d
 
 options = Biopieces.options_parse(ARGV, casts)
 
-num  = 0
-last = false
+num   = 0
+first = true
+last  = false
 
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   unless options[:data_in] and options[:data_in].first == '-'
@@ -57,13 +58,16 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
       Fastq.open(file, mode='r') do |fastq|
         fastq.each do |entry|
           if encoding == 'auto'
-            if entry.qual.match(/[!-:]/) # sanger or illumina18
+            if entry.qual_base33? # sanger or illumina18
               encoding = 'illumina18'
-            elsif entry.qual.match(/[K-h]/) # solexa or illumina13 or illumina15
+            elsif entry.qual_base64? # solexa or illumina13 or illumina15
               encoding = 'illumina13'
             else
               raise SeqError, "Could not auto-detect quality score encoding"
             end
+          elsif first
+            #raise SeqError, "Quality score outside valid range" unless entry.qual_valid?(encoding)
+            first = false
           end
 
           entry.convert_scores!(encoding, 'illumina13')