Пример #1
0
def test_segment_path_length():
    leaves = [l for l in tr.ileaf(NEURON_TREE)]
    for l in leaves:
        nt.ok_(mtr.path_length(l) == 9)

    leaves = [l for l in tr.ileaf(SIMPLE_TREE)]
    for l in leaves:
        nt.ok_(mtr.path_length(l) == 8)
Пример #2
0
def compare_trees(tree1, tree2):
    '''
    Comparison between all the nodes and their respective radii between two trees.
    Ids are do not have to be identical between the trees, and swapping is allowed

    Returns:

        False if the trees are not identical. True otherwise.
    '''
    leaves1 = list(tr.ileaf(tree1))
    leaves2 = list(tr.ileaf(tree2))

    if len(leaves1) != len(leaves2):

        return False

    else:

        nleaves = len(leaves1)

        for leaf1, leaf2 in product(leaves1, leaves2):

            is_equal = True

            for node1, node2 in izip(val_iter(tr.iupstream(leaf1)),
                                     val_iter(tr.iupstream(leaf2))):

                if any(node1[0:5] != node2[0:5]):

                    is_equal = False
                    continue

            if is_equal:
                nleaves -= 1

    return nleaves == 0
Пример #3
0
def n_terminations(tree):
    """
    Return number of terminations in tree
    """
    return sum(1 for _ in tr.ileaf(tree))