本文整理汇总了Python中ete3.Tree.get_farthest_leaf方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.get_farthest_leaf方法的具体用法?Python Tree.get_farthest_leaf怎么用?Python Tree.get_farthest_leaf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ete3.Tree
的用法示例。
在下文中一共展示了Tree.get_farthest_leaf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeUltra
# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import get_farthest_leaf [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)
示例2: len
# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import get_farthest_leaf [as 别名]
upNode.add_child(newLeaf[0], newLeaf[0].name, newDist)
# NB. using the node.prune() function is too slow
# actualize "mergedInd" feature of new leaf
newLeaf[0].mergedInd = mergedLeaves
else:
# populate "mergedInd" feature for future SFS
mergedLeaves = ""
for l in node.iter_leaves():
mergedLeaves = mergedLeaves+" "+l.name
# collapse the subtree
newLeaf = t.get_farthest_leaf()
for child in t.get_children():
child.detach()
node.add_child(newLeaf[0], newLeaf[0].name, newLeaf[1])
# actualize "mergedInd" feature of new leaf
newLeaf[0].mergedInd = mergedLeaves
nTrueSpecies = len(t)
sys.stdout.write('C')
#======================================================#
# COMPUTE & EXPORT the SFS (full names & numerical)
f = open(osfs+"_allinds.txt", 'w+')
fn = open(osfs, 'w+')