本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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)