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


Python TreeNode.from_taxonomy方法代码示例

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


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

示例1: test_to_taxonomy

# 需要导入模块: from skbio import TreeNode [as 别名]
# 或者: from skbio.TreeNode import from_taxonomy [as 别名]
 def test_to_taxonomy(self):
     input_lineages = {'1': ['a', 'b', 'c', 'd', 'e', 'f', 'g'],
                       '2': ['a', 'b', 'c', None, None, 'x', 'y'],
                       '3': ['h', 'i', 'j', 'k', 'l', 'm', 'n'],
                       '4': ['h', 'i', 'j', 'k', 'l', 'm', 'q'],
                       '5': ['h', 'i', 'j', 'k', 'l', 'm', 'n']}
     tree = TreeNode.from_taxonomy(input_lineages.items())
     exp = sorted(input_lineages.items())
     obs = [(n.name, lin) for n, lin in tree.to_taxonomy(allow_empty=True)]
     self.assertEqual(sorted(obs), exp)
开发者ID:anderspitman,项目名称:scikit-bio,代码行数:12,代码来源:test_tree.py

示例2: test_from_taxonomy

# 需要导入模块: from skbio import TreeNode [as 别名]
# 或者: from skbio.TreeNode import from_taxonomy [as 别名]
    def test_from_taxonomy(self):
        input_lineages = {'1': ['a', 'b', 'c', 'd', 'e', 'f', 'g'],
                          '2': ['a', 'b', 'c', None, None, 'x', 'y'],
                          '3': ['h', 'i', 'j', 'k', 'l', 'm', 'n'],
                          '4': ['h', 'i', 'j', 'k', 'l', 'm', 'q'],
                          '5': ['h', 'i', 'j', 'k', 'l', 'm', 'n']}
        exp = TreeNode.read(StringIO(u"((((((((1)g)f)e)d,((((2)y)x)))c)b)a,"
                                     "(((((((3,5)n,(4)q)m)l)k)j)i)h);"))

        root = TreeNode.from_taxonomy(input_lineages.items())

        self.assertEqual(root.compare_subsets(exp), 0.0)
开发者ID:jhcepas,项目名称:scikit-bio,代码行数:14,代码来源:test_tree.py

示例3: test_to_taxonomy

# 需要导入模块: from skbio import TreeNode [as 别名]
# 或者: from skbio.TreeNode import from_taxonomy [as 别名]
 def test_to_taxonomy(self):
     input_lineages = {
         "1": ["a", "b", "c", "d", "e", "f", "g"],
         "2": ["a", "b", "c", None, None, "x", "y"],
         "3": ["h", "i", "j", "k", "l", "m", "n"],
         "4": ["h", "i", "j", "k", "l", "m", "q"],
         "5": ["h", "i", "j", "k", "l", "m", "n"],
     }
     tree = TreeNode.from_taxonomy(input_lineages.items())
     exp = sorted(input_lineages.items())
     obs = [(n.name, lin) for n, lin in tree.to_taxonomy(allow_empty=True)]
     self.assertEqual(sorted(obs), exp)
开发者ID:ttimbers,项目名称:scikit-bio,代码行数:14,代码来源:test_tree.py

示例4: test_from_taxonomy

# 需要导入模块: from skbio import TreeNode [as 别名]
# 或者: from skbio.TreeNode import from_taxonomy [as 别名]
    def test_from_taxonomy(self):
        input_lineages = {
            "1": ["a", "b", "c", "d", "e", "f", "g"],
            "2": ["a", "b", "c", None, None, "x", "y"],
            "3": ["h", "i", "j", "k", "l", "m", "n"],
            "4": ["h", "i", "j", "k", "l", "m", "q"],
            "5": ["h", "i", "j", "k", "l", "m", "n"],
        }
        exp = TreeNode.read(StringIO(u"((((((((1)g)f)e)d,((((2)y)x)))c)b)a," "(((((((3,5)n,(4)q)m)l)k)j)i)h);"))

        root = TreeNode.from_taxonomy(input_lineages.items())

        self.assertEqual(root.compare_subsets(exp), 0.0)
开发者ID:ttimbers,项目名称:scikit-bio,代码行数:15,代码来源:test_tree.py

示例5: test_to_taxonomy_filter

# 需要导入模块: from skbio import TreeNode [as 别名]
# 或者: from skbio.TreeNode import from_taxonomy [as 别名]
    def test_to_taxonomy_filter(self):
        input_lineages = {'1': ['a', 'b', 'c', 'd', 'e', 'f', 'g'],
                          '2': ['a', 'b', 'c', None, None, 'x', 'y'],
                          '3': ['h', 'i', 'j', 'k', 'l'],  # test jagged
                          '4': ['h', 'i', 'j', 'k', 'l', 'm', 'q'],
                          '5': ['h', 'i', 'j', 'k', 'l', 'm', 'n']}
        tree = TreeNode.from_taxonomy(input_lineages.items())
        f = lambda node, lin: 'k' in lin or 'x' in lin

        exp = [('2', ['a', 'b', 'c', 'x', 'y']),
               ('3', ['h', 'i', 'j', 'k', 'l']),
               ('4', ['h', 'i', 'j', 'k', 'l', 'm', 'q']),
               ('5', ['h', 'i', 'j', 'k', 'l', 'm', 'n'])]
        obs = [(n.name, lin) for n, lin in tree.to_taxonomy(filter_f=f)]
        self.assertEqual(sorted(obs), exp)
开发者ID:cauyrd,项目名称:scikit-bio,代码行数:17,代码来源:test_tree.py

示例6: test_to_taxonomy_filter

# 需要导入模块: from skbio import TreeNode [as 别名]
# 或者: from skbio.TreeNode import from_taxonomy [as 别名]
    def test_to_taxonomy_filter(self):
        input_lineages = {
            "1": ["a", "b", "c", "d", "e", "f", "g"],
            "2": ["a", "b", "c", None, None, "x", "y"],
            "3": ["h", "i", "j", "k", "l"],  # test jagged
            "4": ["h", "i", "j", "k", "l", "m", "q"],
            "5": ["h", "i", "j", "k", "l", "m", "n"],
        }
        tree = TreeNode.from_taxonomy(input_lineages.items())

        def f(node, lin):
            return "k" in lin or "x" in lin

        exp = [
            ("2", ["a", "b", "c", "x", "y"]),
            ("3", ["h", "i", "j", "k", "l"]),
            ("4", ["h", "i", "j", "k", "l", "m", "q"]),
            ("5", ["h", "i", "j", "k", "l", "m", "n"]),
        ]
        obs = [(n.name, lin) for n, lin in tree.to_taxonomy(filter_f=f)]
        self.assertEqual(sorted(obs), exp)
开发者ID:ttimbers,项目名称:scikit-bio,代码行数:23,代码来源:test_tree.py


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