From b5a27ee6cfcd801325482ff0d1f4ccd8fbfb81db Mon Sep 17 00:00:00 2001 From: martinahansen Date: Fri, 3 Jul 2009 14:40:18 +0000 Subject: [PATCH] clearning ruby dir git-svn-id: http://biopieces.googlecode.com/svn/trunk@552 74ccb610-7750-0410-82ae-013aeee3265d --- code_ruby/Maasha/{ => lib}/biopieces.rb | 0 code_ruby/Maasha/lib/seq.rb | 5 +++++ code_ruby/Maasha/test/test_seq.rb | 30 +++++++++++++++---------- code_ruby/Maasha/test_module.rb | 7 ------ 4 files changed, 23 insertions(+), 19 deletions(-) rename code_ruby/Maasha/{ => lib}/biopieces.rb (100%) delete mode 100755 code_ruby/Maasha/test_module.rb diff --git a/code_ruby/Maasha/biopieces.rb b/code_ruby/Maasha/lib/biopieces.rb similarity index 100% rename from code_ruby/Maasha/biopieces.rb rename to code_ruby/Maasha/lib/biopieces.rb diff --git a/code_ruby/Maasha/lib/seq.rb b/code_ruby/Maasha/lib/seq.rb index ba79c85..f80d397 100644 --- a/code_ruby/Maasha/lib/seq.rb +++ b/code_ruby/Maasha/lib/seq.rb @@ -8,6 +8,11 @@ class Seq < String @seq_type = seq_type end + # Method for outputting sequence as a String. + def to_s + @seq + end + # Guess the sequence type by analyzing the first 100 residues allowing for ambiguity codes. def seq_type_guess seq_beg = @seq[ 0, 100 ].upcase diff --git a/code_ruby/Maasha/test/test_seq.rb b/code_ruby/Maasha/test/test_seq.rb index 7e8c89d..4297720 100755 --- a/code_ruby/Maasha/test/test_seq.rb +++ b/code_ruby/Maasha/test/test_seq.rb @@ -28,6 +28,12 @@ class TestSeq < Test::Unit::TestCase assert_equal( :DNA, s.seq_type ) end + # Testing Seq#to_s + def test_to_s + s = Seq.new( "ATCG" ) + assert_equal( "ATCG", s.to_s ) + end + # Testing Seq#seq_type_guess def test_seq_type_guess_DNA_uppercase @@ -150,19 +156,19 @@ class TestSeq < Test::Unit::TestCase def test_wrap_with_0_args s = Seq.new( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACGACTACGACT" ) - assert_equal( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACG\nACTACGACT", s.wrap ) + assert_equal( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACG\nACTACGACT", s.wrap.to_s ) end def test_wrap_with_1_args s = Seq.new( "ATCG" ) - assert_equal( "AT\nCG", s.wrap( 2 ) ) + assert_equal( "AT\nCG", s.wrap( 2 ).to_s ) end def test_wrap_with_2_args s = Seq.new( "ATCG" ) - assert_equal( "AT\rCG", s.wrap( 2, "\r" ) ) + assert_equal( "AT\rCG", s.wrap( 2, "\r" ).to_s ) end def test_wrap_dont_change_instance_var @@ -170,7 +176,7 @@ class TestSeq < Test::Unit::TestCase s.wrap( 2 ) - assert_equal( "ATCG", s.seq ) + assert_equal( "ATCG", s.to_s ) end # Testing Seq#wrap! @@ -180,7 +186,7 @@ class TestSeq < Test::Unit::TestCase s.wrap! - assert_equal( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACG\nACTACGACT", s.seq ) + assert_equal( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACG\nACTACGACT", s.to_s ) end def test_wrap_with_1_args! @@ -188,7 +194,7 @@ class TestSeq < Test::Unit::TestCase s.wrap!( 2 ) - assert_equal( "AT\nCG", s.seq ) + assert_equal( "AT\nCG", s.to_s ) end def test_wrap_with_2_args! @@ -196,7 +202,7 @@ class TestSeq < Test::Unit::TestCase s.wrap!( 2, "\r" ) - assert_equal( "AT\rCG", s.seq ) + assert_equal( "AT\rCG", s.to_s ) end # Testing Seq#generate @@ -227,7 +233,7 @@ class TestSeq < Test::Unit::TestCase seq = s.generate( 40 ) - assert_equal( "", s.seq ) + assert_equal( "", s.to_s ) end # Testing Seq#generate! @@ -235,11 +241,11 @@ class TestSeq < Test::Unit::TestCase def test_generate! s = Seq.new( "", :AA ) - gen_seq = s.generate!( 40 ) + gen_seq = s.generate!( 40 ).to_s assert_equal( 40, gen_seq.length ) assert_equal( 40, s.seq.length ) - assert_equal( gen_seq, s.seq ) + assert_equal( gen_seq, s.to_s ) end # Testing Seq::AA#initialize @@ -247,14 +253,14 @@ class TestSeq < Test::Unit::TestCase # test marked for deletion - too simple and not informative def test_Seq_AA_initialize_with_0_args s = Seq::AA.new - assert_equal( "", s.seq ) + assert_equal( "", s.to_s ) assert_equal( :AA, s.seq_type ) end # test marked for deletion - too simple and not informative def test_Seq_AA_initialize_with_1_args s = Seq::AA.new( "SEQ" ) - assert_equal( "SEQ", s.seq ) + assert_equal( "SEQ", s.to_s ) assert_equal( :AA, s.seq_type ) end end diff --git a/code_ruby/Maasha/test_module.rb b/code_ruby/Maasha/test_module.rb deleted file mode 100755 index a94e234..0000000 --- a/code_ruby/Maasha/test_module.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Test - puts "Modules Test1 loaded" - - def greet_world - puts "Hello" - end -end -- 2.39.5