def test_numTopologyHistories(self): """numTopologyHistories""" tree = treelib.parseNewick("((a,b),(c,d));") ctree = spidir.tree2ctree(tree) self.assertEqual(spidir.numTopologyHistories(ctree), 2) self.assertEqual(numTopologyHistories(tree.root), 2) spidir.deleteTree(ctree) tree = treelib.parseNewick("(((a,b),(c,d)),(e,f));") ctree = spidir.tree2ctree(tree) self.assertEqual(spidir.numTopologyHistories(ctree), 8) self.assertEqual(numTopologyHistories(tree.root), 8) spidir.deleteTree(ctree) tree = treelib.parseNewick("((((a,b),(c,d)),(e,f)),g);") ctree = spidir.tree2ctree(tree) self.assertEqual(spidir.numTopologyHistories(ctree), 8) self.assertEqual(numTopologyHistories(tree.root), 8) spidir.deleteTree(ctree) tree = treelib.parseNewick("((((a,b),(c,d)),(e,f)),((g,h),i));") ctree = spidir.tree2ctree(tree) self.assertEqual(spidir.numTopologyHistories(ctree), 7 * 6 / 2 * 8) self.assertEqual(numTopologyHistories(tree.root), 7 * 6 / 2 * 8) spidir.deleteTree(ctree)
def test_numTopologyHistories(self): """numTopologyHistories""" tree = treelib.parseNewick("((a,b),(c,d));") ctree = spidir.tree2ctree(tree) self.assertEqual(spidir.numTopologyHistories(ctree), 2) self.assertEqual(numTopologyHistories(tree.root), 2) spidir.deleteTree(ctree) tree = treelib.parseNewick("(((a,b),(c,d)),(e,f));") ctree = spidir.tree2ctree(tree) self.assertEqual(spidir.numTopologyHistories(ctree), 8) self.assertEqual(numTopologyHistories(tree.root), 8) spidir.deleteTree(ctree) tree = treelib.parseNewick("((((a,b),(c,d)),(e,f)),g);") ctree = spidir.tree2ctree(tree) self.assertEqual(spidir.numTopologyHistories(ctree), 8) self.assertEqual(numTopologyHistories(tree.root), 8) spidir.deleteTree(ctree) tree = treelib.parseNewick("((((a,b),(c,d)),(e,f)),((g,h),i));") ctree = spidir.tree2ctree(tree) self.assertEqual(spidir.numTopologyHistories(ctree), 7*6/2*8) self.assertEqual(numTopologyHistories(tree.root), 7*6/2*8) spidir.deleteTree(ctree)
def assert_doom_table(self, tree, l, u, maxdoom): ctree = spidir.tree2ctree(tree) ptree, nodes, nodelookup = spidir.make_ptree(tree) treelib.draw_tree(tree, scale=10) doomtable = [0] * len(tree.nodes) doomtable = spidir.c_list(ctypes.c_double, doomtable) spidir.calcDoomTable(ctree, l, u, maxdoom, doomtable) spidir.deleteTree(ctree) doomtable2 = calc_doom_table(tree, l, u, maxdoom) print list(doomtable) print doomtable2 for i, j in zip(doomtable, doomtable2): fequal(i, j)
def test_make_trees(self): """makeTree""" tree = treelib.parse_newick("((a,b),(c,d));") ctree = spidir.tree2ctree(tree) spidir.deleteTree(ctree) ctree = spidir.ptree2ctree([3,3,4,4,-1]) spidir.deleteTree(ctree) ctree = spidir.makeTree(5, spidir.c_list(spidir.c_int, [3,3,4,4,-1])) spidir.deleteTree(ctree)
def test_make_trees(self): """makeTree""" tree = treelib.parse_newick("((a,b),(c,d));") ctree = spidir.tree2ctree(tree) spidir.deleteTree(ctree) ctree = spidir.ptree2ctree([3, 3, 4, 4, -1]) spidir.deleteTree(ctree) ctree = spidir.makeTree(5, spidir.c_list(spidir.c_int, [3, 3, 4, 4, -1])) spidir.deleteTree(ctree)