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


Python Tree.populate方法代码示例

本文整理汇总了Python中ete3.Tree.populate方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.populate方法的具体用法?Python Tree.populate怎么用?Python Tree.populate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ete3.Tree的用法示例。


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

示例1: get_example_tree

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import populate [as 别名]
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:cancerconnector,项目名称:clonal-evolution,代码行数:27,代码来源:bubble_tree_example.py

示例2: get_example_tree

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import populate [as 别名]
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:abdo3a,项目名称:ete,代码行数:10,代码来源:barchart_and_piechart_faces.py

示例3: run

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import populate [as 别名]
def run(args):
    import random
    from ete3 import Tree

    for n in range(args.number):
        t = Tree()
        t.populate(args.size, random_branches=args.random_branches)
        dump(t)
开发者ID:Ward9250,项目名称:ete,代码行数:10,代码来源:ete_generate.py

示例4: get_example_tree

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import populate [as 别名]
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:AlishaMechtley,项目名称:ete,代码行数:11,代码来源:floating_piecharts.py

示例5: get_example_tree

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import populate [as 别名]
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:AlishaMechtley,项目名称:ete,代码行数:11,代码来源:face_rotation.py

示例6: get_example_tree

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import populate [as 别名]
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:AlishaMechtley,项目名称:ete,代码行数:11,代码来源:item_faces.py

示例7: get_example_tree

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import populate [as 别名]
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:AlishaMechtley,项目名称:ete,代码行数:55,代码来源:node_style.py

示例8: layout

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import populate [as 别名]
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:AlishaMechtley,项目名称:ete,代码行数:16,代码来源:tree_faces.py

示例9: get_example_tree

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import populate [as 别名]
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
    return t, ts
开发者ID:fmaguire,项目名称:ete,代码行数:18,代码来源:seq_motif_faces.py

示例10: master_ly

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import populate [as 别名]
                faces.add_face_to_node(F, node, i, position="aligned")


def master_ly(node):
    random_background(node)
    sphere_map(node)
    leaf_name(node)
    aligned_faces(node)

def tiny_ly(node):
    node.img_style["size"] = 2
    node.img_style["shape"] = "square"

size = 15
t = Tree()
t.populate(size, reuse_names=False)

I = TreeStyle()
I.mode = "r"

I.orientation = 0
I.layout_fn = master_ly
I.margin_left = 100
I.margin_right = 50
I.margin_top = 100
I.arc_start = 45
I.arc_span = 360
I.margin_bottom = 50
I.show_border = True
I.legend_position = 4
I.title.add_face(faces.TextFace("HOLA MUNDO", fsize=30), 0)
开发者ID:AlishaMechtley,项目名称:ete,代码行数:33,代码来源:random_draw.py

示例11: Tree

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import populate [as 别名]
import time
from ete3 import Tree

# Creates a random tree with 10,000 leaf nodes
tree = Tree()
tree.populate(10000)
# This code should be faster
t1 = time.time()
for leaf in tree.iter_leaves():
    if "aw" in leaf.name:
        print "found a match:", leaf.name,
        break
print "Iterating: ellapsed time:", time.time() - t1
# This slower
t1 = time.time()
for leaf in tree.get_leaves():
    if "aw" in leaf.name:
        print "found a match:", leaf.name,
        break
print "Getting: ellapsed time:", time.time() - t1
# Results in something like:
# found a match: guoaw Iterating: ellapsed time: 0.00436091423035 secs
# found a match: guoaw Getting: ellapsed time: 0.124316930771 secs
开发者ID:abdo3a,项目名称:ete,代码行数:25,代码来源:iterators.py

示例12: Tree

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import populate [as 别名]
import sys
import itertools
from ete3 import Tree

try:
    t = Tree()
    t.populate(int(sys.argv[1]), random_branches=True)
except ValueError:
    print >>sys.stderr, 'loading', sys.argv[1]
    t = Tree(sys.argv[1])

lineages = {}
for tip in t:
    lin = []
    n = tip
    while n.up:
        lin.append(n)
        n = n.up
    lineages[tip.name] = set(lin)

matrix = {}
def get_dist(a, b):
    if a == b:
        return 0.0
    try:
        return matrix[(a, b)]
    except KeyError:
        return matrix[(b, a)]

for tip_a, tip_b in itertools.permutations(lineages.keys(), 2):
    d = sum([n.dist for n in lineages[tip_a] ^ lineages[tip_b]])
开发者ID:linsalrob,项目名称:EdwardsLab,代码行数:33,代码来源:dist_matrix.py

示例13: Tree

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import populate [as 别名]
from ete3 import Tree
t = Tree()
# We create a random tree topology
t.populate(15)
print t
print t.children
print t.get_children()
print t.up
print t.name
print t.dist
print t.is_leaf()
print t.get_tree_root()
print t.children[0].get_tree_root()
print t.children[0].children[0].get_tree_root()
# You can also iterate over tree leaves using a simple syntax
for leaf in t:
      print leaf.name
开发者ID:Tancata,项目名称:phylo,代码行数:19,代码来源:etetest.py

示例14: Tree

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import populate [as 别名]
                             # point
R = A.add_child(name="R") # Adds a third child to the
                           # branch. Multifurcations are supported
# Next, I add 6 random leaves to the R branch names_library is an
# optional argument. If no names are provided, they will be generated
# randomly.
R.populate(6, names_library=["r1","r2","r3","r4","r5","r6"])
# Prints the tree topology
print t
#                     /-C
#                    |
#                    |--D
#                    |
#           /--------|                              /-r4
#          |         |                    /--------|
#          |         |          /--------|          \-r3
#          |         |         |         |
#          |         |         |          \-r5
#          |          \--------|
# ---------|                   |                    /-r6
#          |                   |          /--------|
#          |                    \--------|          \-r2
#          |                             |
#          |                              \-r1
#          |
#           \-B
# a common use of the populate method is to quickly create example
# trees from scratch. Here we create a random tree with 100 leaves.
t = Tree()
t.populate(100)
开发者ID:AlishaMechtley,项目名称:ete,代码行数:32,代码来源:create_trees_from_scratch.py

示例15: Tree

# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import populate [as 别名]
from ete3 import Tree
t = Tree()
# Generate a random tree with 50 leaves
t.populate(50)
# Render  tree in png and pdf format using the default size
t.render("./random_tree.png")
t.render("./random_tree.pdf")
# Render tree in pdf setting a custom width. height will be imputed
t.render("./random_tree.pdf", w=300)
# Render tree in pdf setting a custom height. Width will be imputed
t.render("./random_tree.pdf", h=600)
# Render tree in pdf setting a custom width and height
t.render("./random_tree.pdf", w=300, h=300)
开发者ID:AlishaMechtley,项目名称:ete,代码行数:15,代码来源:render_tree_images.py


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