def test_parse_base_multiplets_basic(self): """parse_base_multiplets: basic input""" basic_lines =\ ['235_237_254_| [20 3] 0: 246 G + 0: 248 A + 0: 265 U',\ '273_274_356_| [21 3] 0: 284 C + 0: 285 A + 0: 367 G'] bm1 = BaseMultiplet([Base('0','246','G','235'),\ Base('0','248','A','237'), Base('0','265','U','254')]) bm2 = BaseMultiplet([Base('0','284','C','273'),\ Base('0','285','A','274'), Base('0','367','G','356')]) bms = BaseMultiplets([bm1, bm2]) obs = parse_base_multiplets(basic_lines) for o, e in zip(obs, bms): for base_x, base_y in zip(o, e): self.assertEqual(base_x, base_y) self.assertEqual(len(obs), 2) self.assertEqual(len(obs[0]), 3) basic_lines =\ ['235_237_254_| [20 3] 0: 246 G + 0: 248 A + 0: 265 I',\ '273_274_356_| [21 3] 0: 284 P + 0: 285 a + 0: 367 G'] bm1 = BaseMultiplet([Base('0','246','G','235'),\ Base('0','248','A','237'), Base('0','265','I','254')]) bm2 = BaseMultiplet([Base('0','284','P','273'),\ Base('0','285','a','274'), Base('0','367','G','356')]) bms = BaseMultiplets([bm1, bm2]) obs = parse_base_multiplets(basic_lines) for o, e in zip(obs, bms): for base_x, base_y in zip(o, e): self.assertEqual(base_x, base_y) self.assertEqual(len(obs), 2) self.assertEqual(len(obs[0]), 3)
def test_init(self): """BaseMultiplet __init__: should work as expected""" b1 = Base('A', '30', 'A') b2 = Base('A', '35', 'G') b3 = Base('A', '360', 'U') bm = BaseMultiplet([b1, b2, b3]) self.assertTrue(bm[0] is b1) self.assertTrue(bm[2] is b3) #should work from tuple also bm = BaseMultiplet((b1, b2, b3)) self.assertTrue(bm[0] is b1) self.assertTrue(bm[2] is b3)
def test_str(self): """BaseMultiplets __str__: should give expected string""" b1 = Base('A', '30', 'A') b2 = Base('A', '35', 'G') b3 = Base('A', '360', 'U') bm1 = BaseMultiplet([b1, b2, b3]) b4 = Base('B', '12', 'C') b5 = Base('B', '42', 'U') b6 = Base('C', '2', 'A') bm2 = BaseMultiplet([b4, b5, b6]) bms = BaseMultiplets([bm1, bm2]) exp_lines = [\ "A 30 A -- A 35 G -- A 360 U;",\ "B 12 C -- B 42 U -- C 2 A;"] self.assertEqual(str(bms), '\n'.join(exp_lines))
def test_str(self): """BaseMultiplet __str__: should give expected string""" b1 = Base('A', '30', 'A') b2 = Base('A', '35', 'G') b3 = Base('A', '360', 'U') bm = BaseMultiplet([b1, b2, b3]) exp = "A 30 A -- A 35 G -- A 360 U;" self.assertEqual(str(bm), exp)
def test_init(self): """BaseMultiplets __init__: from list and tuple""" b1 = Base('A', '30', 'A') b2 = Base('A', '35', 'G') b3 = Base('A', '360', 'U') bm1 = BaseMultiplet([b1, b2, b3]) b4 = Base('B', '12', 'C') b5 = Base('B', '42', 'U') b6 = Base('C', '2', 'A') bm2 = BaseMultiplet([b4, b5, b6]) bms = BaseMultiplets([bm1, bm2]) self.assertTrue(bms[0] is bm1) self.assertTrue(bms[1] is bm2) self.assertEqual(bms[1][2].ResId, '2') #should work from tuple also bms = BaseMultiplets((bm1, bm2)) self.assertTrue(bms[0] is bm1) self.assertTrue(bms[1] is bm2) self.assertEqual(bms[1][2].ResId, '2')