From f5e1bac0bcde3332b484971fd69b2bd1a1ec18e0 Mon Sep 17 00:00:00 2001 From: VinzentRisch Date: Fri, 19 Jul 2024 13:53:03 +0200 Subject: [PATCH 1/2] added new type normalized --- q2_types/feature_table/__init__.py | 4 ++-- q2_types/feature_table/_type.py | 9 ++++++++- q2_types/feature_table/tests/test_type.py | 9 +++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/q2_types/feature_table/__init__.py b/q2_types/feature_table/__init__.py index b94d1b6a..2443ba41 100644 --- a/q2_types/feature_table/__init__.py +++ b/q2_types/feature_table/__init__.py @@ -12,11 +12,11 @@ BIOMV210DirFmt) from ._type import (FeatureTable, Frequency, RelativeFrequency, PresenceAbsence, Composition, Balance, - PercentileNormalized, Design) + PercentileNormalized, Design, Normalized) __all__ = ['BIOMV100Format', 'BIOMV100DirFmt', 'FeatureTable', 'Frequency', 'RelativeFrequency', 'PresenceAbsence', 'BIOMV210Format', 'BIOMV210DirFmt', 'Composition', 'Balance', 'PercentileNormalized', - 'Design'] + 'Design', "Normalized"] importlib.import_module('q2_types.feature_table._transformer') diff --git a/q2_types/feature_table/_type.py b/q2_types/feature_table/_type.py index eab66f42..5cb72625 100644 --- a/q2_types/feature_table/_type.py +++ b/q2_types/feature_table/_type.py @@ -35,9 +35,11 @@ # been transformed/coded. Design = SemanticType('Design', variant_of=FeatureTable.field['content']) +Normalized = SemanticType('Normalized', variant_of=FeatureTable.field['content']) + plugin.register_semantic_types(FeatureTable, Frequency, RelativeFrequency, PresenceAbsence, Balance, Composition, - PercentileNormalized, Design) + PercentileNormalized, Design, Normalized) plugin.register_artifact_class( FeatureTable[Frequency], @@ -86,3 +88,8 @@ FeatureTable[Design], directory_format=BIOMV210DirFmt ) +plugin.register_artifact_class( + FeatureTable[Normalized], + directory_format=BIOMV210DirFmt, + description="A feature table that was normalized." +) diff --git a/q2_types/feature_table/tests/test_type.py b/q2_types/feature_table/tests/test_type.py index 2a4c5603..41946eef 100644 --- a/q2_types/feature_table/tests/test_type.py +++ b/q2_types/feature_table/tests/test_type.py @@ -11,7 +11,7 @@ from q2_types.feature_table import (FeatureTable, Frequency, RelativeFrequency, PercentileNormalized, Composition, Balance, - PresenceAbsence, BIOMV210DirFmt, Design) + PresenceAbsence, BIOMV210DirFmt, Design, Normalized) from qiime2.plugin.testing import TestPluginBase @@ -36,6 +36,9 @@ def test_composition_semantic_type_registration(self): def test_balance_semantic_type_registration(self): self.assertRegisteredSemanticType(Balance) + def test_normalized_semantic_type_registration(self): + self.assertRegisteredSemanticType(Normalized) + def test_feature_table_semantic_type_to_v210_format_registration(self): self.assertSemanticTypeRegisteredToFormat( FeatureTable[Frequency], @@ -58,7 +61,9 @@ def test_feature_table_semantic_type_to_v210_format_registration(self): self.assertSemanticTypeRegisteredToFormat( FeatureTable[Design], BIOMV210DirFmt) - + self.assertSemanticTypeRegisteredToFormat( + FeatureTable[Normalized], + BIOMV210DirFmt) if __name__ == "__main__": unittest.main() From 8018da5b17a36019b350851c366026a41f2283b4 Mon Sep 17 00:00:00 2001 From: VinzentRisch Date: Fri, 19 Jul 2024 14:09:03 +0200 Subject: [PATCH 2/2] lint --- q2_types/feature_table/_type.py | 3 ++- q2_types/feature_table/tests/test_type.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/q2_types/feature_table/_type.py b/q2_types/feature_table/_type.py index 5cb72625..c8de1a0b 100644 --- a/q2_types/feature_table/_type.py +++ b/q2_types/feature_table/_type.py @@ -35,7 +35,8 @@ # been transformed/coded. Design = SemanticType('Design', variant_of=FeatureTable.field['content']) -Normalized = SemanticType('Normalized', variant_of=FeatureTable.field['content']) +Normalized = SemanticType('Normalized', + variant_of=FeatureTable.field['content']) plugin.register_semantic_types(FeatureTable, Frequency, RelativeFrequency, PresenceAbsence, Balance, Composition, diff --git a/q2_types/feature_table/tests/test_type.py b/q2_types/feature_table/tests/test_type.py index 41946eef..8249fe02 100644 --- a/q2_types/feature_table/tests/test_type.py +++ b/q2_types/feature_table/tests/test_type.py @@ -11,7 +11,8 @@ from q2_types.feature_table import (FeatureTable, Frequency, RelativeFrequency, PercentileNormalized, Composition, Balance, - PresenceAbsence, BIOMV210DirFmt, Design, Normalized) + PresenceAbsence, BIOMV210DirFmt, Design, + Normalized) from qiime2.plugin.testing import TestPluginBase @@ -65,5 +66,6 @@ def test_feature_table_semantic_type_to_v210_format_registration(self): FeatureTable[Normalized], BIOMV210DirFmt) + if __name__ == "__main__": unittest.main()