예제 #1
0
 def test_rna_reverse_complement(self):
     test_set = [("A", "U"), ("U", "A"), ("G", "C"), ("C", "G"),
                 ("AU", "AU"), ("GC", "GC"), ("AG", "CU"), ("GU", "AC"),
                 ("AUGC", "GCAU"), ("CCCC", "GGGG")]
     for string, rc_string in test_set:
         res = RNA(string).reverse_complement()
         self.assertEqual(RNA(rc_string), res)
예제 #2
0
 def test_rna_hashable(self):
     test_set = ["A", "AGCAUCGAUC", "GCGCGCGCGCGCUA"]
     for string in test_set:
         try:
             {RNA(string)}
             self.assertEqual(len({RNA(string), string}), 2)
         except TypeError:
             self.fail("Object is unhashable")
예제 #3
0
 def test_rna_getitem(self):
     test_seq = "AUCGAUCGACUCGCUACGCUCGCUCGACU"
     test_set = [
         slice(None, None, None),
         slice(1, None, None),
         slice(None, 2, None),
         slice(None, None, 3),
         slice(1, None, 2),
         slice(1, -1, 2),
         slice(None, 9, 3),
         slice(1, 8, None),
         slice(9, 1, -2)
     ]
     for slc in test_set:
         self.assertEqual(RNA(test_seq)[slc], RNA(test_seq[slc]))
예제 #4
0
 def test_string(self):
     test_set = [
         "AAAAAAAAAA", "UUUUUUUUU", "CCCCCCCCCC", "GGGGGGGGG", "CCACaaCACa",
         "AgCAGcGAcG", "ACUcauCUGAUC", "caucgauc"
     ]
     for string in test_set:
         res = RNA(string)
         self.assertIsInstance(res, RNA)
         self.assertEqual(res._seq, string.upper())
예제 #5
0
 def test_RNA_plus_DNA(self):
     test_set = [("AUGC", "ATGC"), ("A", "GGATGC"), ("CGAUAC", "TGC")]
     for rna_str, dna_str in test_set:
         self.assertRaises(TypeError, lambda x, y: RNA(x) + DNA(y),
                           (rna_str, dna_str))
예제 #6
0
 def test_DNA_plus_RNA(self):
     test_set = [("ATGC", "AUGC"), ("A", "GGAUGC"), ("CGAGAC", "UGC")]
     for dna_str, rna_str in test_set:
         self.assertRaises(TypeError, lambda x, y: DNA(x) + RNA(y),
                           (dna_str, rna_str))
예제 #7
0
 def test_RNA_plus_RNA(self):
     test_set = [("A", "U"), ("ACGA", "A"), ("GGGG", "AGCU"),
                 ("UU", "AGCU")]
     for str1, str2 in test_set:
         self.assertEqual(RNA(str1 + str2), RNA(str1) + RNA(str2))
         self.assertEqual(RNA(str2 + str1), RNA(str2) + RNA(str1))
예제 #8
0
 def test_RNA_equals_DNA(self):
     test_set = [("AUGC", "ATGC"), ("AAAA", "AAAA"), ("AUCGAC", "ATCGAC"),
                 ("CAUC", "ACTC"), ("AUUCG", "TTA"), ("A", "TAA")]
     for str1, str2 in test_set:
         self.assertRaises(TypeError, lambda x, y: RNA(x) == DNA(y),
                           (str1, str2))
예제 #9
0
 def test_DNA_equals_RNA(self):
     test_set = [("ATGC", "AUGC"), ("AAAA", "AAAA"), ("ATCGAC", "ATCGAC"),
                 ("CATC", "ACUC"), ("ATTCG", "UUA"), ("A", "UAA")]
     for str1, str2 in test_set:
         self.assertRaises(TypeError, lambda x, y: DNA(x) == RNA(y),
                           (str1, str2))
예제 #10
0
 def test_RNA_equals_RNA(self):
     test_set = [("AUGC", "AUGC", True), ("AAAA", "AAAA", True),
                 ("AUCGAC", "AUCGAC", True), ("CAUC", "ACUC", False),
                 ("AUUCG", "UUA", False), ("A", "UAA", False)]
     for str1, str2, equals in test_set:
         self.assertEqual(RNA(str1) == RNA(str2), equals)
예제 #11
0
 def test_dna_transcribe(self):
     test_set = [("A", "U"), ("T", "A"), ("ATGCATGC", "UACGUACG")]
     for string, tr_string in test_set:
         self.assertEqual(DNA(string).transcribe(), RNA(tr_string))
예제 #12
0
 def test_rna_iter(self):
     test_set = ["CAGUCGACUGCAUC", "AAAAUUUCGGG", "G"]
     for string in test_set:
         res = [i for i in string]
         self.assertEqual([i for i in RNA(string)], res)
예제 #13
0
 def test_rna_complement(self):
     test_set = [("A", "U"), ("U", "A"), ("G", "C"), ("C", "G"),
                 ("AU", "UA"), ("GC", "CG"), ("AG", "UC"), ("GU", "CA")]
     for string, c_string in test_set:
         res = RNA(string).complement()
         self.assertEqual(RNA(c_string), res)
예제 #14
0
 def test_rna_gc_content(self):
     test_set = [("GCGCGCGC", 1), ("AUAUAUAUA", 0), ("AUGCAUGCAUGC", 0.5),
                 ("AUAGAUACAUAGAUAC", 0.25)]
     for string, gc in test_set:
         res = RNA(string).gc_content()
         self.assertEqual(res, gc)
예제 #15
0
 def test_rna_len(self):
     test_set = [("AGUC", 4), ("A", 1), ("AGUCA", 5)]
     for string, length in test_set:
         self.assertEqual(len(RNA(string)), length)