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): """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')
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_RnaviewParser(self): """RnaviewParser: should work with/without model and/or verification """ rnaview_lines = RNAVIEW_PDB_REAL.split('\n') obs = RnaviewParser(rnaview_lines) self.assertEqual(obs['FN'], 'pdb430d.ent') self.assertEqual(len(obs['UC']), 1) self.assertEqual(len(obs['BP']), 19) self.assertEqual(len(obs['BM']), 0) self.assertEqual(obs['BM'], BaseMultiplets()) self.assertEqual(obs['PC']['Standard'], 7) self.assertEqual(obs['BP'][2].Down.ResName, 'c') self.assertEqual(obs['BP'][6].Edges, 'stacked') self.assertEqual(obs['NP']['NUM_PAIRS'], 11) self.assertEqual(obs['NP']['NUM_BASES'], 29)