]> git.donarmstrong.com Git - biopieces.git/commitdiff
added test for length of seq/qual mismatch
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 26 Sep 2013 12:48:14 +0000 (12:48 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 26 Sep 2013 12:48:14 +0000 (12:48 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@2222 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/lib/maasha/seq.rb
code_ruby/test/maasha/test_seq.rb

index 1d8f3c00594e9208f434251eb23c342413df9506..fd83ba3282d28c561358fb9383c18e324d9a7ed4 100644 (file)
@@ -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
index bbb6759277359c0254275cc92101bd00c113abe6..d773ae2298e77c84b206be12ff32108b600ffd87 100755 (executable)
@@ -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)