Skip to content

Commit d0dea02

Browse files
committed
Use fallback validation to OLS for taxon ID
1 parent a52b3bd commit d0dea02

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

ingest/validation/validate_metadata.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,17 @@ def retrieve_label_and_synonyms(
476476
:param property_type: attribute type for term (string, array, boolean)
477477
"""
478478
ontology_name = re.split("[_:]", ontology_id)[0].lower()
479-
if ontology_is_local(ontology_name):
479+
# use OLS fallback for taxon IDs since minified version is not authoritative
480+
use_fallback = ontology_name == "ncbitaxon"
481+
if ontology_is_local(ontology_name) and not use_fallback:
480482
return minified_reader.find_ontology_entry(ontology_name, ontology_id, property_name)
483+
elif ontology_is_local(ontology_name) and use_fallback:
484+
try:
485+
return minified_reader.find_ontology_entry(ontology_name, ontology_id, property_name)
486+
except ValueError:
487+
return retriever.retrieve_ontology_term_label_and_synonyms(
488+
ontology_id, property_name, convention, property_type
489+
)
481490
else:
482491
return retriever.retrieve_ontology_term_label_and_synonyms(
483492
ontology_id, property_name, convention, property_type
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
NAME cell_type cell_type__ontology_label organism_age disease disease__ontology_label species species__ontology_label geographical_region geographical_region__ontology_label library_preparation_protocol library_preparation_protocol__ontology_label organ organ__ontology_label sex is_living organism_age__unit organism_age__unit_label ethnicity__ontology_label ethnicity race race__ontology_label donor_id biosample_id biosample_type preservation_method
2+
TYPE group group numeric group group group group group group group group group group group group group group group group group group group group group group
3+
BM01_16dpp_AAGCAGTGGTAT CL_0000066 epithelial cell 31 MONDO_0000001 disease NCBITaxon_197152 Cloeon dipterum GAZ_00003181 Boston EFO_0008919 Seq-Well UBERON_0001913 milk female yes UO_0000036 year European ancestry HANCESTRO_0005 NCIT_C43862 Norwegian BM01 BM01_16dpp_r3 PrimaryBioSample_BodyFluid Fresh
4+
BM01_16dpp_TAAGCAGTGGTA CL_0000066 epithelial cell 31 MONDO_0000001 disease NCBITaxon_197152 Cloeon dipterum GAZ_00003181 Boston EFO_0008919 Seq-Well UBERON_0001913 milk female yes UO_0000036 year European ancestry HANCESTRO_0005 NCIT_C43862 Norwegian BM01 BM01_16dpp_r3 PrimaryBioSample_BodyFluid Fresh
5+
BM01_16dpp_CTAAGCAGTGGT CL_0000066 epithelial cell 31 MONDO_0000001 disease NCBITaxon_197152 Cloeon dipterum GAZ_00003181 Boston EFO_0008919 Seq-Well UBERON_0001913 milk female yes UO_0000036 year European ancestry HANCESTRO_0005 NCIT_C126538 Scandinavian BM01 BM01_16dpp_r3 PrimaryBioSample_BodyFluid Fresh
6+
BM01_16dpp_CGGTAAACCATT CL_0000066 epithelial cell 31 MONDO_0000001 disease NCBITaxon_197152 Cloeon dipterum GAZ_00003181 Boston EFO_0008919 Seq-Well UBERON_0001913 milk female yes UO_0000036 year European ancestry HANCESTRO_0005 NCIT_C126538 Scandinavian BM01 BM01_16dpp_r3 PrimaryBioSample_BodyFluid Fresh
7+
BM01_16dpp_CCGAATTCACCG CL_0000066 epithelial cell 31 PATO_0000001 quality NCBITaxon_197152 Cloeon dipterum GAZ_00003181 Boston EFO_0008919 Seq-Well UBERON_0001913 milk female yes UO_0000036 year European ancestry HANCESTRO_0005 NCIT_C126538 Scandinavian BM01 BM01_16dpp_r3 PrimaryBioSample_BodyFluid Fresh

tests/test_validate_metadata.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,22 @@ def test_minified_reader_validation(self):
961961
self.assertEqual('type 1 diabetes mellitus', entry['label'])
962962
self.assertIn('insulin dependent diabetes', entry['synonyms'])
963963

964+
def test_uses_fallback_validation(self):
965+
"""Non-standard species should use OLS fallback validation"""
966+
args = (
967+
"--convention ../schema/alexandria_convention/alexandria_convention_schema.json "
968+
"../tests/data/annotation/metadata/convention/valid_extended_taxon_v3.0.0.txt"
969+
)
970+
metadata, convention = self.setup_metadata(args)
971+
self.assertTrue(
972+
metadata.validate_format(), "Valid metadata headers should not elicit error"
973+
)
974+
validate_input_metadata(metadata, convention)
975+
self.assertFalse(
976+
report_issues(metadata), "Valid ontology content should not elicit error"
977+
)
978+
self.teardown_metadata(metadata)
979+
964980

965981
if __name__ == "__main__":
966982
unittest.main()

0 commit comments

Comments
 (0)