本文整理汇总了Python中cogent.parse.tree.DndParser.postorder方法的典型用法代码示例。如果您正苦于以下问题:Python DndParser.postorder方法的具体用法?Python DndParser.postorder怎么用?Python DndParser.postorder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cogent.parse.tree.DndParser
的用法示例。
在下文中一共展示了DndParser.postorder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_tree
# 需要导入模块: from cogent.parse.tree import DndParser [as 别名]
# 或者: from cogent.parse.tree.DndParser import postorder [as 别名]
def load_tree(input, tipname_map, verbose=False):
"""Returns a PhyloNode tree decorated with helper attrs
Helper attrs include Consensus, TipStart and TipStop. Nontips and tips that
do not have consensus information will have [None] * len(RANK_ORDER) set
as Consensus
"""
if verbose:
print "loading tree..."
if isinstance(input, TreeNode):
tree = input
else:
tree = DndParser(input)
tips = tree.tips()
n_ranks = len(RANK_ORDER)
for idx, tip in enumerate(tips):
tip.TipStart = idx
tip.TipStop = idx
tip.Consensus = tipname_map.get(tip.Name, [None] * 7)
if verbose and tip.Consensus is None:
print "No consensus for %s" % tip.Name
for node in tree.postorder(include_self=True):
if node.istip():
continue
node.TipStart = node.Children[0].TipStart
node.TipStop = node.Children[-1].TipStop
node.Consensus = [None] * n_ranks
if node.Name is None:
node.Bootstrap = None
else:
try:
node.Bootstrap = float(node.Name)
node.Name = None
except:
if verbose:
print "Could not save bootstrap %s, node is root: %s" % \
(node.Name, str(node.Parent == None))
node.Bootstrap = None
for tip in tree.tips():
if tip.Name:
tip.Name = tip.Name.replace("'","")
return tree