TreeNode.
to_taxonomy
(allow_empty=False, filter_f=None)[source]¶Returns a taxonomy representation of self
State: Experimental as of 0.4.0.
Parameters: |
|
---|---|
Yields: | tuple – |
Notes
If allow_empty
is True
and the root node does not have a name,
then that name will not be included. This is because it is common to
have multiple domains represented in the taxonomy, which would result
in a root node that does not have a name and does not make sense to
represent in the output.
Examples
>>> from skbio.tree import TreeNode
>>> lineages = {'1': ['Bacteria', 'Firmicutes', 'Clostridia'],
... '2': ['Bacteria', 'Firmicutes', 'Bacilli'],
... '3': ['Bacteria', 'Bacteroidetes', 'Sphingobacteria'],
... '4': ['Archaea', 'Euryarchaeota', 'Thermoplasmata'],
... '5': ['Archaea', 'Euryarchaeota', 'Thermoplasmata'],
... '6': ['Archaea', 'Euryarchaeota', 'Halobacteria'],
... '7': ['Archaea', 'Euryarchaeota', 'Halobacteria'],
... '8': ['Bacteria', 'Bacteroidetes', 'Sphingobacteria'],
... '9': ['Bacteria', 'Bacteroidetes', 'Cytophagia']}
>>> tree = TreeNode.from_taxonomy(lineages.items())
>>> lineages = sorted([(n.name, l) for n, l in tree.to_taxonomy()])
>>> for name, lineage in lineages:
... print(name, '; '.join(lineage))
1 Bacteria; Firmicutes; Clostridia
2 Bacteria; Firmicutes; Bacilli
3 Bacteria; Bacteroidetes; Sphingobacteria
4 Archaea; Euryarchaeota; Thermoplasmata
5 Archaea; Euryarchaeota; Thermoplasmata
6 Archaea; Euryarchaeota; Halobacteria
7 Archaea; Euryarchaeota; Halobacteria
8 Bacteria; Bacteroidetes; Sphingobacteria
9 Bacteria; Bacteroidetes; Cytophagia