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


Python LoadTree.unrooted方法代码示例

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


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

示例1: TestTree

# 需要导入模块: from cogent import LoadTree [as 别名]
# 或者: from cogent.LoadTree import unrooted [as 别名]
class TestTree(unittest.TestCase):
    """tests for a single tree-type"""
    
    def setUp(self):
        self.name = 'small tree - '
        self.otu_names = ['NineBande', 'Mouse', 'HowlerMon', 'DogFaced']
        self.otu_names.sort()
        self.newick = '(((Human,HowlerMon),Mouse),NineBande,DogFaced);'
        self.newick_sorted = '(DogFaced,((HowlerMon,Human),Mouse),NineBande);'
        self.newick_reduced = '((HowlerMon,Mouse),NineBande,DogFaced);'
        self.tree = LoadTree(treestring = self.newick)
    
    def test_sorttree(self):
        """testing (well, exercising at least) treesort"""
        new_tree = self.tree.sorted()
        if hasattr(self, 'newick_sorted'):
            self.assertEqual(
                self.newick_sorted,
                new_tree.getNewick(with_distances=0))
    
    def test_getsubtree(self):
        """testing getting a subtree"""
        subtree = self.tree.unrooted().getSubTree(self.otu_names)
        
        new_tree = LoadTree(treestring = self.newick_reduced).unrooted()
        
        # check we get the same names
        self.assertEqual(*[len(t.Children) for t in (subtree,new_tree)])
        self.assertEqual(str(subtree), str(new_tree))
    
    def test_ascii(self):
        self.tree.asciiArt()
        # unlabeled internal node
        tr = DndParser("(B:0.2,(C:0.3,D:0.4):0.6)F;")
        tr.asciiArt(show_internal=True, compact=False)
        tr.asciiArt(show_internal=True, compact=True)
        tr.asciiArt(show_internal=False, compact=False)
开发者ID:carze,项目名称:clovr-base,代码行数:39,代码来源:test_tree2.py

示例2: test_rootswaps

# 需要导入模块: from cogent import LoadTree [as 别名]
# 或者: from cogent.LoadTree import unrooted [as 别名]
 def test_rootswaps(self):
     """testing (well, exercising at least), unrooted"""
     new_tree = LoadTree(treestring="((a,b),(c,d))")
     new_tree = new_tree.unrooted()
     self.assert_(len(new_tree.Children) > 2, 'not unrooted right')
开发者ID:carze,项目名称:clovr-base,代码行数:7,代码来源:test_tree2.py


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