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


Python DndParser.getNewick方法代码示例

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


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

示例1: test_DndParser

# 需要导入模块: from cogent.parse.tree import DndParser [as 别名]
# 或者: from cogent.parse.tree.DndParser import getNewick [as 别名]
    def test_DndParser(self):
        """DndParser tests"""
        t_str = "(A_a,(B:1.0,C),'D_e':0.5)E;"
        tree_unesc = DndParser(t_str, PhyloNode, unescape_name=True)
        tree_esc = DndParser(t_str, PhyloNode, unescape_name=False)

        self.assertEqual(tree_unesc.Name, 'E')
        self.assertEqual(tree_unesc.Children[0].Name, 'A a')
        self.assertEqual(tree_unesc.Children[1].Children[0].Name, 'B')
        self.assertEqual(tree_unesc.Children[1].Children[0].Length, 1.0)
        self.assertEqual(tree_unesc.Children[1].Children[1].Name, 'C')
        self.assertEqual(tree_unesc.Children[2].Name, 'D_e')
        self.assertEqual(tree_unesc.Children[2].Length, 0.5)

        self.assertEqual(tree_esc.Name, 'E')
        self.assertEqual(tree_esc.Children[0].Name, 'A_a')
        self.assertEqual(tree_esc.Children[1].Children[0].Name, 'B')
        self.assertEqual(tree_esc.Children[1].Children[0].Length, 1.0)
        self.assertEqual(tree_esc.Children[1].Children[1].Name, 'C')
        self.assertEqual(tree_esc.Children[2].Name, "'D_e'")
        self.assertEqual(tree_esc.Children[2].Length, 0.5)

        reload_test = tree_esc.getNewick(with_distances=True, \
                                         escape_name=False)
        obs = DndParser(reload_test, unescape_name=False)
        self.assertEqual(obs.getNewick(with_distances=True), \
                         tree_esc.getNewick(with_distances=True))
        reload_test = tree_unesc.getNewick(with_distances=True, \
                                           escape_name=False)
        obs = DndParser(reload_test, unescape_name=False)
        self.assertEqual(obs.getNewick(with_distances=True), \
                         tree_unesc.getNewick(with_distances=True))
开发者ID:GavinHuttley,项目名称:pycogent,代码行数:34,代码来源:test_tree.py

示例2: test_getsubtree

# 需要导入模块: from cogent.parse.tree import DndParser [as 别名]
# 或者: from cogent.parse.tree.DndParser import getNewick [as 别名]
    def test_getsubtree(self):
        """testing getting a subtree
        """
        otu_names = ['NineBande', 'Mouse', 'HowlerMon', 'DogFaced']
        newick = '(((Human,HowlerMon),Mouse),NineBande,DogFaced);'
        newick_reduced = '((Mouse,HowlerMon),NineBande,DogFaced);'
        tree = DndParser(newick, constructor = PicrustNode) 

        subtree = tree.getSubTree(otu_names)
        new_tree = DndParser(newick_reduced, constructor = PicrustNode)       
        # check we get the same names
        self.assertEqual(*[len(t.Children) for t in (subtree,new_tree)])
        self.assertEqual(subtree.getNewick(), new_tree.getNewick())
开发者ID:cleme,项目名称:picrust,代码行数:15,代码来源:test_util.py

示例3: test_join_nodes

# 需要导入模块: from cogent.parse.tree import DndParser [as 别名]
# 或者: from cogent.parse.tree.DndParser import getNewick [as 别名]
    def test_join_nodes(self):
        """join them nodes! (((99 + 97) + 94) + 91) + ..."""
        parsed = [make_nodes(self.clst_99, 0.01, 99),
                  make_nodes(self.clst_97, 0.02, 97),
                  make_nodes(self.clst_94, 0.03, 94)]

        exp = """((((3:.005)99_2_3:.01,(8:.005,7:.005)99_3_8:.01)97_0_3:.015)94_0_3,
                 (((1:.005,6:.005)99_1_1:.01)97_1_1:.015,
                 ((10:.005,20:.005,30:.005)99_0_10:.01)97_2_10:.015)94_1_1);"""
        expt = DndParser(exp)
        obs = join_nodes(parsed)

        self.assertEqual(obs.getNewick(with_distances=True),
                         expt.getNewick(with_distances=True))
开发者ID:infotroph,项目名称:nested_reference_otus,代码行数:16,代码来源:test_unnest.py

示例4: test_commonname_promotion

# 需要导入模块: from cogent.parse.tree import DndParser [as 别名]
# 或者: from cogent.parse.tree.DndParser import getNewick [as 别名]
 def test_commonname_promotion(self):
     """correctly promote names if possible"""
     consensus_tree = DndParser("(((s1,s2)g1,(s3,s4)g2,(s5,s6)g3)f1)o1;")
     rank_lookup = {'s':6,'g':5,'f':4,'o':3,'c':2,'p':1,'k':0}
     for n in consensus_tree.traverse(include_self=True):
         n.Rank = rank_lookup[n.Name[0]]
     input = "((((1)s1,(2)s2),((3)s3,(4)s5)))o1;"
     lookup = dict([(n.Name, n) for n in consensus_tree.traverse(include_self=True)])
     exp = "((((1)s1,(2)s2)g1,((3)'g2; s3',(4)'g3; s5')))'o1; f1';"
     t = DndParser(input)
     t.Rank = 3
     t.Children[0].Rank = None
     t.Children[0].Children[0].Rank = None
     t.Children[0].Children[1].Rank = None
     t.Children[0].Children[0].Children[0].Rank = 6
     t.Children[0].Children[0].Children[1].Rank = 6
     t.Children[0].Children[1].Children[0].Rank = 6
     t.Children[0].Children[1].Children[1].Rank = 6
     backfill_names_gap(t, lookup)
     commonname_promotion(t)
     self.assertEqual(t.getNewick(with_distances=False), exp)
开发者ID:teravest,项目名称:tax2tree,代码行数:23,代码来源:test_nlevel.py

示例5: test_make_tree_arb_safe

# 需要导入模块: from cogent.parse.tree import DndParser [as 别名]
# 或者: from cogent.parse.tree.DndParser import getNewick [as 别名]
 def test_make_tree_arb_safe(self):
     """ARB can't handle single descendent nodes"""
     t = DndParser("(((((a)b)c)d)e)f;", constructor=RangeNode)
     exp = "(((((a,X)b,X)c,X)d,X)e,X)f;"
     make_tree_arb_safe(t)
     self.assertEqual(t.getNewick(), exp)
开发者ID:greengenes,项目名称:Greengenes,代码行数:8,代码来源:test_util.py


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