예제 #1
0
def test_ibifurcation_point_upstream():
    leaves = [l for l in ileaf(REF_TREE2)]
    ref_paths = [[11, 0], [11, 0], [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(ibifurcation_point(l, iupstream))], ref)
예제 #2
0
def test_ibifurcation_point_upstream():
    leaves = [l for l in ileaf(REF_TREE2)]
    ref_paths = [
        [11, 0], [11, 0], [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(ibifurcation_point(l, iupstream))], ref)
예제 #3
0
def i_remote_bifurcation_angle(tree):
    '''Return the opening angle between the last segments of two out-going
    sections of a bifurcation point
    '''
    def _remangle(t):
        '''Helper to calculate the remote angle'''
        end_points = tuple(p for p in tr.i_branch_end_points(t))
        return mm.angle_3points(t.value, end_points[0].value, end_points[1].value)

    return imap(_remangle, tr.ibifurcation_point(tree))
예제 #4
0
def i_remote_bifurcation_angle(tree):
    '''Return the opening angle between the last segments of two out-going
    sections of a bifurcation point
    '''
    def _remangle(t):
        '''Helper to calculate the remote angle'''
        end_points = tuple(p for p in tr.i_branch_end_points(t))
        return mm.angle_3points(t.value, end_points[0].value,
                                end_points[1].value)

    return imap(_remangle, tr.ibifurcation_point(tree))
예제 #5
0
def partition(tree):
    '''Measures the distribution of sections
       to the children subtrees at each bifurcation point.
       Partition is defined as the max/min number of sections
       between the children subtrees of a bifurcation point.

       Returns:
           List of partition for each bifurcation point.
    '''
    def partition_at_point(bif_point):
        '''Partition at each bif point.'''
        n = n_sections(bif_point.children[0])
        m = n_sections(bif_point.children[1])
        return max(n, m) / min(n, m)

    return [partition_at_point(i)
            for i in tr.ibifurcation_point(tree)]
예제 #6
0
def test_valiter_bifurcation_point():
    nt.ok_(list(val_iter(ibifurcation_point(REF_TREE2))) ==
           [0, 11, 12, 1211])
예제 #7
0
def test_ibifurcation_point_postorder():
    nt.assert_equal([n.value for n in ibifurcation_point(REF_TREE2, ipostorder)],
                    [11, 1211, 12, 0])
예제 #8
0
def test_ibifurcation_point():
    nt.assert_equal([n.value for n in ibifurcation_point(REF_TREE2)],
                    [0, 11, 12, 1211])
예제 #9
0
def n_bifurcations(tree):
    """
    Return number of bifurcations in tree
    """
    return sum(1 for _ in tr.ibifurcation_point(tree))
예제 #10
0
def i_local_bifurcation_angle(tree):
    '''Return the opening angle between two out-going segments
    in a bifurcation point
    '''
    return imap(local_bifurcation_angle,
                tr.ibifurcation_point(tree))
예제 #11
0
def test_valiter_bifurcation_point():
    nt.ok_(list(val_iter(ibifurcation_point(REF_TREE2))) == [0, 11, 12, 1211])
예제 #12
0
def test_ibifurcation_point_postorder():
    nt.assert_equal(
        [n.value for n in ibifurcation_point(REF_TREE2, ipostorder)],
        [11, 1211, 12, 0])
예제 #13
0
def test_ibifurcation_point():
    nt.assert_equal([n.value for n in ibifurcation_point(REF_TREE2)],
                    [0, 11, 12, 1211])
예제 #14
0
def n_bifurcations(tree):
    """
    Return number of bifurcations in tree
    """
    return sum(1 for _ in tr.ibifurcation_point(tree))
예제 #15
0
def i_local_bifurcation_angle(tree):
    '''Return the opening angle between two out-going segments
    in a bifurcation point
    '''
    return imap(local_bifurcation_angle, tr.ibifurcation_point(tree))