本文整理汇总了Python中ete3.TreeStyle.tree_width方法的典型用法代码示例。如果您正苦于以下问题:Python TreeStyle.tree_width方法的具体用法?Python TreeStyle.tree_width怎么用?Python TreeStyle.tree_width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ete3.TreeStyle
的用法示例。
在下文中一共展示了TreeStyle.tree_width方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import tree_width [as 别名]
def run(args):
if args.text_mode:
from ete3 import Tree
for tindex, tfile in enumerate(args.src_tree_iterator):
#print tfile
if args.raxml:
nw = re.sub(":(\d+\.\d+)\[(\d+)\]", ":\\1[&&NHX:support=\\2]", open(tfile).read())
t = Tree(nw)
else:
t = Tree(tfile)
print(t.get_ascii(show_internal=args.show_internal_names,
attributes=args.show_attributes))
return
import random
import re
import colorsys
from collections import defaultdict
from ete3 import (Tree, PhyloTree, TextFace, RectFace, faces, TreeStyle,
add_face_to_node, random_color)
global FACES
if args.face:
FACES = parse_faces(args.face)
else:
FACES = []
# VISUALIZATION
ts = TreeStyle()
ts.mode = args.mode
ts.show_leaf_name = True
ts.tree_width = args.tree_width
for f in FACES:
if f["value"] == "@name":
ts.show_leaf_name = False
break
if args.as_ncbi:
ts.show_leaf_name = False
FACES.extend(parse_faces(
['value:@sci_name, size:10, fstyle:italic',
'value:@taxid, color:grey, size:6, format:" - %s"',
'value:@sci_name, color:steelblue, size:7, pos:b-top, nodetype:internal',
'value:@rank, color:indianred, size:6, pos:b-bottom, nodetype:internal',
]))
if args.alg:
FACES.extend(parse_faces(
['value:@sequence, size:10, pos:aligned, ftype:%s' %args.alg_type]
))
if args.heatmap:
FACES.extend(parse_faces(
['value:@name, size:10, pos:aligned, ftype:heatmap']
))
if args.bubbles:
for bubble in args.bubbles:
FACES.extend(parse_faces(
['value:@%s, pos:float, ftype:bubble, opacity:0.4' %bubble,
]))
ts.branch_vertical_margin = args.branch_separation
if args.show_support:
ts.show_branch_support = True
if args.show_branch_length:
ts.show_branch_length = True
if args.force_topology:
ts.force_topology = True
ts.layout_fn = lambda x: None
for tindex, tfile in enumerate(args.src_tree_iterator):
#print tfile
if args.raxml:
nw = re.sub(":(\d+\.\d+)\[(\d+)\]", ":\\1[&&NHX:support=\\2]", open(tfile).read())
t = PhyloTree(nw)
else:
t = PhyloTree(tfile)
if args.alg:
t.link_to_alignment(args.alg, alg_format=args.alg_format)
if args.heatmap:
DEFAULT_COLOR_SATURATION = 0.3
BASE_LIGHTNESS = 0.7
def gradient_color(value, max_value, saturation=0.5, hue=0.1):
def rgb2hex(rgb):
return '#%02x%02x%02x' % rgb
def hls2hex(h, l, s):
return rgb2hex( tuple([int(x*255) for x in colorsys.hls_to_rgb(h, l, s)]))
lightness = 1 - (value * BASE_LIGHTNESS) / max_value
return hls2hex(hue, lightness, DEFAULT_COLOR_SATURATION)
#.........这里部分代码省略.........
示例2: SeqMotifFace
# 需要导入模块: from ete3 import TreeStyle [as 别名]
# 或者: from ete3.TreeStyle import tree_width [as 别名]
(t & "C").add_face(seqFace, 0, "aligned")
seqFace = SeqMotifFace(seq, seq_format="()")
(t & "D").add_face(seqFace, 0, "aligned")
seqFace = SeqMotifFace(seq, motifs=simple_motifs, seq_format="-")
(t & "E").add_face(seqFace, 0, "aligned")
seqFace = SeqMotifFace(seq=None, motifs=simple_motifs, gap_format="blank")
(t & "F").add_face(seqFace, 0, "aligned")
seqFace = SeqMotifFace(seq, motifs=mixed_motifs, seq_format="-")
(t & "G").add_face(seqFace, 0, "aligned")
seqFace = SeqMotifFace(seq=None, motifs=box_motifs, gap_format="line")
(t & "H").add_face(seqFace, 0, "aligned")
seqFace = SeqMotifFace(seq[30:60], seq_format="seq")
(t & "I").add_face(seqFace, 0, "aligned")
return t
if __name__ == '__main__':
t = get_example_tree()
ts = TreeStyle()
ts.tree_width = 50
#t.show(tree_style=ts)
t.render("seq_motif_faces.png", tree_style=ts)