diff --git a/q2_amr/amrfinderplus/types/__init__.py b/q2_amr/amrfinderplus/types/__init__.py index 19b7008..31ef4ea 100644 --- a/q2_amr/amrfinderplus/types/__init__.py +++ b/q2_amr/amrfinderplus/types/__init__.py @@ -5,5 +5,14 @@ # # The full license is in the file LICENSE, distributed with this software. # ---------------------------------------------------------------------------- +from q2_amr.amrfinderplus.types._format import ( + AMRFinderPlusDatabaseDirectoryFormat, + BinaryFormat, + TextFormat, +) -__all__ = [] +__all__ = [ + "AMRFinderPlusDatabaseDirectoryFormat", + "TextFormat", + "BinaryFormat", +] diff --git a/q2_amr/amrfinderplus/types/_format.py b/q2_amr/amrfinderplus/types/_format.py index bc9c3d2..a1b6f67 100644 --- a/q2_amr/amrfinderplus/types/_format.py +++ b/q2_amr/amrfinderplus/types/_format.py @@ -5,3 +5,38 @@ # # The full license is in the file LICENSE, distributed with this software. # ---------------------------------------------------------------------------- +from q2_types.feature_data import MixedCaseDNAFASTAFormat, ProteinFASTAFormat +from qiime2.plugin import model + + +class TextFormat(model.TextFileFormat): + def _validate_(self, level): + pass + + +class BinaryFormat(model.BinaryFileFormat): + def _validate_(self, level): + pass + + +class AMRFinderPlusDatabaseDirectoryFormat(model.DirectoryFormat): + AMR_LIB = model.File("AMR.LIB", format=TextFormat) + AMR_LIB_comp = model.FileCollection(r"AMR\.LIB\.h3.$", format=BinaryFormat) + AMRProt = model.File("AMRProt", format=ProteinFASTAFormat) + AMRProt_blast = model.FileCollection(r"AMRProt\.p..$", format=BinaryFormat) + AMRProt_mutation = model.File("AMRProt-mutation.tab", format=TextFormat) + AMRProt_suppress = model.File("AMRProt-suppress", format=TextFormat) + AMRProt_susceptible = model.File("AMRProt-susceptible.tab", format=TextFormat) + changes = model.File("changes.txt", format=TextFormat) + db_version = model.File("database_format_version.txt", format=TextFormat) + fam = model.File("fam.tab", format=TextFormat) + taxgroup = model.File("taxgroup.tab", format=TextFormat) + version = model.File("version.txt", format=TextFormat) + AMR_DNA = model.FileCollection( + r"^AMR_DNA-[a-zA-Z_]+$", format=MixedCaseDNAFASTAFormat + ) + AMR_DNA_comp = model.FileCollection( + r"^AMR_DNA-[a-zA-Z_]+\.n..$", format=BinaryFormat + ) + AMR_CDS_comp = model.FileCollection(r"^AMR_CDS\.n..$", format=BinaryFormat) + AMR_CDS = model.File("AMR_CDS", format=MixedCaseDNAFASTAFormat) diff --git a/q2_amr/amrfinderplus/types/tests/test_types_formats_transformers.py b/q2_amr/amrfinderplus/types/tests/test_types_formats_transformers.py index bc9c3d2..ea15625 100644 --- a/q2_amr/amrfinderplus/types/tests/test_types_formats_transformers.py +++ b/q2_amr/amrfinderplus/types/tests/test_types_formats_transformers.py @@ -5,3 +5,16 @@ # # The full license is in the file LICENSE, distributed with this software. # ---------------------------------------------------------------------------- +from qiime2.plugin.testing import TestPluginBase + +from q2_amr.amrfinderplus.types._format import AMRFinderPlusDatabaseDirectoryFormat + + +class TestAMRFinderPlusDatabaseTypesAndFormats(TestPluginBase): + package = "q2_amr.amrfinderplus.types.tests" + + def test_amrfinderplus_database_directory_format_validate_positive(self): + format = AMRFinderPlusDatabaseDirectoryFormat( + "/Users/rischv/Documents/data/amrfinder/database", mode="r" + ) + format.validate() diff --git a/q2_amr/plugin_setup.py b/q2_amr/plugin_setup.py index 00ac3f5..6f12790 100644 --- a/q2_amr/plugin_setup.py +++ b/q2_amr/plugin_setup.py @@ -28,6 +28,12 @@ from qiime2.plugin import Citations, Plugin from q2_amr import __version__ +from q2_amr.amrfinderplus.types._format import ( + AMRFinderPlusDatabaseDirectoryFormat, + BinaryFormat, + TextFormat, +) +from q2_amr.amrfinderplus.types._type import AMRFinderPlusDatabase from q2_amr.card.database import fetch_card_db from q2_amr.card.heatmap import heatmap from q2_amr.card.mags import annotate_mags_card @@ -468,6 +474,7 @@ CARDReadsGeneKmerAnalysis, CARDReadsAlleleKmerAnalysis, CARDMAGsKmerAnalysis, + AMRFinderPlusDatabase, ) plugin.register_semantic_type_to_format( @@ -498,6 +505,10 @@ SampleData[CARDMAGsKmerAnalysis], artifact_format=CARDMAGsKmerAnalysisDirectoryFormat, ) +plugin.register_semantic_type_to_format( + AMRFinderPlusDatabase, + artifact_format=AMRFinderPlusDatabaseDirectoryFormat, +) plugin.register_formats( CARDKmerDatabaseDirectoryFormat, CARDKmerJSONFormat, @@ -522,6 +533,9 @@ CARDReadsKmerAnalysisJSONFormat, CARDReadsGeneKmerAnalysisDirectoryFormat, CARDReadsAlleleKmerAnalysisDirectoryFormat, + AMRFinderPlusDatabaseDirectoryFormat, + TextFormat, + BinaryFormat, ) importlib.import_module("q2_amr.card.types._transformer")