示例#1
0
def nextbacktree(t, i, q=None, lim=0, maxdepth=None):
    """
    create a tree of ivy.tree.Nodes from table t, with
    records having fields next, back, parent, and depth
    """
    db = t._db
    r = t[int(i)]
    limits = dict(orderby=t.next)
    limits['orderby'] = t.next
    if lim: limits["limitby"] = (0,lim)
    q2 = (t.next>r.next)&(t.back<r.back)
    if maxdepth:
        q2 &= (t.depth <= maxdepth)
    recs = db(q)(q2).select(**limits)
    
    root = Node(); root.isroot = True
    root.rec = r; root.id = r.id; root.next = r.next; root.back = r.back;

    i2n = {}; i2n[r.id] = root
    for r in recs:
        n = Node()
        n.rec = r; n.id = r.id; n.next = r.next; n.back = r.back; n.parent = i2n[r.parent];
        if (((not maxdepth) and (r.next==r.back-1)) or
            (maxdepth and (n.depth == maxdepth))):
            n.isleaf = True
        i2n[r.id] = n
        i2n[r.parent].add_child(n)
    return root
示例#2
0
def nextbackgtree(t, i, q=None, lim=0, maxdepth=None):
    """
    create a tree of ivy.tree.Nodes from table t, with
    records having fields next, back, parent, and depth
    """
    db = t._db
    r = t[int(i)]
    limits = dict(orderby=t.next)
    if lim: limits["limitby"] = (0,lim)
    q2 = (t.next>r.next)&(t.back<r.back)
    if maxdepth:
        q2 &= (t.depth <= maxdepth)
    recs = db(q)(q2).select(**limits)
   
    #Node = ivy.tree.Node
    root = Node(); root.isroot = True
    root.rec = r; root.id = r.id; root.next = r.next; root.back = r.back; root.stree = r.stree; root.snode = r.snode 

    i2n = {}; i2n[r.id] = root

    for r in recs:
    
        n = Node()

        if( not hasattr( r, 'id' ) ):
            r = r.gnode

        n.rec = r; n.id = r.id; n.next = r.next; n.back = r.back; n.stree = r.stree; n.snode = r.snode
        if (((not maxdepth) and (r.next==r.back-1)) or
            (maxdepth and (n.depth == maxdepth))):
            n.isleaf = True
        i2n[r.id] = n
        i2n[r.parent].add_child(n)
    return root
示例#3
0
def getNodeFromRowData( row ):

    node = Node()

    node.id = row[0]; node.next = row[1]; node.back = row[2]; node.length = row[3]; node.label = row[4]
    node.taxon = row[5];

    return node
示例#4
0
def getNodeFromRowData(row):

    node = Node()

    node.id = row[0]
    node.next = row[1]
    node.back = row[2]
    node.length = row[3]
    node.label = row[4]
    node.taxon = row[5]

    return node
示例#5
0
def nextbacktree(t, i, q=None, lim=0, maxdepth=None):
    """
    create a tree of ivy.tree.Nodes from table t, with
    records having fields next, back, parent, and depth
    """
    db = t._db
    r = t[int(i)]
    limits = dict(orderby=t.next)
    limits['orderby'] = t.next
    if lim: limits["limitby"] = (0, lim)
    q2 = (t.next > r.next) & (t.back < r.back)
    if maxdepth:
        q2 &= (t.depth <= maxdepth)
    recs = db(q)(q2).select(**limits)

    root = Node()
    root.isroot = True
    root.rec = r
    root.id = r.id
    root.next = r.next
    root.back = r.back

    i2n = {}
    i2n[r.id] = root
    for r in recs:
        n = Node()
        n.rec = r
        n.id = r.id
        n.next = r.next
        n.back = r.back
        n.parent = i2n[r.parent]
        if (((not maxdepth) and (r.next == r.back - 1))
                or (maxdepth and (n.depth == maxdepth))):
            n.isleaf = True
        i2n[r.id] = n
        i2n[r.parent].add_child(n)
    return root