def test_missing_tip_name(self): """DndParser should produce the correct tree when missing a name""" obs = TreeNode.from_newick(missing_tip_name) exp = TreeNode() exp.append(TreeNode()) exp.append(TreeNode()) exp.children[0].append(TreeNode(name='a')) exp.children[0].append(TreeNode(name='b')) exp.children[1].append(TreeNode(name='c')) exp.children[1].append(TreeNode()) self.assertEqual(str(obs), str(exp))
def test_nonames(self): """DndParser should produce the correct tree when there are no names""" obs = TreeNode.from_newick(no_names) exp = TreeNode() exp.append(TreeNode()) exp.append(TreeNode()) exp.children[0].append(TreeNode()) exp.children[0].append(TreeNode()) exp.children[1].append(TreeNode()) exp.children[1].append(TreeNode()) self.assertEqual(str(obs), str(exp))
def test_missing_tip_name(self): """DndParser should produce the correct tree when missing a name""" obs = TreeNode.from_newick(missing_tip_name) exp = TreeNode() exp.append(TreeNode()) exp.append(TreeNode()) exp.children[0].append(TreeNode(name='a')) exp.children[0].append(TreeNode(name='b')) exp.children[1].append(TreeNode(name='c')) exp.children[1].append(TreeNode()) self.assertEqual(str(obs), str(exp))
def test_nonames(self): """DndParser should produce the correct tree when there are no names""" obs = TreeNode.from_newick(no_names) exp = TreeNode() exp.append(TreeNode()) exp.append(TreeNode()) exp.children[0].append(TreeNode()) exp.children[0].append(TreeNode()) exp.children[1].append(TreeNode()) exp.children[1].append(TreeNode()) self.assertEqual(str(obs), str(exp))
def test_gops(self): """Basic TreeNode operations should work as expected""" p = TreeNode() 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 = TreeNode() p.append(q) self.assertEqual(str(p), '()abc:3;') r = TreeNode() 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_gops(self): """Basic TreeNode operations should work as expected""" p = TreeNode() 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 = TreeNode() p.append(q) self.assertEqual(str(p), '()abc:3;') r = TreeNode() 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 = TreeNode.from_newick(minimal) exp = TreeNode() exp.append(TreeNode()) self.assertEqual(str(obs), str(exp))
def test_minimal(self): """DndParser should produce the correct minimal tree""" obs = TreeNode.from_newick(minimal) exp = TreeNode() exp.append(TreeNode()) self.assertEqual(str(obs), str(exp))