From b97cc18f166044063a07bc669f4db9a6be2369f4 Mon Sep 17 00:00:00 2001 From: Evan Molinelli Date: Mon, 2 Dec 2024 13:01:13 -0500 Subject: [PATCH] update raw values error to include requirement --- cellxgene_schema_cli/cellxgene_schema/validate.py | 11 ++++------- cellxgene_schema_cli/tests/test_schema_compliance.py | 9 +++++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cellxgene_schema_cli/cellxgene_schema/validate.py b/cellxgene_schema_cli/cellxgene_schema/validate.py index bf88cabf..7ce2d44a 100644 --- a/cellxgene_schema_cli/cellxgene_schema/validate.py +++ b/cellxgene_schema_cli/cellxgene_schema/validate.py @@ -36,15 +36,12 @@ CONDITION_IS_VISIUM_11M = f"'{ASSAY_VISIUM_11M} (Visium CytAssist Spatial Gene Expression, 11mm)" CONDITION_IS_SEQV2 = f"'{ASSAY_SLIDE_SEQV2}' (Slide-seqV2)" -CONDITION_IS_VISIUM = "a descendant of 'EFO:0010961' (Visium Spatial Gene Expression)" -CONDITION_IS_SEQV2 = f"'{ASSAY_SLIDE_SEQV2}' (Slide-seqV2)" - - ERROR_SUFFIX_SPATIAL = f"obs['assay_ontology_term_id'] is either {CONDITION_IS_VISIUM} or {CONDITION_IS_SEQV2}" ERROR_SUFFIX_VISIUM = f"obs['assay_ontology_term_id'] is {CONDITION_IS_VISIUM}" ERROR_SUFFIX_VISIUM_11M = f"obs['assay_ontology_term_id'] is {CONDITION_IS_VISIUM_11M}" -ERROR_SUFFIX_VISIUM_AND_IS_SINGLE_TRUE = f"{ERROR_SUFFIX_VISIUM} and uns['spatial']['is_single'] is True" +ERROR_SUFFIX_IS_SINGLE = "uns['spatial']['is_single'] is True" +ERROR_SUFFIX_VISIUM_AND_IS_SINGLE_TRUE = f"{ERROR_SUFFIX_VISIUM} and {ERROR_SUFFIX_IS_SINGLE}" ERROR_SUFFIX_VISIUM_AND_IS_SINGLE_TRUE_FORBIDDEN = f"is only allowed for {ERROR_SUFFIX_VISIUM_AND_IS_SINGLE_TRUE}" ERROR_SUFFIX_VISIUM_AND_IS_SINGLE_TRUE_REQUIRED = f"is required for {ERROR_SUFFIX_VISIUM_AND_IS_SINGLE_TRUE}" ERROR_SUFFIX_VISIUM_AND_IS_SINGLE_TRUE_IN_TISSUE_0 = f"{ERROR_SUFFIX_VISIUM_AND_IS_SINGLE_TRUE} and in_tissue is 0" @@ -99,10 +96,10 @@ def visium_and_is_single_true_matrix_size(self) -> Optional[int]: .apply(lambda t: is_ontological_descendant_of(ONTOLOGY_PARSER, t, ASSAY_VISIUM_11M, True)) .any() ): - self._visium_error_suffix = ERROR_SUFFIX_VISIUM_11M + self._visium_error_suffix = f"{ERROR_SUFFIX_VISIUM_11M} and {ERROR_SUFFIX_IS_SINGLE}" self._visium_and_is_single_true_matrix_size = VISIUM_11MM_AND_IS_SINGLE_TRUE_MATRIX_SIZE elif self._is_visium_including_descendants(): - self._visium_error_suffix = ERROR_SUFFIX_VISIUM + self._visium_error_suffix = f"{ERROR_SUFFIX_VISIUM} and {ERROR_SUFFIX_IS_SINGLE}" self._visium_and_is_single_true_matrix_size = VISIUM_AND_IS_SINGLE_TRUE_MATRIX_SIZE return self._visium_and_is_single_true_matrix_size diff --git a/cellxgene_schema_cli/tests/test_schema_compliance.py b/cellxgene_schema_cli/tests/test_schema_compliance.py index 9e1c0500..b815e86e 100644 --- a/cellxgene_schema_cli/tests/test_schema_compliance.py +++ b/cellxgene_schema_cli/tests/test_schema_compliance.py @@ -19,6 +19,7 @@ ERROR_SUFFIX_VISIUM, ERROR_SUFFIX_VISIUM_11M, ERROR_SUFFIX_VISIUM_AND_IS_SINGLE_TRUE, + ERROR_SUFFIX_IS_SINGLE, SPATIAL_HIRES_IMAGE_MAX_DIMENSION_SIZE, SPATIAL_HIRES_IMAGE_MAX_DIMENSION_SIZE_VISIUM_11MM, VISIUM_11MM_AND_IS_SINGLE_TRUE_MATRIX_SIZE, @@ -336,14 +337,14 @@ def test_raw_values__invalid_visium_and_is_single_true_row_length( validator.validate_adata() if assay_ontology_term_id == ASSAY_VISIUM_11M: _errors = [ - f"ERROR: When {ERROR_SUFFIX_VISIUM_11M}, the raw matrix must be the " + f"ERROR: When {ERROR_SUFFIX_VISIUM_11M} and {ERROR_SUFFIX_IS_SINGLE}, the raw matrix must be the " "unfiltered feature-barcode matrix 'raw_feature_bc_matrix'. It must have exactly " f"{validator.visium_and_is_single_true_matrix_size} rows. Raw matrix row count is 2.", "ERROR: Raw data may be missing: data in 'raw.X' does not meet schema requirements.", ] else: _errors = [ - f"ERROR: When {ERROR_SUFFIX_VISIUM}, the raw matrix must be the " + f"ERROR: When {ERROR_SUFFIX_VISIUM} and {ERROR_SUFFIX_IS_SINGLE}, the raw matrix must be the " "unfiltered feature-barcode matrix 'raw_feature_bc_matrix'. It must have exactly " f"{validator.visium_and_is_single_true_matrix_size} rows. Raw matrix row count is 2.", "ERROR: Raw data may be missing: data in 'raw.X' does not meet schema requirements.", @@ -387,13 +388,13 @@ def test_raw_values__multiple_invalid_in_tissue_errors( validator.validate_adata() if assay_ontology_term_id == ASSAY_VISIUM_11M: assert ( - validator.errors[0] == f"ERROR: When {ERROR_SUFFIX_VISIUM_11M}, the raw matrix must be the " + validator.errors[0] == f"ERROR: When {ERROR_SUFFIX_VISIUM_11M} and {ERROR_SUFFIX_IS_SINGLE}, the raw matrix must be the " "unfiltered feature-barcode matrix 'raw_feature_bc_matrix'. It must have exactly " f"{validator.visium_and_is_single_true_matrix_size} rows. Raw matrix row count is 2." ) else: assert ( - validator.errors[0] == f"ERROR: When {ERROR_SUFFIX_VISIUM}, the raw matrix must be the " + validator.errors[0] == f"ERROR: When {ERROR_SUFFIX_VISIUM} and {ERROR_SUFFIX_IS_SINGLE}, the raw matrix must be the " "unfiltered feature-barcode matrix 'raw_feature_bc_matrix'. It must have exactly " f"{validator.visium_and_is_single_true_matrix_size} rows. Raw matrix row count is 2." )