Skip to content

Commit

Permalink
update raw values error to include requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Molinelli authored and Evan Molinelli committed Dec 2, 2024
1 parent 8aeced2 commit b97cc18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
11 changes: 4 additions & 7 deletions cellxgene_schema_cli/cellxgene_schema/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down
9 changes: 5 additions & 4 deletions cellxgene_schema_cli/tests/test_schema_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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."
)
Expand Down

0 comments on commit b97cc18

Please sign in to comment.