本文整理汇总了Python中cogent.LoadTree.sorted方法的典型用法代码示例。如果您正苦于以下问题:Python LoadTree.sorted方法的具体用法?Python LoadTree.sorted怎么用?Python LoadTree.sorted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cogent.LoadTree
的用法示例。
在下文中一共展示了LoadTree.sorted方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestTree
# 需要导入模块: from cogent import LoadTree [as 别名]
# 或者: from cogent.LoadTree import sorted [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)