def test_setup_master_tree_missingtips(self): """tests setup_master_tree""" master_tree = parse_newick('((a:2,b:3):2,(c:1,d:2)foo:7);') t1 = parse_newick('((a:6,b:8.2):2,(c:1,d:2):7);') # same structure t2 = parse_newick('((a:2,c:33):2,d:7);') # where's b? support_tree_tipnames = ['a', 'c', 'd'] exp = "((c:1.0,d:2.0)foo:7.0,a:4.0)node0;" new_master = tc.setup_master_tree(master_tree, [t1, t2]) self.assertEqual(new_master.getNewick(with_distances=True), exp) desc_tips_root = frozenset(['a', 'c', 'd']) desc_tips_c1 = frozenset(['a']) desc_tips_c0 = frozenset(['c', 'd']) desc_tips_c0c0 = frozenset(['c']) desc_tips_c0c1 = frozenset(['d']) self.assertEqual(frozenset(new_master.getTipNames()), desc_tips_root) self.assertEqual( frozenset(new_master.Children[0].getTipNames()), desc_tips_c0) self.assertEqual( frozenset(new_master.Children[1].getTipNames()), desc_tips_c1) c0 = new_master.Children[0] self.assertEqual( frozenset(c0.Children[0].getTipNames()), desc_tips_c0c0) self.assertEqual( frozenset(c0.Children[1].getTipNames()), desc_tips_c0c1)
def test_setup_master_tree_alltips(self): """tests setup_master_tree""" master_tree = parse_newick('((a:2,b:3):2,(c:1,d:2)foo:7);') t1 = parse_newick('((a:6,b:8.2):2,(c:1,d:2):7);') # same structure t2 = parse_newick('((a:2,b:3,c:33):2,d:7);') # abc are siblings support_tree_tipnames = ['a','b','c','d'] exp = "((a:2.0,b:3.0)node1:2.0,(c:1.0,d:2.0)foo:7.0)node0;" new_master = tc.setup_master_tree(master_tree, [t1,t2]) self.assertEqual(new_master.getNewick(with_distances=True),exp) desc_tips_root = frozenset(['a','b','c','d']) desc_tips_c0 = frozenset(['a','b']) desc_tips_c1 = frozenset(['c','d']) desc_tips_c0c0 = frozenset(['a']) desc_tips_c0c1 = frozenset(['b']) desc_tips_c1c0 = frozenset(['c']) desc_tips_c1c1 = frozenset(['d']) self.assertEqual(frozenset(new_master.getTipNames()), desc_tips_root) self.assertEqual(frozenset(new_master.Children[0].getTipNames()), desc_tips_c0) self.assertEqual(frozenset(new_master.Children[1].getTipNames()), desc_tips_c1) c0 = master_tree.Children[0] c1 = master_tree.Children[1] self.assertEqual(frozenset(c0.Children[0].getTipNames()), desc_tips_c0c0) self.assertEqual(frozenset(c0.Children[1].getTipNames()), desc_tips_c0c1) self.assertEqual(frozenset(c1.Children[0].getTipNames()), desc_tips_c1c0) self.assertEqual(frozenset(c1.Children[1].getTipNames()), desc_tips_c1c1)
def test_setup_master_tree_alltips(self): """tests setup_master_tree""" master_tree = parse_newick("((a:2,b:3):2,(c:1,d:2)foo:7);") t1 = parse_newick("((a:6,b:8.2):2,(c:1,d:2):7);") # same structure t2 = parse_newick("((a:2,b:3,c:33):2,d:7);") # abc are siblings support_tree_tipnames = ["a", "b", "c", "d"] exp = "((a:2.0,b:3.0)node1:2.0,(c:1.0,d:2.0)foo:7.0)node0;" new_master = tc.setup_master_tree(master_tree, [t1, t2]) self.assertEqual(new_master.getNewick(with_distances=True), exp) desc_tips_root = frozenset(["a", "b", "c", "d"]) desc_tips_c0 = frozenset(["a", "b"]) desc_tips_c1 = frozenset(["c", "d"]) desc_tips_c0c0 = frozenset(["a"]) desc_tips_c0c1 = frozenset(["b"]) desc_tips_c1c0 = frozenset(["c"]) desc_tips_c1c1 = frozenset(["d"]) self.assertEqual(frozenset(new_master.getTipNames()), desc_tips_root) self.assertEqual(frozenset(new_master.Children[0].getTipNames()), desc_tips_c0) self.assertEqual(frozenset(new_master.Children[1].getTipNames()), desc_tips_c1) c0 = master_tree.Children[0] c1 = master_tree.Children[1] self.assertEqual(frozenset(c0.Children[0].getTipNames()), desc_tips_c0c0) self.assertEqual(frozenset(c0.Children[1].getTipNames()), desc_tips_c0c1) self.assertEqual(frozenset(c1.Children[0].getTipNames()), desc_tips_c1c0) self.assertEqual(frozenset(c1.Children[1].getTipNames()), desc_tips_c1c1)