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' )
# 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' )
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