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


Python Tree.deroot方法代码示例

本文整理汇总了Python中dendropy.Tree.deroot方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.deroot方法的具体用法?Python Tree.deroot怎么用?Python Tree.deroot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dendropy.Tree的用法示例。


在下文中一共展示了Tree.deroot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_dendropy_tree_from_break_tree

# 需要导入模块: from dendropy import Tree [as 别名]
# 或者: from dendropy.Tree import deroot [as 别名]
    def get_dendropy_tree_from_break_tree(self, break_tree):
        nodes = self._extract_break_tree_leaves(break_tree)
        sorted_break_tree_leaves_sets, max_leaves_set_size = self._sort_break_tree_leaves_sets(break_tree)

        for leave_set_size in range(max_leaves_set_size):
            if leave_set_size not in sorted_break_tree_leaves_sets:
                continue

            for leave_set in sorted_break_tree_leaves_sets[leave_set_size]:
                one_step_parents = []
                for leaf in leave_set:
                    node = self._find_node_with_same_taxon(nodes, leaf)
                    oldest_parent = self._get_oldest_parent(node)
                    if oldest_parent not in one_step_parents:
                        one_step_parents.append(oldest_parent)

                new_oldest_parent = Node()
                if len(one_step_parents) > 1:
                    for parent in one_step_parents:
                        parent.parent_node = new_oldest_parent

        oldest_parents = []
        for node in nodes:
            oldest_parent = self._get_oldest_parent(node)
            if oldest_parent not in oldest_parents:
                oldest_parents.append(oldest_parent)

        if len(oldest_parents) > 1:
            seed = Node()
            for oldest_parent in oldest_parents:
                oldest_parent.parent_node = seed
        elif len(oldest_parents) == 1:
            seed = oldest_parents[0]
        else:
            seed = Node()

        tree = Tree(seed_node=seed)
        tree.deroot()
        return tree
开发者ID:Maratka,项目名称:BioProjekt,代码行数:41,代码来源:Converter.py


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