本文整理匯總了Python中ete_dev.Tree.populate方法的典型用法代碼示例。如果您正苦於以下問題:Python Tree.populate方法的具體用法?Python Tree.populate怎麽用?Python Tree.populate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ete_dev.Tree
的用法示例。
在下文中一共展示了Tree.populate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_example_tree
# 需要導入模塊: from ete_dev import Tree [as 別名]
# 或者: from ete_dev.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
示例2: test
# 需要導入模塊: from ete_dev import Tree [as 別名]
# 或者: from ete_dev.Tree import populate [as 別名]
def test(self):
# Text faces
I = TreeImage()
I.mode = "rect"
I.aligned_header.add_face(self.headerF, 0)
I.aligned_header.add_face(self.headerF, 1)
I.aligned_header.add_face(self.headerF, 2)
I.aligned_header.add_face(self.headerF, 3)
I.aligned_foot.add_face(self.footF, 0)
I.aligned_foot.add_face(self.footF, 1)
I.aligned_foot.add_face(self.footF, 2)
I.aligned_foot.add_face(self.footF, 3)
I.draw_aligned_faces_as_grid = True
t = Tree()
t.dist = 0
t.populate(10)
style = NodeStyleDict()
style["fgcolor"] = "#ff0000"
style["size"] = 20
style.add_fixed_face(self.fixedF, "branch-right", 0)
t.img_style = style
t.render("./test.svg", layout=mylayout, tree_style=I)
t.show(mylayout, tree_style=I)
t.show(mylayout2, tree_style=I)
示例3: get_example_tree
# 需要導入模塊: from ete_dev import Tree [as 別名]
# 或者: from ete_dev.Tree import populate [as 別名]
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()
示例4: get_example_tree
# 需要導入模塊: from ete_dev import Tree [as 別名]
# 或者: from ete_dev.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
示例5: get_example_tree
# 需要導入模塊: from ete_dev import Tree [as 別名]
# 或者: from ete_dev.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
示例6: get_example_tree
# 需要導入模塊: from ete_dev import Tree [as 別名]
# 或者: from ete_dev.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
示例7: get_example_tree
# 需要導入模塊: from ete_dev import Tree [as 別名]
# 或者: from ete_dev.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
示例8: get_example_tree
# 需要導入模塊: from ete_dev import Tree [as 別名]
# 或者: from ete_dev.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
示例9: layout
# 需要導入模塊: from ete_dev import Tree [as 別名]
# 或者: from ete_dev.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")
示例10: get_example_tree
# 需要導入模塊: from ete_dev import Tree [as 別名]
# 或者: from ete_dev.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
t.show(tree_style=ts)
return t, ts
示例11: Tree
# 需要導入模塊: from ete_dev import Tree [as 別名]
# 或者: from ete_dev.Tree import populate [as 別名]
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
# \--------| |
示例12: layout
# 需要導入模塊: from ete_dev import Tree [as 別名]
# 或者: from ete_dev.Tree import populate [as 別名]
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)
示例13: master_ly
# 需要導入模塊: from ete_dev import Tree [as 別名]
# 或者: from ete_dev.Tree import populate [as 別名]
# Center text according to masterItem size
tw = text.boundingRect().width()
th = text.boundingRect().height()
center = masterItem.boundingRect().center()
text.setPos(center.x()-tw/2, center.y()-th/2)
return masterItem
def master_ly(node):
if node.is_leaf():
# Create an ItemFAce. First argument must be the pointer to
# the constructor function that returns a QGraphicsItem. It
# will be used to draw the Face. Next arguments are arbitrary,
# and they will be forwarded to the constructor Face function.
F = faces.DynamicItemFace(ugly_name_face, 100, 50)
faces.add_face_to_node(F, node, 0, position="aligned")
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)
t.render("item_faces.png", h=400, tree_style=ts)
# The interactive features are only available using the GUI
t.show(tree_style=ts)
示例14: layout
# 需要導入模塊: from ete_dev import Tree [as 別名]
# 或者: from ete_dev.Tree import populate [as 別名]
from ete_dev import Tree, faces, AttrFace, TreeStyle, NodeStyle
def layout(node):
# If node is a leaf, add the nodes name and a its scientific name
if node.is_leaf():
faces.add_face_to_node(AttrFace("name"), node, column=0)
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
示例15: xrange
# 需要導入模塊: from ete_dev import Tree [as 別名]
# 或者: from ete_dev.Tree import populate [as 別名]
# n4.size = (10, 10)
#n2.size = 10
#n3.size = 10
#n5.size = 10
#n2.dist = 0.1
#n2.size = 1
#n3.size = 1
#n2.dist = 0.5
#t.populate(100)#, random_branches=True)
#t.write(outfile="test.nw")
ts.layout_fn = layout2
t.show(tree_style=ts)
ts.scale = 1
sys.exit()
t.show(tree_style=ts)
for x in xrange(30):
t = Tree()
t.dist = 0
t.populate(100, random_branches=True)
t.render("/tmp/kk.png", tree_style=ts)
sys.exit()
ts.layout_fn = layout
t.show(tree_style=ts)
ts.mode = "r"
t.show(tree_style=ts)