diff --git a/q2_types/tree/__init__.py b/q2_types/tree/__init__.py index 34bdbb68..532a7b51 100644 --- a/q2_types/tree/__init__.py +++ b/q2_types/tree/__init__.py @@ -9,9 +9,10 @@ import importlib from ._format import NewickFormat, NewickDirectoryFormat -from ._type import Phylogeny, Rooted, Unrooted +from ._type import Phylogeny, Rooted, Unrooted, Hierarchy __all__ = [ - 'NewickFormat', 'NewickDirectoryFormat', 'Phylogeny', 'Rooted', 'Unrooted'] + 'NewickFormat', 'NewickDirectoryFormat', 'Phylogeny', + 'Rooted', 'Unrooted', 'Hierarchy'] importlib.import_module('q2_types.tree._transformer') diff --git a/q2_types/tree/_type.py b/q2_types/tree/_type.py index 0230cf65..095069a4 100644 --- a/q2_types/tree/_type.py +++ b/q2_types/tree/_type.py @@ -18,7 +18,12 @@ Unrooted = SemanticType('Unrooted', variant_of=Phylogeny.field['type']) -plugin.register_semantic_types(Phylogeny, Rooted, Unrooted) +Hierarchy = SemanticType('Hierarchy') + +plugin.register_semantic_types(Phylogeny, Rooted, Unrooted, Hierarchy) plugin.register_semantic_type_to_format(Phylogeny[Rooted | Unrooted], artifact_format=NewickDirectoryFormat) + +plugin.register_semantic_type_to_format(Hierarchy, + artifact_format=NewickDirectoryFormat) diff --git a/q2_types/tree/tests/test_type.py b/q2_types/tree/tests/test_type.py index fe7976b7..55a20b9e 100644 --- a/q2_types/tree/tests/test_type.py +++ b/q2_types/tree/tests/test_type.py @@ -8,7 +8,8 @@ import unittest -from q2_types.tree import Phylogeny, Rooted, Unrooted, NewickDirectoryFormat +from q2_types.tree import (Phylogeny, Rooted, Unrooted, + Hierarchy, NewickDirectoryFormat) from qiime2.plugin.testing import TestPluginBase @@ -24,10 +25,17 @@ def test_rooted_semantic_type_registration(self): def test_unrooted_semantic_type_registration(self): self.assertRegisteredSemanticType(Unrooted) + def test_hierarchy_semantic_type_registration(self): + self.assertRegisteredSemanticType(Hierarchy) + def test_phylogeny_rooted_unrooted_to_newick_dir_fmt_registration(self): self.assertSemanticTypeRegisteredToFormat( Phylogeny[Rooted | Unrooted], NewickDirectoryFormat) + def test_hierarchy_to_newick_dir_fmt_registration(self): + self.assertSemanticTypeRegisteredToFormat( + Hierarchy, NewickDirectoryFormat) + if __name__ == '__main__': unittest.main()