diff --git a/q2_types/__init__.py b/q2_types/__init__.py index 58f25f57..9c9bb0ab 100644 --- a/q2_types/__init__.py +++ b/q2_types/__init__.py @@ -6,11 +6,7 @@ # The full license is in the file LICENSE, distributed with this software. # ---------------------------------------------------------------------------- -import importlib - from ._version import get_versions __version__ = get_versions()['version'] del get_versions - -importlib.import_module('q2_types.tree') diff --git a/q2_types/plugin_setup.py b/q2_types/plugin_setup.py index b9ecee53..e8474987 100644 --- a/q2_types/plugin_setup.py +++ b/q2_types/plugin_setup.py @@ -44,3 +44,4 @@ importlib.import_module('q2_types.profile_hmms._deferred_setup') importlib.import_module('q2_types.reference_db._deferred_setup') importlib.import_module('q2_types.sample_data._deferred_setup') +importlib.import_module('q2_types.tree._deferred_setup') diff --git a/q2_types/tree/__init__.py b/q2_types/tree/__init__.py index 804e1a0c..4e868e8c 100644 --- a/q2_types/tree/__init__.py +++ b/q2_types/tree/__init__.py @@ -5,14 +5,9 @@ # # The full license is in the file LICENSE, distributed with this software. # ---------------------------------------------------------------------------- - -import importlib - -from ._format import NewickFormat, NewickDirectoryFormat -from ._type import Phylogeny, Rooted, Unrooted, Hierarchy +from ._formats import NewickFormat, NewickDirectoryFormat +from ._types import Phylogeny, Rooted, Unrooted, Hierarchy __all__ = [ '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/_deferred_setup/__init__.py similarity index 81% rename from q2_types/tree/_type.py rename to q2_types/tree/_deferred_setup/__init__.py index 03eaa270..7e2dec14 100644 --- a/q2_types/tree/_type.py +++ b/q2_types/tree/_deferred_setup/__init__.py @@ -6,23 +6,19 @@ # The full license is in the file LICENSE, distributed with this software. # ---------------------------------------------------------------------------- +import importlib from io import StringIO from skbio import TreeNode -from qiime2.plugin import SemanticType from qiime2.plugin.util import transform -from ..plugin_setup import plugin -from . import NewickDirectoryFormat +from .. import (NewickFormat, NewickDirectoryFormat, + Phylogeny, Rooted, Unrooted, Hierarchy) -Phylogeny = SemanticType('Phylogeny', field_names=['type']) +from ...plugin_setup import plugin -Rooted = SemanticType('Rooted', variant_of=Phylogeny.field['type']) - -Unrooted = SemanticType('Unrooted', variant_of=Phylogeny.field['type']) - -Hierarchy = SemanticType('Hierarchy') +plugin.register_formats(NewickFormat, NewickDirectoryFormat) plugin.register_semantic_types(Phylogeny, Rooted, Unrooted, Hierarchy) @@ -57,3 +53,5 @@ def factory(): plugin.register_artifact_class(Hierarchy, directory_format=NewickDirectoryFormat) + +importlib.import_module('._transformers', __name__) diff --git a/q2_types/tree/_transformer.py b/q2_types/tree/_deferred_setup/_transformers.py similarity index 91% rename from q2_types/tree/_transformer.py rename to q2_types/tree/_deferred_setup/_transformers.py index da1cb4b2..da5c2684 100644 --- a/q2_types/tree/_transformer.py +++ b/q2_types/tree/_deferred_setup/_transformers.py @@ -8,8 +8,9 @@ import skbio -from ..plugin_setup import plugin -from . import NewickFormat +from .. import NewickFormat + +from ...plugin_setup import plugin @plugin.register_transformer diff --git a/q2_types/tree/_format.py b/q2_types/tree/_formats.py similarity index 87% rename from q2_types/tree/_format.py rename to q2_types/tree/_formats.py index 5d5f69f1..676e9562 100644 --- a/q2_types/tree/_format.py +++ b/q2_types/tree/_formats.py @@ -5,12 +5,9 @@ # # The full license is in the file LICENSE, distributed with this software. # ---------------------------------------------------------------------------- - import skbio.io import qiime2.plugin.model as model -from ..plugin_setup import plugin - class NewickFormat(model.TextFileFormat): def sniff(self): @@ -20,6 +17,3 @@ def sniff(self): NewickDirectoryFormat = model.SingleFileDirectoryFormat( 'NewickDirectoryFormat', 'tree.nwk', NewickFormat) - - -plugin.register_formats(NewickFormat, NewickDirectoryFormat) diff --git a/q2_types/tree/_types.py b/q2_types/tree/_types.py new file mode 100644 index 00000000..33854e9f --- /dev/null +++ b/q2_types/tree/_types.py @@ -0,0 +1,17 @@ +# ---------------------------------------------------------------------------- +# Copyright (c) 2016-2023, QIIME 2 development team. +# +# Distributed under the terms of the Modified BSD License. +# +# The full license is in the file LICENSE, distributed with this software. +# ---------------------------------------------------------------------------- +from qiime2.plugin import SemanticType + + +Phylogeny = SemanticType('Phylogeny', field_names=['type']) + +Rooted = SemanticType('Rooted', variant_of=Phylogeny.field['type']) + +Unrooted = SemanticType('Unrooted', variant_of=Phylogeny.field['type']) + +Hierarchy = SemanticType('Hierarchy')