当前位置: 首页>>代码示例>>Python>>正文


Python Tree.get_farthest_leaf方法代码示例

本文整理汇总了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)
开发者ID:stsmall,项目名称:An_funestus,代码行数:23,代码来源:makeUltrametric.py

示例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+')
开发者ID:sunyatin,项目名称:vanaprabhava,代码行数:33,代码来源:VPB.py


注:本文中的ete3.Tree.get_farthest_leaf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。