Exemple #1
0
def test_iforking_point_upstream():
    leaves = [l for l in ileaf(REF_TREE2)]
    ref_paths = [[1111, 11, 0], [1111, 11, 0], [1111, 11, 0], [11, 0],
                 [1211, 12, 0], [1211, 12, 0], [12, 0]]

    for l, ref in zip(leaves, ref_paths):
        nt.assert_equal([s for s in val_iter(iforking_point(l, iupstream))],
                        ref)
Exemple #2
0
def test_iforking_point_upstream():
    leaves = [l for l in ileaf(REF_TREE2)]
    ref_paths = [
        [1111, 11, 0], [1111, 11, 0], [1111, 11, 0], [11, 0],
        [1211, 12, 0], [1211, 12, 0], [12, 0]
    ]

    for l, ref in zip(leaves, ref_paths):
        nt.assert_equal([s for s in val_iter(iforking_point(l, iupstream))], ref)
Exemple #3
0
def branch_order(tree_section):
    '''Branching order of a tree section

    The branching order is defined as the depth of the tree section.

    Note:
        The first level has branch order 0.
    '''
    node = tree_section[-1]
    bo = sum(1 for _ in tr.iforking_point(node, tr.iupstream))
    return bo - 2 if tr.is_forking_point(node) else bo - 1
Exemple #4
0
def branch_order(tree_section):
    '''Branching order of a tree section

    The branching order is defined as the depth of the tree section.

    Note:
        The first level has branch order 0.
    '''
    node = tree_section[-1]
    bo = sum(1 for _ in tr.iforking_point(node, tr.iupstream))
    return bo - 2 if tr.is_forking_point(node) else bo - 1
Exemple #5
0
def _check_trees(trees):
    for t in trees:
        nt.ok_(len(list(tree.ileaf(t))) == 11)
        nt.ok_(len(list(tree.iforking_point(t))) == 10)
        nt.ok_(len(list(tree.ipreorder(t))) == 211)
        nt.ok_(len(list(tree.ipostorder(t))) == 211)
        nt.ok_(len(list(tree.isegment(t))) == 210)
        leaves = [l for l in tree.ileaf(t)]
        # path length from each leaf to root node.
        branch_order = [21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 111]
        for i, l in enumerate(leaves):
            nt.ok_(len(list(tree.iupstream(l))) == branch_order[i])
Exemple #6
0
def _check_trees(trees):
    for t in trees:
        nt.ok_(len(list(tree.ileaf(t))) == 11)
        nt.ok_(len(list(tree.iforking_point(t))) == 10)
        nt.ok_(len(list(tree.ipreorder(t))) == 211)
        nt.ok_(len(list(tree.ipostorder(t))) == 211)
        nt.ok_(len(list(tree.isegment(t))) == 210)
        leaves = [l for l in tree.ileaf(t)]
        # path length from each leaf to root node.
        branch_order = [21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 111]
        for i, l in enumerate(leaves):
            nt.ok_(len(list(tree.iupstream(l))) == branch_order[i])
Exemple #7
0
def test_valiter_forking_point():
    nt.ok_(list(val_iter(iforking_point(REF_TREE2))) ==
           [0, 11, 1111, 12, 1211])
Exemple #8
0
def test_iforking_point_preorder():
    nt.assert_equal([n.value for n in iforking_point(REF_TREE2, ipostorder)],
                    [1111, 11, 1211, 12, 0])
Exemple #9
0
def test_iforking_point():
    nt.assert_equal([n.value for n in iforking_point(REF_TREE2)],
                    [0, 11, 1111, 12, 1211])
Exemple #10
0
def test_valiter_forking_point():
    nt.ok_(
        list(val_iter(iforking_point(REF_TREE2))) == [0, 11, 1111, 12, 1211])
Exemple #11
0
def test_iforking_point_preorder():
    nt.assert_equal([n.value for n in iforking_point(REF_TREE2, ipostorder)],
                    [1111, 11, 1211, 12, 0])
Exemple #12
0
def test_iforking_point():
    nt.assert_equal([n.value for n in iforking_point(REF_TREE2)],
                    [0, 11, 1111, 12, 1211])