From: martinahansen Date: Thu, 26 Sep 2013 12:48:14 +0000 (+0000) Subject: added test for length of seq/qual mismatch X-Git-Url: https://git.donarmstrong.com/?p=biopieces.git;a=commitdiff_plain;h=545eed9d7927e2c59a7c7d3c919aa8d8bed18c86 added test for length of seq/qual mismatch git-svn-id: http://biopieces.googlecode.com/svn/trunk@2222 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_ruby/lib/maasha/seq.rb b/code_ruby/lib/maasha/seq.rb index 1d8f3c0..fd83ba3 100644 --- a/code_ruby/lib/maasha/seq.rb +++ b/code_ruby/lib/maasha/seq.rb @@ -135,6 +135,10 @@ class Seq @seq = seq @type = type @qual = qual + + if @qual + raise SeqError, "Sequence length and score length mismatch: #{@seq.length} != #{@qual.length}" if @seq.length != @qual.length + end end # Method that guesses and returns the sequence type diff --git a/code_ruby/test/maasha/test_seq.rb b/code_ruby/test/maasha/test_seq.rb index bbb6759..d773ae2 100755 --- a/code_ruby/test/maasha/test_seq.rb +++ b/code_ruby/test/maasha/test_seq.rb @@ -34,6 +34,10 @@ class TestSeq < Test::Unit::TestCase @entry = Seq.new end + test "Seq.new with differnet length SEQ and SCORES raises" do + assert_raise(SeqError) { Seq.new("test", "ATCG", "dna", "hhh") } + end + test "Seq.new_bp returns correctly" do record = {:SEQ_NAME => "test", :SEQ => "ATCG", :SEQ_TYPE => :dna, :SCORES => "hhhh"} seq = Seq.new_bp(record)