本文整理汇总了Python中cogent.LoadTree.getNodeNames方法的典型用法代码示例。如果您正苦于以下问题:Python LoadTree.getNodeNames方法的具体用法?Python LoadTree.getNodeNames怎么用?Python LoadTree.getNodeNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cogent.LoadTree
的用法示例。
在下文中一共展示了LoadTree.getNodeNames方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MatchNodes
# 需要导入模块: from cogent import LoadTree [as 别名]
# 或者: from cogent.LoadTree import getNodeNames [as 别名]
def MatchNodes(self):
#print "YAY"
self.correctForFastMLNameChanges() #performs the correction on the output string if necessary
#print "NAY"
TerminiStringToNodeName_D = {}
#a termini string is prepared for each internal node, that is, all termini under the internal node sorted an placed into a single string
for NodeKey in self.UpperKey_L:
TerminiStringToNodeName_D['-'.join(sorted(self.Nodes_D[NodeKey]['terminal']))] = NodeKey
#prepares a cogent tree object for the fastML output
FH = getInputTempFile(self.FastMLOutputTreeString)
FastMLCogentTree = LoadTree(FH.name)
self.FastMLToOriginalMatchedNodes_D = {}
#for each cogent node in the FastML cogent tree
for FastMLCogentNodeKey in FastMLCogentTree.getNodeNames():
#a termini string is prepared for the fastML node
FastMLCogentNode = FastMLCogentTree.getNodeMatchingName(FastMLCogentNodeKey)
FastMLTermini_L = [tip.Name for tip in FastMLCogentNode.iterTips()]
#if it has more than 0 termini under the node
if len(FastMLTermini_L) > 0:
#A fastML termini string is prepared, and this termini string will be the same termini string as the equivalent cogent node
FastMLTerminiString = '-'.join(sorted(FastMLTermini_L))
self.FastMLToOriginalMatchedNodes_D[FastMLCogentNodeKey] = TerminiStringToNodeName_D[FastMLTerminiString]
#if it has no termini under it, then the node itself is a terminus and has the same name in FastML and Cogent
else:
self.FastMLToOriginalMatchedNodes_D[FastMLCogentNodeKey] = FastMLCogentNodeKey