本文整理汇总了Python中ete3.TreeStyle.draw_aligned_faces_as_table方法的典型用法代码示例。如果您正苦于以下问题:Python TreeStyle.draw_aligned_faces_as_table方法的具体用法?Python TreeStyle.draw_aligned_faces_as_table怎么用?Python TreeStyle.draw_aligned_faces_as_table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ete3.TreeStyle
的用法示例。
在下文中一共展示了TreeStyle.draw_aligned_faces_as_table方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_tree
# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import draw_aligned_faces_as_table [as 别名]
#.........这里部分代码省略.........
pass
def ly_block_alg(node):
if node.is_leaf():
if 'sequence' in node.features:
seqFace = SeqMotifFace(node.sequence, [])
# [10, 100, "[]", None, 10, "black", "rgradient:blue", "arial|8|white|domain Name"],
motifs = []
last_lt = None
for c, lt in enumerate(node.sequence):
if lt != '-':
if last_lt is None:
last_lt = c
if c+1 == len(node.sequence):
start, end = last_lt, c
motifs.append([start, end, "()", 0, 12, "slategrey", "slategrey", None])
last_lt = None
elif lt == '-':
if last_lt is not None:
start, end = last_lt, c-1
motifs.append([start, end, "()", 0, 12, "grey", "slategrey", None])
last_lt = None
seqFace = SeqMotifFace(node.sequence, motifs,
intermotif_format="line",
seqtail_format="line", scale_factor=ALG_SCALE)
add_face_to_node(seqFace, node, ALG_START_COL, aligned=True)
TRACKED_CLADES = ["Eukaryota", "Viridiplantae", "Fungi",
"Alveolata", "Metazoa", "Stramenopiles", "Rhodophyta",
"Amoebozoa", "Crypthophyta", "Bacteria",
"Alphaproteobacteria", "Betaproteobacteria", "Cyanobacteria",
"Gammaproteobacteria",]
# ["Opisthokonta", "Apicomplexa"]
colors = random_color(num=len(TRACKED_CLADES), s=0.45)
lin2color = dict([(ln, colors[i]) for i, ln in enumerate(TRACKED_CLADES)])
NAME_FACE = AttrFace('name', fsize=10, fgcolor='#444444')
LABEL_START_COL = 10
ALG_START_COL = 40
ts = TreeStyle()
ts.draw_aligned_faces_as_table = False
ts.draw_guiding_lines = False
ts.show_leaf_name = False
ts.show_branch_support = False
ts.scale = 160
ts.layout_fn = [ly_basic, ly_leaf_names, ly_supports, ly_tax_labels]
MIXED_RES = set()
MAX_SEQ_LEN = 0
NPR_TREES = []
for n in tree.traverse():
if hasattr(n, "tree_seqtype"):
MIXED_RES.add(n.tree_seqtype)
if hasattr(n, "tree_type"):
NPR_TREES.append(n.tree_type)
seq = getattr(n, "sequence", "")
MAX_SEQ_LEN = max(len(seq), MAX_SEQ_LEN)
if MAX_SEQ_LEN:
ALG_SCALE = min(1, 1000./MAX_SEQ_LEN)
ts.layout_fn.append(ly_block_alg)
if len(NPR_TREES) > 1:
rF = RectFace(4, 4, "steelblue", "steelblue")
rF.margin_right = 10
rF.margin_left = 10
ts.legend.add_face(rF, 0)
ts.legend.add_face(TextFace(" NPR node"), 1)
ts.legend_position = 3
if len(MIXED_RES) > 1:
rF = RectFace(20, 20, "#CFE6CA", "#CFE6CA")
rF.margin_right = 10
rF.margin_left = 10
ts.legend.add_face(rF, 0)
ts.legend.add_face(TextFace(" Nucleotide based alignment"), 1)
ts.legend_position = 3
try:
tree.set_species_naming_function(spname)
annotate_tree_with_ncbi(tree)
a = tree.search_nodes(species='Dictyostelium discoideum')[0]
b = tree.search_nodes(species='Chondrus crispus')[0]
#out = tree.get_common_ancestor([a, b])
#out = tree.search_nodes(species='Haemophilus parahaemolyticus')[0].up
tree.set_outgroup(out)
tree.swap_children()
except Exception:
pass
tree.render(outfile, tree_style=ts, w=170, units='mm', dpi=150)
tree.render(outfile+'.svg', tree_style=ts, w=170, units='mm', dpi=150)
tree.render(outfile+'.pdf', tree_style=ts, w=170, units='mm', dpi=150)
示例2: PhyloTree
# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import draw_aligned_faces_as_table [as 别名]
from ete3 import add_face_to_node, TextFace, AttrFace, SequenceFace
nw = '(0:0, 1:20);'
fa = """
>0
AA..
>1
CAA.
"""
t = PhyloTree(nw, alignment=fa, alg_format='fasta', format=1)
ts = TreeStyle()
ts.show_branch_length = False
ts.show_leaf_name = False
ts.draw_guiding_lines = True
ts.draw_aligned_faces_as_table = True
ts.show_scale = False
def my_layout(node):
#
# add names to all nodes (not just to leaf nodes)
# ete3/test/test_treeview/face_rotation.py
F = TextFace(node.name, tight_text=True)
add_face_to_node(F, node, column=0, position="branch-right")
#
# add branch lengths
# ete3/treeview/qt4_render.py
if not node.is_root():
bl_face = AttrFace("dist", fsize=8, ftype="Arial",
fgcolor="black", formatter="%0.3g")
#