本文整理汇总了Python中cogent.parse.tree.DndParser.getTipNames方法的典型用法代码示例。如果您正苦于以下问题:Python DndParser.getTipNames方法的具体用法?Python DndParser.getTipNames怎么用?Python DndParser.getTipNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cogent.parse.tree.DndParser
的用法示例。
在下文中一共展示了DndParser.getTipNames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_tree_subset
# 需要导入模块: from cogent.parse.tree import DndParser [as 别名]
# 或者: from cogent.parse.tree.DndParser import getTipNames [as 别名]
def check_tree_subset(fasta_labels,
tree_fp):
""" Returns a list of all fasta labels that are not a subset of the tree
fasta_labels: list of fasta labels
tree_fp: tree filepath
"""
# Need to get modified fasta labels with underscore stripped
raw_fasta_labels = set([label.split('_')[0] for label in fasta_labels])
tree_f = open(tree_fp, "U")
tree = DndParser(tree_f)
# Get a set of tree tip names
tree_tips = set(tree.getTipNames())
labels_not_in_tips = []
for curr_label in raw_fasta_labels:
if curr_label not in tree_tips:
labels_not_in_tips.append(curr_label)
# Return True if all found in tree tips
if len(labels_not_in_tips) == 0:
labels_not_in_tips = True
return labels_not_in_tips
示例2: check_tree_exact_match
# 需要导入模块: from cogent.parse.tree import DndParser [as 别名]
# 或者: from cogent.parse.tree.DndParser import getTipNames [as 别名]
def check_tree_exact_match(fasta_labels,
tree_fp):
"""Checks fasta labels to exact match to tree tips
Returns a list of two lists, the fasta labels not in tips, and tips not
in fasta labels.
fasta_labels: list of fasta labels
tree_fp: tree filepath
"""
# Need to get modified fasta labels with underscore stripped
raw_fasta_labels = set([label.split('_')[0] for label in fasta_labels])
tree_f = open(tree_fp, "U")
tree = DndParser(tree_f)
# Get a set of tree tip names
tree_tips = set(tree.getTipNames())
labels_not_in_tips = []
for curr_label in raw_fasta_labels:
if curr_label not in tree_tips:
labels_not_in_tips.append(curr_label)
# Return True if all found in tree tips
if len(labels_not_in_tips) == 0:
labels_not_in_tips = True
tips_not_in_labels = []
for curr_tip in tree_tips:
if curr_tip not in raw_fasta_labels:
tips_not_in_labels.append(curr_tip)
if len(tips_not_in_labels) == 0:
tips_not_in_labels = True
return [labels_not_in_tips, tips_not_in_labels]