当前位置: 首页>>代码示例>>Python>>正文


Python ete_dev.Tree类代码示例

本文整理汇总了Python中ete_dev.Tree的典型用法代码示例。如果您正苦于以下问题:Python Tree类的具体用法?Python Tree怎么用?Python Tree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Tree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_example_tree

def get_example_tree():

    # sample sequence and a list of example motif types     
    seq = "LHGRISQQVEQSRSQVQAIGEKVSLAQAKIEKIKGSKKAIKVFSSAKYPAPERLQEYGSIFTDAQDPGLQRRPRHRIQSKQRPLDERALQEKLKDFPVCVSTKPEPEDDAEEGLGGLPSNISSVSSLLLFNTTENLYKKYVFLDPLAGAVTKTHVMLGAETEEKLFDAPLSISKREQLEQQVPENYFYVPDLGQVPEIDVPSYLPDLPGIANDLMYIADLGPGIAPSAPGTIPELPTFHTEVAEPLKVGELGSGMGAGPGTPAHTPSSLDTPHFVFQTYKMGAPPLPPSTAAPVGQGARQDDSSSSASPSVQGAPREVVDPSGGWATLLESIRQAGGIGKAKLRSMKERKLEKQQQKEQEQVRATSQGGHLMSDLFNKLVMRRKGISGKGPGAGDGPGGAFARVSDSIPPLPPPQQPQAEDEDDWES"
    motifs = [
        # seq.start, seq.end, shape, width, height, fgcolor, bgcolor
        [10, 100, "[]", None, 10, "black", "rgradient:blue", "arial|8|white|domain Name"],
        [110, 150, "o", None, 10, "blue", "pink", None],
        [155, 180, "()", None, 10, "blue", "rgradient:purple", None],
        [160, 170, "^", None, 14, "black", "yellow", None],
        [172, 180, "v", None, 12, "black", "rgradient:orange", None],
        [185, 190, "o", None, 12, "black", "brown", None],
        [198, 200, "<>", None, 15, "black", "rgradient:gold", None],
        [210, 240, "compactseq", 2, 10, None, None, None],
        [300, 320, "seq", 10, 10, None, None, None],
        [310, 345, "<>", None, 15, "black", "rgradient:black", None],
    ]
    # Create a random tree and add to each leaf a random set of motifs
    # from the original set
    t = Tree()
    t.populate(10)
    for l in t.iter_leaves():
        seq_motifs = [list(m) for m in motifs] #sample(motifs, randint(2, len(motifs))) 

        seqFace = SeqMotifFace(seq, seq_motifs, intermotif_format="line",
                               seqtail_format="compactseq", scale_factor=1)
        seqFace.margin_bottom = 4
        f = l.add_face(seqFace, 0, "aligned")

    return t, TreeStyle()
开发者ID:daisieh,项目名称:ete,代码行数:30,代码来源:seq_motif_faces.py

示例2: get_example_tree

def get_example_tree():
    # Random tree
    t = Tree()
    t.populate(20, random_branches=True)

    # Some random features in all nodes
    for n in t.traverse():
        n.add_features(weight=random.randint(0, 50))

    # Create an empty TreeStyle
    ts = TreeStyle()

    # Set our custom layout function
    ts.layout_fn = layout

    # Draw a tree 
    ts.mode = "c"

    # We will add node names manually
    ts.show_leaf_name = False
    # Show branch data
    ts.show_branch_length = True
    ts.show_branch_support = True

    return t, ts
开发者ID:MikeTrizna,项目名称:ete,代码行数:25,代码来源:bubble_map.py

示例3: get_example_tree

def get_example_tree():
    t = Tree()
    ts = TreeStyle()
    ts.layout_fn = layout
    ts.mode = "r"
    ts.show_leaf_name = False
    t.populate(10)
    return t, ts
开发者ID:daisieh,项目名称:ete,代码行数:8,代码来源:barchart_and_piechart_faces.py

示例4: get_example_tree

def get_example_tree():
        
    t = Tree()
    t.populate(8, reuse_names=False)

    ts = TreeStyle()
    ts.layout_fn = master_ly
    ts.title.add_face(faces.TextFace("Drawing your own Qt Faces", fsize=15), 0)
    return t, ts
开发者ID:MikeTrizna,项目名称:ete,代码行数:9,代码来源:item_faces.py

示例5: get_example_tree

def get_example_tree():
    t = Tree()
    t.populate(10)
    ts = TreeStyle()
    ts.rotation = 45
    ts.show_leaf_name = False
    ts.layout_fn = rotation_layout
    
    return t, ts
开发者ID:MikeTrizna,项目名称:ete,代码行数:9,代码来源:face_rotation.py

示例6: get_example_tree

def get_example_tree():
    t = Tree()
    ts = TreeStyle()
    ts.layout_fn = layout
    ts.mode = "c"
    ts.show_leaf_name = True
    ts.min_leaf_separation = 15
    t.populate(100)
    return t, ts
开发者ID:MikeTrizna,项目名称:ete,代码行数:9,代码来源:floating_piecharts.py

示例7: layout

def layout(node):
    if node.is_leaf():
        # Add node name to laef nodes
        N = AttrFace("name", fsize=14, fgcolor="black")
        faces.add_face_to_node(N, node, 0)

        t = Tree()
        t.populate(10)

        T = TreeFace(t, small_ts)
        # Let's make the sphere transparent 
        T.opacity = 0.8
        # And place as a float face over the tree
        faces.add_face_to_node(T, node, 1, position="aligned")
开发者ID:alxndrsPittis,项目名称:ete,代码行数:14,代码来源:tree_faces.py

示例8: get_example_tree

def get_example_tree():
    # Create a random tree and add to each leaf a random set of motifs
    # from the original set
    t = Tree()
    t.populate(10)
    # for l in t.iter_leaves():
    #     seq_motifs = [list(m) for m in motifs] #sample(motifs, randint(2, len(motifs))) 

    #     seqFace = SeqMotifFace(seq, seq_motifs, intermotif_format="line",
    #                            seqtail_format="compactseq", scale_factor=1)
    #     seqFace.margin_bottom = 4
    #     f = l.add_face(seqFace, 0, "aligned")

    ts = TreeStyle()
    ts.layout_fn = layout
    t.show(tree_style=ts)
    return t, ts
开发者ID:MikeTrizna,项目名称:ete,代码行数:17,代码来源:seq_motif_faces.py

示例9: get_example_tree

def get_example_tree():

    # Set dashed blue lines in all leaves
    nst1 = NodeStyle()
    nst1["bgcolor"] = "LightSteelBlue"
    nst2 = NodeStyle()
    nst2["bgcolor"] = "Moccasin"
    nst3 = NodeStyle()
    nst3["bgcolor"] = "DarkSeaGreen"
    nst4 = NodeStyle()
    nst4["bgcolor"] = "Khaki"


    t = Tree("((((a1,a2),a3), ((b1,b2),(b3,b4))), ((c1,c2),c3));")
    for n in t.traverse():
        n.dist = 0
    
    n1 = t.get_common_ancestor("a1", "a2", "a3")
    n1.set_style(nst1)
    n2 = t.get_common_ancestor("b1", "b2", "b3", "b4")
    n2.set_style(nst2)
    n3 = t.get_common_ancestor("c1", "c2", "c3")
    n3.set_style(nst3)
    n4 = t.get_common_ancestor("b3", "b4")
    n4.set_style(nst4)
    ts = TreeStyle()
    ts.layout_fn = layout
    ts.show_leaf_name = False

    ts.mode = "c"
    ts.root_opening_factor = 1
    return t, ts
开发者ID:MikeTrizna,项目名称:ete,代码行数:32,代码来源:node_background.py

示例10: get_example_tree

def get_example_tree():

    t = Tree()
    t.populate(8)

    # Node style handling is no longer limited to layout functions. You
    # can now create fixed node styles and use them many times, save them
    # or even add them to nodes before drawing (this allows to save and
    # reproduce an tree image design)

    # Set bold red branch to the root node
    style = NodeStyle()
    style["fgcolor"] = "#0f0f0f"
    style["size"] = 0
    style["vt_line_color"] = "#ff0000"
    style["hz_line_color"] = "#ff0000"
    style["vt_line_width"] = 8
    style["hz_line_width"] = 8
    style["vt_line_type"] = 0 # 0 solid, 1 dashed, 2 dotted
    style["hz_line_type"] = 0
    t.set_style(style)

    #Set dotted red lines to the first two branches
    style1 = NodeStyle()
    style1["fgcolor"] = "#0f0f0f"
    style1["size"] = 0
    style1["vt_line_color"] = "#ff0000"
    style1["hz_line_color"] = "#ff0000"
    style1["vt_line_width"] = 2
    style1["hz_line_width"] = 2
    style1["vt_line_type"] = 2 # 0 solid, 1 dashed, 2 dotted
    style1["hz_line_type"] = 2
    t.children[0].img_style = style1
    t.children[1].img_style = style1

    # Set dashed blue lines in all leaves
    style2 = NodeStyle()
    style2["fgcolor"] = "#000000"
    style2["shape"] = "circle"
    style2["vt_line_color"] = "#0000aa"
    style2["hz_line_color"] = "#0000aa"
    style2["vt_line_width"] = 2
    style2["hz_line_width"] = 2
    style2["vt_line_type"] = 1 # 0 solid, 1 dashed, 2 dotted
    style2["hz_line_type"] = 1
    for l in t.iter_leaves():
        l.img_style = style2

    ts = TreeStyle()
    ts.layout_fn = layout
    ts.show_leaf_name = False

    return t, ts
开发者ID:MikeTrizna,项目名称:ete,代码行数:53,代码来源:node_style.py

示例11: Tree

from ete_dev import Tree

# Loads a tree
tree = Tree("((H:1,I:1):0.5, A:1, (B:1,(C:1,D:1):0.5):0.5);")
print "this is the original tree:"
print tree
#                    /-H
#          /--------|
#         |          \-I
#         |
# ---------|--A
#         |
#         |          /-B
#          \--------|
#                   |          /-C
#                    \--------|
#                              \-D
# Finds the first common ancestor between B and C.
ancestor = tree.get_common_ancestor("D", "C")
print "The ancestor of C and D is:"
print ancestor
#          /-C
# ---------|
#          \-D
# You can use more than two nodes in the search
ancestor = tree.get_common_ancestor("B", "C", "D")
print "The ancestor of B, C and D is:"
print ancestor
#          /-B
# ---------|
#         |          /-C
开发者ID:daisieh,项目名称:ete,代码行数:31,代码来源:get_common_ancestor.py

示例12: Tree

from ete_dev import Tree
# Load an unrooted tree. Note that three branches hang from the root
# node. This usually means that no information is available about
# which of nodes is more basal.
t = Tree('(A,(H,F)(B,(E,D)));')
print "Unrooted tree"
print t
#          /-A
#         |
#         |          /-H
#---------|---------|
#         |          \-F
#         |
#         |          /-B
#          \--------|
#                   |          /-E
#                    \--------|
#                              \-D
#
# Let's define that the ancestor of E and D as the tree outgroup.  Of
# course, the definition of an outgroup will depend on user criteria.
ancestor = t.get_common_ancestor("E","D")
t.set_outgroup(ancestor)
print "Tree rooteda at E and D's ancestor is more basal that the others."
print t
#
#                    /-B
#          /--------|
#         |         |          /-A
#         |          \--------|
#         |                   |          /-H
开发者ID:MikeTrizna,项目名称:ete,代码行数:31,代码来源:rooting_trees.py

示例13: Tree

from ete_dev import Tree
# generates a random tree
t = Tree();
t.populate(15);
print t
#
#
#                    /-qogjl
#          /--------|
#         |          \-vxbgp
#         |
#         |          /-xyewk
#---------|         |
#         |         |                    /-opben
#         |         |                   |
#         |         |          /--------|                    /-xoryn
#          \--------|         |         |          /--------|
#                   |         |         |         |         |          /-wdima
#                   |         |          \--------|          \--------|
#                   |         |                   |                    \-qxovz
#                   |         |                   |
#                   |         |                    \-isngq
#                    \--------|
#                             |                    /-neqsc
#                             |                   |
#                             |                   |                              /-waxkv
#                             |          /--------|                    /--------|
#                             |         |         |          /--------|          \-djeoh
#                             |         |         |         |         |
#                             |         |          \--------|          \-exmsn
#                              \--------|                   |
开发者ID:MikeTrizna,项目名称:ete,代码行数:31,代码来源:get_midpoint_outgroup.py

示例14: Tree

# Import Tree instance and faces module
from ete_dev import Tree, faces

# Loads an example tree
nw = """
(((Dre:0.008339,Dme:0.300613)1.000000:0.596401,
(Cfa:0.640858,Hsa:0.753230)1.000000:0.182035)1.000000:0.106234,
((Dre:0.271621,Cfa:0.046042)1.000000:0.953250,
(Hsa:0.061813,Mms:0.110769)1.000000:0.204419)1.000000:0.973467);
"""
t = Tree(nw)

# You can create any random tree containing the same leaf names, and
# layout will work equally
#
# t = Tree()
# Creates a random tree with 8 leaves using a given set of names
# t.populate(8, ["Dme", "Dre", "Hsa", "Ptr", "Cfa", "Mms"])

# Set the path in which images are located
img_path = "./"
# Create faces based on external images
humanFace = faces.ImgFace(img_path+"human.png")
mouseFace = faces.ImgFace(img_path+"mouse.png")
dogFace = faces.ImgFace(img_path+"dog.png")
chimpFace = faces.ImgFace(img_path+"chimp.png")
fishFace = faces.ImgFace(img_path+"fish.png")
flyFace = faces.ImgFace(img_path+"fly.png")

# Create a faces ready to read the name attribute of nodes
#nameFace = faces.TextFace(open("text").readline().strip(), fsize=20, fgcolor="#009000")
开发者ID:MikeTrizna,项目名称:ete,代码行数:31,代码来源:custom_tree_visualization.py

示例15: layout

import sys
from ete_dev import Tree, faces, TreeStyle, COLOR_SCHEMES

sys.path.insert(0, "./")
def layout(node):
    if node.is_leaf():
        F= faces.PieChartFace([10,10,10,10,10,10,10,10,10,4,6], colors=COLOR_SCHEMES["set3"], width=100, height=100)
        F.border.width = None
        F.opacity = 0.8
        faces.add_face_to_node(F,node, 0, position="branch-right")
        F.background.color = "indianred"
        x = faces.TextFace("hola")
        faces.add_face_to_node(x,node, 1, position="branch-right")
        x.background.color = "blue"
    else:
        F= faces.BarChartFace([40,20,70,100,30,40,50,40,70,12], min_value=0, colors=COLOR_SCHEMES["spectral"])
        faces.add_face_to_node(F,node, 0, position="branch-top")
        
t = Tree()
ts = TreeStyle()
ts.layout_fn = layout
ts.mode = "r"
ts.show_leaf_name = False

t.populate(10)
t.show(tree_style=ts)
开发者ID:alxndrsPittis,项目名称:ete,代码行数:26,代码来源:test_newfaces.py


注:本文中的ete_dev.Tree类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。