diff --git a/q2_types/distance_matrix/_type.py b/q2_types/distance_matrix/_type.py index 2f5eb670..682c4e99 100644 --- a/q2_types/distance_matrix/_type.py +++ b/q2_types/distance_matrix/_type.py @@ -17,5 +17,5 @@ plugin.register_semantic_types(DistanceMatrix) plugin.register_semantic_type_to_format( DistanceMatrix, - artifact_format=DistanceMatrixDirectoryFormat + directory_format=DistanceMatrixDirectoryFormat ) diff --git a/q2_types/feature_data/_type.py b/q2_types/feature_data/_type.py index 3fa24c75..7cf88bc5 100644 --- a/q2_types/feature_data/_type.py +++ b/q2_types/feature_data/_type.py @@ -59,33 +59,33 @@ plugin.register_semantic_type_to_format( FeatureData[Taxonomy], - artifact_format=TSVTaxonomyDirectoryFormat) + directory_format=TSVTaxonomyDirectoryFormat) plugin.register_semantic_type_to_format( FeatureData[Sequence], - artifact_format=DNASequencesDirectoryFormat) + directory_format=DNASequencesDirectoryFormat) plugin.register_semantic_type_to_format( FeatureData[RNASequence], - artifact_format=RNASequencesDirectoryFormat) + directory_format=RNASequencesDirectoryFormat) plugin.register_semantic_type_to_format( FeatureData[PairedEndSequence], - artifact_format=PairedDNASequencesDirectoryFormat) + directory_format=PairedDNASequencesDirectoryFormat) plugin.register_semantic_type_to_format( FeatureData[PairedEndRNASequence], - artifact_format=PairedRNASequencesDirectoryFormat) + directory_format=PairedRNASequencesDirectoryFormat) plugin.register_semantic_type_to_format( FeatureData[AlignedSequence], - artifact_format=AlignedDNASequencesDirectoryFormat) + directory_format=AlignedDNASequencesDirectoryFormat) plugin.register_semantic_type_to_format( FeatureData[AlignedRNASequence], - artifact_format=AlignedRNASequencesDirectoryFormat) + directory_format=AlignedRNASequencesDirectoryFormat) plugin.register_semantic_type_to_format( FeatureData[Differential], DifferentialDirectoryFormat) plugin.register_semantic_type_to_format( FeatureData[ProteinSequence], - artifact_format=ProteinSequencesDirectoryFormat) + directory_format=ProteinSequencesDirectoryFormat) plugin.register_semantic_type_to_format( FeatureData[AlignedProteinSequence], - artifact_format=AlignedProteinSequencesDirectoryFormat) + directory_format=AlignedProteinSequencesDirectoryFormat) plugin.register_semantic_type_to_format( FeatureData[BLAST6], - artifact_format=BLAST6DirectoryFormat) + directory_format=BLAST6DirectoryFormat) diff --git a/q2_types/feature_table/_type.py b/q2_types/feature_table/_type.py index 3f0842ac..4ee2b995 100644 --- a/q2_types/feature_table/_type.py +++ b/q2_types/feature_table/_type.py @@ -43,5 +43,5 @@ FeatureTable[Frequency | RelativeFrequency | PresenceAbsence | Balance | Composition | PercentileNormalized | Design], - artifact_format=BIOMV210DirFmt + directory_format=BIOMV210DirFmt ) diff --git a/q2_types/feature_table/tests/test_type.py b/q2_types/feature_table/tests/test_type.py index a6b9b0ea..f8d51d45 100644 --- a/q2_types/feature_table/tests/test_type.py +++ b/q2_types/feature_table/tests/test_type.py @@ -38,9 +38,25 @@ def test_balance_semantic_type_registration(self): def test_feature_table_semantic_type_to_v210_format_registration(self): self.assertSemanticTypeRegisteredToFormat( - FeatureTable[Frequency | RelativeFrequency | PresenceAbsence | - Composition | Balance | PercentileNormalized | - Design], + FeatureTable[Frequency], + BIOMV210DirFmt) + self.assertSemanticTypeRegisteredToFormat( + FeatureTable[RelativeFrequency], + BIOMV210DirFmt) + self.assertSemanticTypeRegisteredToFormat( + FeatureTable[PresenceAbsence], + BIOMV210DirFmt) + self.assertSemanticTypeRegisteredToFormat( + FeatureTable[Composition], + BIOMV210DirFmt) + self.assertSemanticTypeRegisteredToFormat( + FeatureTable[Balance], + BIOMV210DirFmt) + self.assertSemanticTypeRegisteredToFormat( + FeatureTable[PercentileNormalized], + BIOMV210DirFmt) + self.assertSemanticTypeRegisteredToFormat( + FeatureTable[Design], BIOMV210DirFmt) diff --git a/q2_types/multiplexed_sequences/_type.py b/q2_types/multiplexed_sequences/_type.py index 05e8ec7d..fda90dd3 100644 --- a/q2_types/multiplexed_sequences/_type.py +++ b/q2_types/multiplexed_sequences/_type.py @@ -23,9 +23,9 @@ plugin.register_semantic_type_to_format( MultiplexedSingleEndBarcodeInSequence, - artifact_format=MultiplexedSingleEndBarcodeInSequenceDirFmt + directory_format=MultiplexedSingleEndBarcodeInSequenceDirFmt ) plugin.register_semantic_type_to_format( MultiplexedPairedEndBarcodeInSequence, - artifact_format=MultiplexedPairedEndBarcodeInSequenceDirFmt, + directory_format=MultiplexedPairedEndBarcodeInSequenceDirFmt, ) diff --git a/q2_types/ordination/_type.py b/q2_types/ordination/_type.py index f26af7e4..a71c1fc6 100644 --- a/q2_types/ordination/_type.py +++ b/q2_types/ordination/_type.py @@ -19,11 +19,11 @@ plugin.register_semantic_types(PCoAResults, ProcrustesStatistics) plugin.register_semantic_type_to_format( PCoAResults, - artifact_format=OrdinationDirectoryFormat + directory_format=OrdinationDirectoryFormat ) plugin.register_semantic_type_to_format( ProcrustesStatistics, - artifact_format=ProcrustesStatisticsDirFmt + directory_format=ProcrustesStatisticsDirFmt ) diff --git a/q2_types/per_sample_sequences/_type.py b/q2_types/per_sample_sequences/_type.py index 52fde8a9..1297b661 100644 --- a/q2_types/per_sample_sequences/_type.py +++ b/q2_types/per_sample_sequences/_type.py @@ -26,19 +26,29 @@ PairedEndSequencesWithQuality, JoinedSequencesWithQuality) -plugin.register_semantic_type_to_format( +plugin.register_artifact_class( SampleData[Sequences], - artifact_format=QIIME1DemuxDirFmt + directory_format=QIIME1DemuxDirFmt, + description=("Collections of sequences associated with specified samples " + "(i.e., demultiplexed sequences).") ) -plugin.register_semantic_type_to_format( +plugin.register_artifact_class( SampleData[SequencesWithQuality], - artifact_format=SingleLanePerSampleSingleEndFastqDirFmt + directory_format=SingleLanePerSampleSingleEndFastqDirFmt, + description=("Collections of sequences with quality scores associated " + "with specified samples (i.e., demultiplexed sequences).") ) -plugin.register_semantic_type_to_format( +plugin.register_artifact_class( SampleData[JoinedSequencesWithQuality], - artifact_format=SingleLanePerSampleSingleEndFastqDirFmt + directory_format=SingleLanePerSampleSingleEndFastqDirFmt, + description=("Collections of joined paired-end sequences with quality " + "scores associated with specified samples (i.e., " + "demultiplexed sequences).") ) -plugin.register_semantic_type_to_format( +plugin.register_artifact_class( SampleData[PairedEndSequencesWithQuality], - artifact_format=SingleLanePerSamplePairedEndFastqDirFmt + directory_format=SingleLanePerSamplePairedEndFastqDirFmt, + description=("Collections of unjoined paired-end sequences with quality " + "scores associated with specified samples (i.e., " + "demultiplexed sequences).") ) diff --git a/q2_types/sample_data/_type.py b/q2_types/sample_data/_type.py index e75060a0..ca06789e 100644 --- a/q2_types/sample_data/_type.py +++ b/q2_types/sample_data/_type.py @@ -21,5 +21,5 @@ plugin.register_semantic_type_to_format( SampleData[AlphaDiversity], - artifact_format=AlphaDiversityDirectoryFormat + directory_format=AlphaDiversityDirectoryFormat ) diff --git a/q2_types/tree/_type.py b/q2_types/tree/_type.py index 28e41d45..0ab94e82 100644 --- a/q2_types/tree/_type.py +++ b/q2_types/tree/_type.py @@ -6,12 +6,16 @@ # The full license is in the file LICENSE, distributed with this software. # ---------------------------------------------------------------------------- +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 - Phylogeny = SemanticType('Phylogeny', field_names=['type']) Rooted = SemanticType('Rooted', variant_of=Phylogeny.field['type']) @@ -22,8 +26,34 @@ plugin.register_semantic_types(Phylogeny, Rooted, Unrooted, Hierarchy) -plugin.register_semantic_type_to_format(Phylogeny[Rooted | Unrooted], - artifact_format=NewickDirectoryFormat) +plugin.register_artifact_class( + Phylogeny[Unrooted], NewickDirectoryFormat, + "A phylogenetic tree not containing a defined root.") + + +# Phylogeny[Rooted] import usage example +def phylogeny_rooted_usage(use): + def factory(): + from q2_types.tree import NewickFormat + + tree = TreeNode.read(StringIO( + '(SEQUENCE1:0.000000003,SEQUENCE2:0.000000003);')) + ff = transform(tree, to_type=NewickFormat) + ff.validate() + return ff + + to_import = use.init_format('my-tree', factory, ext='.tre') + + use.import_from_format('tree', + semantic_type='Phylogeny[Rooted]', + variable=to_import, + view_type='NewickFormat') + + +plugin.register_artifact_class( + Phylogeny[Rooted], NewickDirectoryFormat, + "A phylogenetic tree containing a defined root.", + examples={'Import rooted phylogenetic tree': phylogeny_rooted_usage}) plugin.register_semantic_type_to_format(Hierarchy, - artifact_format=NewickDirectoryFormat) + directory_format=NewickDirectoryFormat) diff --git a/q2_types/tree/tests/test_type.py b/q2_types/tree/tests/test_type.py index 78656381..8e2c2ab3 100644 --- a/q2_types/tree/tests/test_type.py +++ b/q2_types/tree/tests/test_type.py @@ -30,7 +30,9 @@ def test_hierarchy_semantic_type_registration(self): def test_phylogeny_rooted_unrooted_to_newick_dir_fmt_registration(self): self.assertSemanticTypeRegisteredToFormat( - Phylogeny[Rooted | Unrooted], NewickDirectoryFormat) + Phylogeny[Rooted], NewickDirectoryFormat) + self.assertSemanticTypeRegisteredToFormat( + Phylogeny[Unrooted], NewickDirectoryFormat) def test_hierarchy_to_newick_dir_fmt_registration(self): self.assertSemanticTypeRegisteredToFormat(