本文整理汇总了Python中tree.Tree.nni方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.nni方法的具体用法?Python Tree.nni怎么用?Python Tree.nni使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree.Tree
的用法示例。
在下文中一共展示了Tree.nni方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_class_tree
# 需要导入模块: from tree import Tree [as 别名]
# 或者: from tree.Tree import nni [as 别名]
def make_class_tree(
master_tree,
permutation_extent,
method,
with_check=True,
checklist=[],
):
"""
Function returns a tree object derived from a master tree,
but with some permutation applied. The type of permutation
is defined by `method`, one of 'nni', 'spr' and 'coal'
If with_check is True, the generated tree is checked against
a checklist of other trees on the same species, and permutations
are applied until the new tree has a unique topology. This is
only implemented for nni and spr.
"""
if num_permutations == 0:
return master_tree
new_tree = Tree(master_tree.newick)
if method == 'nni':
if with_check:
while not self.check_diff_top(new_tree, checklist):
new_tree = Tree(master_tree.newick)
for i in range(permutation_extent):
new_tree = new_tree.nni()
else:
for i in range(num_permutations):
new_tree = new_tree.nni()
elif method == 'spr':
if with_check:
while not self.check_diff_top(new_tree, checklist):
new_tree = Tree(master_tree.newick)
for i in range(permutation_extent):
new_tree = \
new_tree.spr(disallow_sibling_SPRs=True)
else:
for i in range(num_permutations):
new_tree = new_tree.spr()
elif method == 'coal':
new_tree = \
master_tree.get_constrained_gene_tree(scale_to=permutation_extent)
return new_tree