def test_missing_tip_name(self): """DndParser should produce the correct tree when missing a name""" obs = DndParser(missing_tip_name) exp = PhyloNode() exp.append(PhyloNode()) exp.append(PhyloNode()) exp.children[0].append(PhyloNode(name="a")) exp.children[0].append(PhyloNode(name="b")) exp.children[1].append(PhyloNode(name="c")) exp.children[1].append(PhyloNode()) self.assertEqual(str(obs), str(exp))
def test_nonames(self): """DndParser should produce the correct tree when there are no names""" obs = DndParser(no_names) exp = PhyloNode() exp.append(PhyloNode()) exp.append(PhyloNode()) exp.children[0].append(PhyloNode()) exp.children[0].append(PhyloNode()) exp.children[1].append(PhyloNode()) exp.children[1].append(PhyloNode()) self.assertEqual(str(obs), str(exp))
def test_gops(self): """Basic PhyloNode operations should work as expected""" p = PhyloNode() self.assertEqual(str(p), ";") p.name = "abc" self.assertEqual(str(p), "abc;") p.length = 3 self.assertEqual(str(p), "abc:3;") # don't suppress branch from root q = PhyloNode() p.append(q) self.assertEqual(str(p), "()abc:3;") r = PhyloNode() q.append(r) self.assertEqual(str(p), "(())abc:3;") r.name = "xyz" self.assertEqual(str(p), "((xyz))abc:3;") q.length = 2 self.assertEqual(str(p), "((xyz):2)abc:3;")
def test_minimal(self): """DndParser should produce the correct minimal tree""" obs = DndParser(minimal) exp = PhyloNode() exp.append(PhyloNode()) self.assertEqual(str(obs), str(exp))