]> git.donarmstrong.com Git - biopieces.git/commitdiff
last cleanups
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 3 Jul 2009 15:08:59 +0000 (15:08 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 3 Jul 2009 15:08:59 +0000 (15:08 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@553 74ccb610-7750-0410-82ae-013aeee3265d

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

index f80d397fbc6878388b725172e3af29e2533b0a46..8146ab4fc3c9409ac9274515330fd6b042f2228f 100644 (file)
@@ -121,6 +121,12 @@ class Seq < String
        class NA < Seq
                # Class containing methods specific for DNA sequences.
                class DNA < NA
+                       # Method to initialize a new DNA sequence.
+                       def initialize( seq = "" )
+                               @seq      = seq
+                               @seq_type = :DNA
+                       end
+
                        # Method that complements DNA sequence including ambiguity codes.
                        def complement
                                @seq.tr!( 'AGCUTRYWSMKHDVBNagcutrywsmkhdvbn', 'TCGAAYRWSKMDHBVNtcgaayrwskmdhbvn' )
@@ -129,6 +135,12 @@ class Seq < String
 
                # Class containing methods specific for RNA sequences.
                class RNA < NA
+                       # Method to initialize a new RNA sequence.
+                       def initialize( seq = "" )
+                               @seq      = seq
+                               @seq_type = :RNA
+                       end
+
                        # Method that complements RNA sequence including ambiguity codes.
                        def complement
                                @seq.tr!( 'AGCUTRYWSMKHDVBNagcutrywsmkhdvbn', 'UCGAAYRWSKMDHBVNucgaayrwskmdhbvn' )
index 4297720dcfed260063b3d347a8c9613188ed2b17..e6e28a2e8c985b058e0aa1b36e1aa046bb89bea2 100755 (executable)
@@ -263,5 +263,63 @@ class TestSeq < Test::Unit::TestCase
                assert_equal( "SEQ", s.to_s )
                assert_equal( :AA,  s.seq_type )
        end
+
+       # Testing Seq::AA#mol_weight
+
+       def test_Seq_aa_mol_wight_bad_residue
+               s = Seq::AA.new( "7" )
+               assert_raise( RuntimeError ) { s.mol_weight }
+       end
+
+       def test_Seq_aa_mol_wight_return_correct
+               s = Seq::AA.new( "SEQ" )
+               assert_equal( 398.0, s.mol_weight )
+       end
+
+       # Testing Seq::NA::DNA#initialize
+
+       # test marked for deletion - too simple and not informative
+       def test_Seq_NA_DNA_inialize_with_0_args
+               s = Seq::NA::DNA.new
+               assert_equal( "", s.to_s )
+               assert_equal( :DNA, s.seq_type )
+       end
+
+       # test marked for deletion - too simple and not informative
+       def test_Seq_NA_DNA_inialize_with_1_args
+               s = Seq::NA::DNA.new( "ATCG" )
+               assert_equal( "ATCG", s.to_s )
+               assert_equal( :DNA, s.seq_type )
+       end
+
+       # Testing Seq::NA::DNA#complement
+
+       def test_Seq_NA_DNA_complement_correct
+               s = Seq::NA::DNA.new( "ATCG" )
+               assert_equal( "TAGC", s.complement.to_s )
+       end
+
+       # Testing Seq::NA::RNA#initialize
+
+       # test marked for deletion - too simple and not informative
+       def test_Seq_NA_RNA_inialize_with_0_args
+               s = Seq::NA::RNA.new
+               assert_equal( "", s.to_s )
+               assert_equal( :RNA, s.seq_type )
+       end
+
+       # test marked for deletion - too simple and not informative
+       def test_Seq_NA_RNA_inialize_with_1_args
+               s = Seq::NA::RNA.new( "AUCG" )
+               assert_equal( "AUCG", s.to_s )
+               assert_equal( :RNA, s.seq_type )
+       end
+
+       # Testing Seq::NA::RNA#complement
+
+       def test_Seq_NA_DNA_complement_correct
+               s = Seq::NA::RNA.new( "AUCG" )
+               assert_equal( "UAGC", s.complement.to_s )
+       end
 end