Skip to content

Commit

Permalink
Merge 4e2f65b into e37a040
Browse files Browse the repository at this point in the history
  • Loading branch information
mortonjt committed Apr 8, 2017
2 parents e37a040 + 4e2f65b commit 06ff2b0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
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()

0 comments on commit 06ff2b0

Please sign in to comment.