当前位置: 首页>>代码示例>>Python>>正文


Python Tree.nni方法代码示例

本文整理汇总了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
开发者ID:kgori,项目名称:clustering_project,代码行数:47,代码来源:seqsim.py


注:本文中的tree.Tree.nni方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。