Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions q2_types/tree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
7 changes: 6 additions & 1 deletion q2_types/tree/_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 9 additions & 1 deletion q2_types/tree/tests/test_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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()