本文整理汇总了Python中dendropy.Tree.retain_taxa_with_labels方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.retain_taxa_with_labels方法的具体用法?Python Tree.retain_taxa_with_labels怎么用?Python Tree.retain_taxa_with_labels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dendropy.Tree
的用法示例。
在下文中一共展示了Tree.retain_taxa_with_labels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: displayed_subtree
# 需要导入模块: from dendropy import Tree [as 别名]
# 或者: from dendropy.Tree import retain_taxa_with_labels [as 别名]
def displayed_subtree(tree, labels):
#this is annoying, but Dendropy can consider the labels not matching depending on
#underscore vs. space issues
#Realized that using retain_taxa vs prune_taxa doesn't make any difference - dendropy
#used prune behind the scenes regardless
#DP3 vs. DP4
if hasattr(tree, 'taxon_namespace'):
newtree = Tree(tree, taxon_namespace=tree.taxon_namespace)
else:
newtree = Tree(tree, taxon_set=tree.taxon_set)
if isinstance(labels[0], str):
newtree.retain_taxa_with_labels(labels)
else:
newtree.retain_taxa(labels)
#compat_encode_bipartitions now maps delete_outdegree_one to collapse_unrooted_basal_bifurcation in DP 4
compat_encode_bipartitions(newtree, delete_outdegree_one=False)
return newtree