Пример #1
0
 def test_is_tertiary_base_base(self):
     """is_tertiary_base_base: checks annotation, not base identity"""
     b1, b2 = Base('A', '30', 'C'), Base('A', '40', 'U')
     bp = BasePair(b1, b2, Saenger='!1H(b_b)')
     self.assertEqual(is_tertiary_base_base(bp), True)
     bp = BasePair(b1, b2, Edges='H/?', Saenger='!(s_s)')
     self.assertEqual(is_tertiary_base_base(bp), False)
Пример #2
0
 def test_is_not_stacked(self):
     """is_not_stacked: opposite of is_stacked"""
     b1, b2 = Base('A', '30', 'C'), Base('A', '40', 'A')
     bp = BasePair(b1, b2, Edges='stacked')
     self.assertEqual(is_not_stacked(bp), False)
     bp = BasePair(b1, b2, Edges='H/?')
     self.assertEqual(is_not_stacked(bp), True)
Пример #3
0
 def test_is_stacked(self):
     """is_stacked: checks annotation, not base identity"""
     b1, b2 = Base('A', '30', 'C'), Base('A', '40', 'A')
     bp = BasePair(b1, b2, Edges='stacked')
     self.assertEqual(is_stacked(bp), True)
     bp = BasePair(b1, b2, Edges='H/?')
     self.assertEqual(is_stacked(bp), False)
Пример #4
0
 def test_is_not_stacked_or_tertiary(self):
     """is_not_stacked_or_tertiary: checks annotation, not base identity"""
     b1, b2 = Base('A', '30', 'C'), Base('A', '40', 'U')
     bp = BasePair(b1, b2, Saenger='!1H(b_b)')
     self.assertEqual(is_not_stacked_or_tertiary(bp), False)
     bp = BasePair(b1, b2, Edges='stacked')
     self.assertEqual(is_not_stacked_or_tertiary(bp), False)
     bp = BasePair(b1, b2, Edges='W/W', Saenger='XX')
     self.assertEqual(is_not_stacked_or_tertiary(bp), True)
Пример #5
0
 def test_is_not_canocical(self):
     """is_not_canonical: opposite of is_canonical"""
     b1, b2 = Base('A', '30', 'C'), Base('A', '40', 'G')
     bp = BasePair(b1, b2, Edges='+/+')
     self.assertEqual(is_not_canonical(bp), False)
     bp = BasePair(b1, b2, Edges='-/-')
     self.assertEqual(is_not_canonical(bp), False)
     bp = BasePair(b1, b2, Edges='W/W')
     self.assertEqual(is_not_canonical(bp), True)
     bp = BasePair(b1, b2, Edges='W/W', Orientation='cis', Saenger='XXVIII')
     self.assertEqual(is_not_canonical(bp), False)
Пример #6
0
 def test_is_canocical(self):
     """is_canonical: work on annotation, not base identity"""
     b1, b2 = Base('A', '30', 'C'), Base('A', '40', 'G')
     bp = BasePair(b1, b2, Edges='+/+')
     self.assertEqual(is_canonical(bp), True)
     bp = BasePair(b1, b2, Edges='-/-')
     self.assertEqual(is_canonical(bp), True)
     bp = BasePair(b1, b2, Edges='W/W')
     self.assertEqual(is_canonical(bp), False)
     bp = BasePair(b1, b2, Edges='W/W', Orientation='cis', Saenger='XXVIII')
     self.assertEqual(is_canonical(bp), True)
Пример #7
0
 def test_isWC(self):
     """BasePair isWC: should return True for GC or AU pair"""
     bp = BasePair(Base('A','30','G'), Base('A','36','C'))
     self.assertEqual(bp.isWC(), True)
     bp = BasePair(Base('A','30','g'), Base('A','36','C'))
     self.assertEqual(bp.isWC(), True)
     bp = BasePair(Base('A','30','C'), Base('A','36','G'))
     self.assertEqual(bp.isWC(), True)
     bp = BasePair(Base('A','30','U'), Base('A','36','a'))
     self.assertEqual(bp.isWC(), True)
     bp = BasePair(Base('A','30','G'), Base('A','36','U'))
     self.assertEqual(bp.isWC(), False)
Пример #8
0
 def test_isWC(self):
     """BasePair isWC: should return True for GC or AU pair"""
     bp = BasePair(Base("A", "30", "G"), Base("A", "36", "C"))
     self.assertEqual(bp.isWC(), True)
     bp = BasePair(Base("A", "30", "g"), Base("A", "36", "C"))
     self.assertEqual(bp.isWC(), True)
     bp = BasePair(Base("A", "30", "C"), Base("A", "36", "G"))
     self.assertEqual(bp.isWC(), True)
     bp = BasePair(Base("A", "30", "U"), Base("A", "36", "a"))
     self.assertEqual(bp.isWC(), True)
     bp = BasePair(Base("A", "30", "G"), Base("A", "36", "U"))
     self.assertEqual(bp.isWC(), False)
Пример #9
0
 def test_str(self):
     """BasePairs __str__: should produce expected string"""
     b1 = BasePair(Base('A', '30', 'G'), Base('A', '36', 'C'), Saenger='XX')
     b2 = BasePair(Base('A','31','A'), Base('A','35','U'),\
         Orientation='cis',Edges='W/W')
     bps = BasePairs([b1, b2])
     exp_lines = [
     "===================================================================",\
     "Bases: Up -- Down; Annotation: Edges -- Orient. -- Conf. -- Saenger",\
     "===================================================================",\
     "Bases: A 30 G -- A 36 C; Annotation: None -- None -- None -- XX;",\
     "Bases: A 31 A -- A 35 U; Annotation: W/W -- cis -- None -- None;"]
     self.assertEqual(str(bps), '\n'.join(exp_lines))
Пример #10
0
 def test_isWobble(self):
     """BasePair isWobble: should return True for GU pair"""
     bp = BasePair(Base("A", "30", "G"), Base("A", "36", "U"))
     self.assertEqual(bp.isWobble(), True)
     bp = BasePair(Base("A", "30", "g"), Base("A", "36", "U"))
     self.assertEqual(bp.isWobble(), True)
     bp = BasePair(Base("A", "30", "u"), Base("A", "36", "g"))
     self.assertEqual(bp.isWobble(), True)
     bp = BasePair(Base("A", "30", "A"), Base("A", "36", "U"))
     self.assertEqual(bp.isWobble(), False)
Пример #11
0
 def test_isWobble(self):
     """BasePair isWobble: should return True for GU pair"""
     bp = BasePair(Base('A','30','G'), Base('A','36','U'))
     self.assertEqual(bp.isWobble(), True)
     bp = BasePair(Base('A','30','g'), Base('A','36','U'))
     self.assertEqual(bp.isWobble(), True)
     bp = BasePair(Base('A','30','u'), Base('A','36','g'))
     self.assertEqual(bp.isWobble(), True)
     bp = BasePair(Base('A','30','A'), Base('A','36','U'))
     self.assertEqual(bp.isWobble(), False)
Пример #12
0
 def test_ne(self):
     "BasePair !=: should function as expected"
     # identical
     up = Base('A', '30', 'G')
     down = Base('A', '36', 'C')
     bp = BasePair(up, down, Edges='H/W', Saenger='XI',\
         Orientation='cis', Conformation=None)
     self.assertEqual(bp != self.bp, False)
     # diff up base
     diff_up = Base('C', '12', 'A')
     bp = BasePair(diff_up, down, Edges='H/W', Saenger='XI',\
         Orientation='cis', Conformation=None)
     self.assertEqual(bp != self.bp, True)
     # diff down base
     diff_down = Base('D', '13', 'U')
     bp = BasePair(up, diff_down, Edges='H/W', Saenger='XI',\
         Orientation='cis', Conformation=None)
     self.assertEqual(bp != self.bp, True)
     # diff edges
     bp = BasePair(up, down, Edges='W/W', Saenger='XI',\
         Orientation='cis', Conformation=None)
     self.assertEqual(bp != self.bp, True)
     # diff orientation
     bp = BasePair(up, down, Edges='H/W', Saenger='XI',\
         Orientation='tran', Conformation=None)
     self.assertEqual(bp != self.bp, True)
     # diff conformation
     bp = BasePair(up, down, Edges='H/W', Saenger='XI',\
         Orientation='cis', Conformation='syn')
     self.assertEqual(bp != self.bp, True)
     # diff saenger
     bp = BasePair(up, down, Edges='H/W', Saenger='XIX',\
         Orientation='cis', Conformation=None)
     self.assertEqual(bp != self.bp, True)
Пример #13
0
    def test_in_chain(self):
        b1, b2 = Base('A', '30', 'C'), Base('A', '40', 'G')
        bp1 = BasePair(b1, b2)
        self.assertEqual(in_chain("A")(bp1), True)
        self.assertEqual(in_chain(["A", 'B'])(bp1), True)
        self.assertEqual(in_chain("B")(bp1), False)

        b3, b4 = Base('A', '30', 'C'), Base('B', '40', 'G')
        bp2 = BasePair(b3, b4)
        self.assertEqual(in_chain("A")(bp2), False)
        self.assertEqual(in_chain(["A", 'B'])(bp2), True)
        self.assertEqual(in_chain("AB")(bp2), True)
        self.assertEqual(in_chain("AC")(bp2), False)

        b5, b6 = Base('A', '30', 'C'), Base('C', '40', 'G')
        bp3 = BasePair(b5, b6)
        self.assertEqual(in_chain("A")(bp3), False)
        self.assertEqual(in_chain("C")(bp3), False)
        self.assertEqual(in_chain(["A", 'B'])(bp3), False)
        self.assertEqual(in_chain("AC")(bp3), True)
Пример #14
0
    def test_parse_base_pairs_basic(self):
        """parse_base_pairs: basic input"""
        basic_lines =\
            ['25_437, 0:    34 C-G   448 0: +/+ cis         XIX',\
            '26_436, 0:    35 U-A   447 0: -/- cis         XX']
        bp1 = BasePair(Up=Base('0','34','C','25'),\
            Down=Base('0','448','G','437'),\
            Edges='+/+', Orientation='cis',Conformation=None,Saenger='XIX')
        bp2 = BasePair(Up=Base('0','35','U','26'),\
            Down=Base('0','447','A','436'),\
            Edges='-/-', Orientation='cis',Conformation=None,Saenger='XX')
        bps = BasePairs([bp1, bp2])
        obs = parse_base_pairs(basic_lines)
        for o, e in zip(obs, [bp1, bp2]):
            self.assertEqual(o, e)
        self.assertEqual(len(obs), 2)

        basic_lines =\
            ['25_437, 0:    34 c-P   448 0: +/+ cis         XIX',\
            '26_436, 0:    35 U-X   447 0: -/- cis         XX']
        self.assertRaises(RnaViewParseError, parse_base_pairs, basic_lines)

        basic_lines =\
            ['25_437, 0:    34 c-P   448 0: +/+ cis         XIX',\
            '26_436, 0:    35 I-A   447 0: -/- cis         XX']
        bp1 = BasePair(Up=Base('0','34','c','25'),\
            Down=Base('0','448','P','437'),\
            Edges='+/+', Orientation='cis',Conformation=None,Saenger='XIX')
        bp2 = BasePair(Up=Base('0','35','I','26'),\
            Down=Base('0','447','A','436'),\
            Edges='-/-', Orientation='cis',Conformation=None,Saenger='XX')
        bps = BasePairs([bp1, bp2])
        obs = parse_base_pairs(basic_lines)
        for o, e in zip(obs, [bp1, bp2]):
            self.assertEqual(o, e)
        self.assertEqual(len(obs), 2)


        lines = ['1_2,  :     6 G-G     7  :      stacked',\
            '1_16,  :     6 G-C    35  : +/+ cis         XIX']
        bp1 = BasePair(Up=Base(' ','6','G','1'),\
            Down=Base(' ','7','G','2'), Edges='stacked')
        bp2 = BasePair(Up=Base(' ','6','G','1'),\
            Down=Base(' ','35','C','16'),\
            Edges='+/+', Orientation='cis',Conformation=None,Saenger='XIX')
        obs = parse_base_pairs(lines)
        for o, e in zip(obs, [bp1, bp2]):
            self.assertEqual(o, e)
        self.assertEqual(len(obs), 2)
Пример #15
0
 def test_isWobble(self):
     """BasePair isWobble: should return True for GU pair"""
     bp = BasePair(Base('A', '30', 'G'), Base('A', '36', 'U'))
     self.assertEqual(bp.isWobble(), True)
     bp = BasePair(Base('A', '30', 'g'), Base('A', '36', 'U'))
     self.assertEqual(bp.isWobble(), True)
     bp = BasePair(Base('A', '30', 'u'), Base('A', '36', 'g'))
     self.assertEqual(bp.isWobble(), True)
     bp = BasePair(Base('A', '30', 'A'), Base('A', '36', 'U'))
     self.assertEqual(bp.isWobble(), False)
Пример #16
0
    def setUp(self):
        """setUp method for all BasePairs tests"""
        self.a1 = BasePair(Base('A', '30', 'G'),
                           Base('A', '36', 'C'),
                           Saenger='XX')
        self.a2 = BasePair(Base('A', '31', 'A'),
                           Base('A', '35', 'U'),
                           Saenger='XX')
        self.a3 = BasePair(Base('A', '40', 'G'),
                           Base('A', '60', 'U'),
                           Saenger='V')
        self.a4 = BasePair(Base('A','41','A'), Base('A','58','U'),\
            Saenger=None)
        self.ab1 = BasePair(Base('A', '41', 'A'), Base('B', '58', 'U'))
        self.ac1 = BasePair(Base('A', '10', 'C'), Base('C', '3', 'G'))
        self.bc1 = BasePair(Base('B', '41', 'A'), Base('C', '1', 'U'))
        self.bn1 = BasePair(Base('B', '41', 'A'), Base(None, '1', 'U'))
        self.cd1 = BasePair(Base('C', '41', 'A'), Base('D', '1', 'U'))

        self.bp1 = BasePair(Base('A', '34', 'U'), Base('A', '40', 'A'))
        self.bp2 = BasePair(Base('A', '35', 'C'), Base('A', '39', 'G'))
        self.bp3 = BasePair(Base('B', '32', 'G'), Base('B', '38', 'U'))
        self.bp4 = BasePair(Base('B', '33', 'G'), Base('B', '37', 'C'))
        self.bp5 = BasePair(Base('A', '31', 'C'), Base('B', '41', 'G'))
        self.bp6 = BasePair(Base('A', '32', 'U'), Base('B', '40', 'A'))
        self.bp7 = BasePair(Base('A', '37', 'U'), Base('B', '35', 'A'))

        self.pairs = BasePairs([self.bp1, self.bp2, self.bp3, self.bp4,\
            self.bp5, self.bp6, self.bp7])
Пример #17
0
 def setUp(self):
     """setUp method for all tests in BasePairTests"""
     self.b1 = Base('A', '30', 'G')
     self.b2 = Base('A', '36', 'C')
     self.bp = BasePair(self.b1, self.b2, Edges='H/W', Saenger='XI',\
         Orientation='cis', Conformation=None)
Пример #18
0
    def test_hasConflicts(self):
        """BasePairs hadConflicts: handle chains and residue IDs"""
        # no conflict
        b1 = BasePair(Base('A', '30', 'G'), Base('A', '36', 'C'), Saenger='XX')
        b2 = BasePair(Base('A','31','A'), Base('A','35','U'),\
            Orientation='cis',Edges='W/W')
        b3 = BasePair(Base('A', '15', 'G'), Base('A', '42', 'C'))
        bps = BasePairs([b1, b2, b3])
        self.assertEqual(bps.hasConflicts(), False)
        self.assertEqual(bps.hasConflicts(return_conflict=True), (False, None))

        # conflict within chain
        b1 = BasePair(Base('A', '30', 'G'), Base('A', '36', 'C'), Saenger='XX')
        b2 = BasePair(Base('A','31','A'), Base('A','35','U'),\
            Orientation='cis',Edges='W/W')
        b3 = BasePair(Base('A', '30', 'G'), Base('A', '42', 'C'))
        bps = BasePairs([b1, b2, b3])
        self.assertEqual(bps.hasConflicts(), True)

        # conflict within chain -- return conflict
        b1 = BasePair(Base('A', '30', 'G'), Base('A', '36', 'C'), Saenger='XX')
        b2 = BasePair(Base('A','31','A'), Base('A','35','U'),\
            Orientation='cis',Edges='W/W')
        b3 = BasePair(Base('A', '30', 'G'), Base('A', '42', 'C'))
        bps = BasePairs([b1, b2, b3])
        self.assertEqual(bps.hasConflicts(return_conflict=True),\
            (True, "A 30 G"))

        # no conflict, same residue ID, different chain
        b1 = BasePair(Base('A', '30', 'G'), Base('A', '36', 'C'), Saenger='XX')
        b2 = BasePair(Base('A','31','A'), Base('A','35','U'),\
            Orientation='cis',Edges='W/W')
        b3 = BasePair(Base('C', '30', 'G'), Base('A', '42', 'C'))
        bps = BasePairs([b1, b2, b3])
        self.assertEqual(bps.hasConflicts(), False)
Пример #19
0
 def test_isWC(self):
     """BasePair isWC: should return True for GC or AU pair"""
     bp = BasePair(Base('A', '30', 'G'), Base('A', '36', 'C'))
     self.assertEqual(bp.isWC(), True)
     bp = BasePair(Base('A', '30', 'g'), Base('A', '36', 'C'))
     self.assertEqual(bp.isWC(), True)
     bp = BasePair(Base('A', '30', 'C'), Base('A', '36', 'G'))
     self.assertEqual(bp.isWC(), True)
     bp = BasePair(Base('A', '30', 'U'), Base('A', '36', 'a'))
     self.assertEqual(bp.isWC(), True)
     bp = BasePair(Base('A', '30', 'G'), Base('A', '36', 'U'))
     self.assertEqual(bp.isWC(), False)