How to use the newick.dumps 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_internal_name_removal():
    tree = loads('((B:0.2,(C:0.3,D:0.4)E:0.5)F:0.1)A;')[0]
    tree.remove_internal_names()
    assert dumps(tree) == '((B:0.2,(C:0.3,D:0.4):0.5):0.1);'
github glottobank / python-newick / tests / test_newick.py View on Github external
def test_all_removal():
    tree = loads('((B:0.2,(C:0.3,D:0.4)E:0.5)F:0.1)A;')[0]
    tree.remove_names()
    tree.remove_lengths()
    topology_only = dumps(tree)
    assert topology_only == '((,(,)));'
github glottobank / python-newick / tests / test_newick.py View on Github external
def test_dumps(*trees):
    for ex in [
        '(,,(,));',
        '(A,B,(C,D));',
        '(A,B,(C,D)E)F;',
        '(:0.1,:0.2,(:0.3,:0.4):0.5);',
        '((B:0.2,(C:0.3,D:0.4)E:0.5)F:0.1)A;',
    ]:
        assert ex == dumps(loads(ex)[0])
github glottobank / python-newick / tests / test_newick.py View on Github external
def test_leaf_name_removal():
    tree = loads('((B:0.2,(C:0.3,D:0.4)E:0.5)F:0.1)A;')[0]
    tree.remove_leaf_names()
    assert dumps(tree) == '((:0.2,(:0.3,:0.4)E:0.5)F:0.1)A;'
github glottobank / python-newick / tests / test_newick.py View on Github external
def test_length_removal():
    tree = loads('((B:0.2,(C:0.3,D:0.4)E:0.5)F:0.1)A;')[0]
    tree.remove_lengths()
    assert dumps(tree) == '((B,(C,D)E)F)A;'
github glottobank / python-newick / tests / test_newick.py View on Github external
def test_name_removal():
    tree = loads('((B:0.2,(C:0.3,D:0.4)E:0.5)F:0.1)A;')[0]
    tree.remove_names()
    assert dumps(tree) == '((:0.2,(:0.3,:0.4):0.5):0.1);'
github lmaurits / BEASTling / beastling / util / misc.py View on Github external
#    and will be pruned." % tree_type.capitalize())
    # Get the tree looking nice
    tree.remove_redundant_nodes()
    tree.remove_internal_names()
    if tree_type == "starting":
        tree.resolve_polytomies()
    # Remove lengths for a monophyly tree
    if tree_type == "monophyly":
        for n in tree.walk():
            n._length = None
    # Checks
    if tree_type == "starting":
        assert all(len(n.descendants) in (0, 2) for n in tree.walk())
    assert len(tree.get_leaves()) == len(languages)
    assert all(l.name for l in tree.get_leaves())
    return newick.dumps(tree)

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