How to use the newick.Node function in newick

To help you get started, we’ve selected a few newick examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glottobank / python-newick / tests / test_newick.py View on Github external
def test_Node():
    with pytest.raises(ValueError):
        Node(name='A)')

    root = loads('(A,B,(C,D)E)F;')[0]
    assert [n.name for n in root.walk()] == ['F', 'A', 'B', 'E', 'C', 'D']
    assert [n.name for n in root.walk() if n.is_leaf] == ['A', 'B', 'C', 'D']
    assert [n.name for n in root.walk(mode='postorder')] == ['A', 'B', 'C', 'D', 'E', 'F']
    assert root.ancestor is None
    assert root.descendants[0].ancestor == root
    root = loads('(((a,b),(c,d)),e);')[0]
    assert [n.ancestor.newick for n in root.walk() if n.ancestor] == \
        [
            '(((a,b),(c,d)),e)',
            '((a,b),(c,d))',
            '(a,b)',
            '(a,b)',
            '((a,b),(c,d))',
            '(c,d)',
github glottobank / python-newick / tests / test_newick.py View on Github external
def setUp(self):
        self.test_obj = Node("A", "1.0")
        self.test_descendant = Node("D", "2.0")
        self.lengths = ["2.0", "3.0", "4.0"]
github glottobank / python-newick / tests / test_newick.py View on Github external
def test_node_parameters_changeability(self):
        test_obj = Node(name="A")
        self.assertEqual("A", test_obj.name)
        test_obj.name = "B"
        self.assertEqual("B", test_obj.name)
github glottobank / python-newick / tests / test_newick.py View on Github external
def test_node_newick_representation_without_length(self):
        test_obj = Node(name="A")
        self.assertEqual("A", test_obj.newick)
github glottobank / python-newick / tests / test_newick.py View on Github external
def test_repr():
    n = Node(name="A")
    assert repr(n) == 'Node("A")'
github glottobank / python-newick / tests / test_newick.py View on Github external
def clone_node(n):
        c = Node(name=n.name)
        for nn in n.descendants:
            c.add_descendant(clone_node(nn))
        return c
github glottobank / python-newick / tests / test_newick.py View on Github external
def setUp(self):
        self.test_obj = Node("A", "1.0")
        self.test_descendant = Node("D", "2.0")
        self.lengths = ["2.0", "3.0", "4.0"]
github glottobank / python-newick / tests / test_newick.py View on Github external
def test_node_newick_representation_with_length(self):
        test_obj = Node(name="A", length="3")
        self.assertEqual("A:3", test_obj.newick)

newick

A python module to read and write the Newick format

Apache-2.0
Latest version published 1 year ago

Package Health Score

53 / 100
Full package analysis

Similar packages