Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clean-up error message if only 1 ancestor is valid for ontology term #637

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cellxgene_schema_cli/cellxgene_schema/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,11 @@ def _validate_curie_ancestors(

if True not in checks:
if errors:
all_ancestors = list(allowed_ancestors.values())
self.errors.append(f"'{term_id}' in '{column_name}' is not a child term id of '{all_ancestors}'.")
all_ancestors = [ancestor for ancestors in allowed_ancestors.values() for ancestor in ancestors]
# print ancestor as string with single-quotes if only 1 entry
if len(all_ancestors) == 1:
all_ancestors = f"'{all_ancestors[0]}'"
self.errors.append(f"'{term_id}' in '{column_name}' is not a child term id of {all_ancestors}.")
return False
return True

Expand Down
6 changes: 3 additions & 3 deletions cellxgene_schema_cli/tests/test_schema_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def test_assay_ontology_term_id(self):
self.validator.errors,
[
"ERROR: 'EFO:0000001' in 'assay_ontology_term_id' is not a "
"child term id of '[['EFO:0002772', 'EFO:0010183']]'."
"child term id of ['EFO:0002772', 'EFO:0010183']."
],
)

Expand Down Expand Up @@ -603,7 +603,7 @@ def test_tissue_ontology_term_id_child_of_anatomical_entity(self):
self.validator.errors,
[
"ERROR: 'UBERON:0001062' in 'tissue_ontology_term_id' is not a child term id of "
"'[['UBERON:0001062']]'. When 'tissue_type' is 'tissue' or 'organoid', 'tissue_ontology_term_id' "
"'UBERON:0001062'. When 'tissue_type' is 'tissue' or 'organoid', 'tissue_ontology_term_id' "
"MUST be a child term id of 'UBERON:0001062' (anatomical entity)."
],
)
Expand All @@ -616,7 +616,7 @@ def test_tissue_ontology_term_id_child_of_anatomical_entity(self):
self.validator.errors,
[
"ERROR: 'UBERON:0001062' in 'tissue_ontology_term_id' is not a child term id of "
"'[['UBERON:0001062']]'. When 'tissue_type' is 'tissue' or 'organoid', 'tissue_ontology_term_id' "
"'UBERON:0001062'. When 'tissue_type' is 'tissue' or 'organoid', 'tissue_ontology_term_id' "
"MUST be a child term id of 'UBERON:0001062' (anatomical entity)."
],
)
Expand Down
Loading