Skip to content

Commit

Permalink
ENH: add FeatureData[Contig] type (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
misialq authored Mar 13, 2024
1 parent b21fb99 commit f5bce08
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions q2_types/feature_data_mag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
OrthologFileFmt
)

from ._type import MAG, NOG, OG, KEGG
from ._type import MAG, NOG, OG, KEGG, Contig
from ._transformer import MAGIterator

__all__ = [
'MAG', 'MAGSequencesDirFmt', 'MAGIterator', 'NOG', 'OG', 'KEGG',
'OrthologAnnotationDirFmt', 'OrthologFileFmt',
'OrthologAnnotationDirFmt', 'OrthologFileFmt', 'Contig'
]

importlib.import_module('q2_types.feature_data._format')
Expand Down
9 changes: 9 additions & 0 deletions q2_types/feature_data_mag/_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
)
from qiime2.core.type import SemanticType

from ..per_sample_sequences import ContigSequencesDirFmt
from ..plugin_setup import plugin


Expand All @@ -24,6 +25,14 @@
artifact_format=MAGSequencesDirFmt
)

Contig = SemanticType('Contig', variant_of=FeatureData.field['type'])

plugin.register_semantic_types(Contig)
plugin.register_semantic_type_to_format(
FeatureData[Contig],
artifact_format=ContigSequencesDirFmt
)

NOG = SemanticType('NOG', variant_of=FeatureData.field['type'])

plugin.register_semantic_types(NOG)
Expand Down
15 changes: 13 additions & 2 deletions q2_types/feature_data_mag/tests/test_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
from qiime2.plugin.testing import TestPluginBase

from q2_types.feature_data_mag import (
MAG, MAGSequencesDirFmt, OrthologAnnotationDirFmt, NOG, OG, KEGG,
)
MAG, MAGSequencesDirFmt, OrthologAnnotationDirFmt,
NOG, OG, KEGG, Contig
)
from q2_types.per_sample_sequences import ContigSequencesDirFmt


class TestTypes(TestPluginBase):
Expand All @@ -28,6 +30,15 @@ def test_mags_semantic_type_to_format_registration(self):
MAGSequencesDirFmt
)

def test_contig_semantic_type_registration(self):
self.assertRegisteredSemanticType(Contig)

def test_contig_semantic_type_to_format_registration(self):
self.assertSemanticTypeRegisteredToFormat(
FeatureData[Contig],
ContigSequencesDirFmt
)

def test_nog_type_registration(self):
self.assertRegisteredSemanticType(NOG)

Expand Down

0 comments on commit f5bce08

Please sign in to comment.