From: martinahansen Date: Fri, 8 Feb 2013 07:48:39 +0000 (+0000) Subject: fixed quality score validity check X-Git-Url: https://git.donarmstrong.com/?p=biopieces.git;a=commitdiff_plain;h=c54a2cc53ee2a7db8028ef593be593e527dc50c2 fixed quality score validity check git-svn-id: http://biopieces.googlecode.com/svn/trunk@2091 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/bp_bin/read_fastq b/bp_bin/read_fastq index 44a69ed..96be2c3 100755 --- a/bp_bin/read_fastq +++ b/bp_bin/read_fastq @@ -65,12 +65,15 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| 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') + + if first + raise SeqError, "Quality score outside valid range" unless entry.qual_valid?('illumina13') + first = false + end + output.puts entry.to_bp num += 1 diff --git a/code_ruby/lib/maasha/seq.rb b/code_ruby/lib/maasha/seq.rb index f2d93d1..8833acb 100644 --- a/code_ruby/lib/maasha/seq.rb +++ b/code_ruby/lib/maasha/seq.rb @@ -552,12 +552,12 @@ class Seq raise SeqError, "Missing qual" if self.qual.nil? case encoding.downcase - when "sanger" then return true if self.qual.match(/^[!-I]*$/) - when "454" then return true if self.qual.match(/^[@-h]*$/) - when "solexa" then return true if self.qual.match(/^[;-h]*$/) - when "illumina13" then return true if self.qual.match(/^[@-h]*$/) - when "illumina15" then return true if self.qual.match(/^[@-h]*$/) - when "illumina18" then return true if self.qual.match(/^[!-J]*$/) + when "sanger" then return true if self.qual.match(/^[!-~]*$/) + when "454" then return true if self.qual.match(/^[@-~]*$/) + when "solexa" then return true if self.qual.match(/^[;-~]*$/) + when "illumina13" then return true if self.qual.match(/^[@-~]*$/) + when "illumina15" then return true if self.qual.match(/^[@-~]*$/) + when "illumina18" then return true if self.qual.match(/^[!-~]*$/) else raise SeqError, "unknown quality score encoding: #{encoding}" end diff --git a/code_ruby/test/maasha/test_seq.rb b/code_ruby/test/maasha/test_seq.rb index 171e6b1..a7145ef 100755 --- a/code_ruby/test/maasha/test_seq.rb +++ b/code_ruby/test/maasha/test_seq.rb @@ -520,12 +520,12 @@ class TestSeq < Test::Unit::TestCase end def test_Seq_qual_valid_returns_correctly - tests = [["sanger", 0, 40, 33], - ["454", 0, 40, 64], - ["solexa", -5, 40, 64], - ["illumina13", 0, 40, 64], - ["illumina15", 0, 40, 64], - ["illumina18", 0, 41, 33]] + tests = [["sanger", 0, 93, 33], + ["454", 0, 62, 64], + ["solexa", -5, 62, 64], + ["illumina13", 0, 62, 64], + ["illumina15", 0, 62, 64], + ["illumina18", 0, 93, 33]] tests.each do |test| @entry.qual = (test[1] + test[-1]).chr + (test[2] + test[-1]).chr