本文整理汇总了Python中ete3.Tree.iter_prepostorder方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.iter_prepostorder方法的具体用法?Python Tree.iter_prepostorder怎么用?Python Tree.iter_prepostorder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ete3.Tree
的用法示例。
在下文中一共展示了Tree.iter_prepostorder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeUltra
# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import iter_prepostorder [as 别名]
def makeUltra(treeFile):
"""Make a tree ultrametric
"""
print("loading trees...")
treelist = []
with open(treeFile, 'r') as newick:
for line in newick:
if not line.startswith("NA"):
t = Tree(line)
most_distant_leaf, tree_length = t.get_farthest_leaf()
current_dist = 0
for postorder, node in t.iter_prepostorder():
if postorder:
current_dist -= node.dist
else:
if node.is_leaf():
node.dist += tree_length - (current_dist + node.dist)
elif node.up: # node is internal
current_dist += node.dist
treelist.append(t)
return(treelist)