From e476daac131c17dc82b1e97484b73bbdbb7c16d8 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Tue, 23 Aug 2011 14:06:02 +0000 Subject: [PATCH] worked on unit tests for sam.rb git-svn-id: http://biopieces.googlecode.com/svn/trunk@1492 74ccb610-7750-0410-82ae-013aeee3265d --- code_ruby/lib/maasha/sam.rb | 11 +++++++++++ code_ruby/test/maasha/test_sam.rb | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) 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 } -- 2.39.2