From: martinahansen Date: Tue, 23 Aug 2011 14:06:02 +0000 (+0000) Subject: worked on unit tests for sam.rb X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=e476daac131c17dc82b1e97484b73bbdbb7c16d8;p=biopieces.git worked on unit tests for sam.rb git-svn-id: http://biopieces.googlecode.com/svn/trunk@1492 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_ruby/lib/maasha/sam.rb b/code_ruby/lib/maasha/sam.rb index df518e6..3ffc56d 100644 --- a/code_ruby/lib/maasha/sam.rb +++ b/code_ruby/lib/maasha/sam.rb @@ -288,6 +288,17 @@ class Sam < Filesys end end end + + # Method to check if rnext, when not '*' or '=' + # and @SQ header lines are present, is located + # in the header hash. + def check_rnext(rnext) + unless @header.empty? or rnext == '*' or rnext == '=' + unless @header[:SQ][:SN].has_key? rnext.to_sym + raise SamError, "rnext not found in header hash: #{rnext}" + end + end + end end diff --git a/code_ruby/test/maasha/test_sam.rb b/code_ruby/test/maasha/test_sam.rb index e056b21..8642f64 100755 --- a/code_ruby/test/maasha/test_sam.rb +++ b/code_ruby/test/maasha/test_sam.rb @@ -340,7 +340,7 @@ class SamTest < Test::Unit::TestCase assert_raise(SamError) { sam.each } end - def test_Sam_each_wtih_rname_present_in_header_dont_raise + def test_Sam_each_with_rname_present_in_header_dont_raise sam = Sam.new(StringIO.new("@SQ\tSN:ref\tLN:45\n*\t*\tref\t*\t*\t*\t*\t*\t\*\t*\t*\n")) assert_nothing_raised { sam.each }