biolink / biolink-model-toolkit

A collection of useful python functions for looking up information and working with the Biolink Model
https://biolink.github.io/biolink-model-toolkit/
BSD 3-Clause "New" or "Revised" License
20 stars 11 forks source link

Test if a given CURIE prefix (namespace) is known to Biolink Model (any of the prefixes, not just the category id_prefixes) #84

Closed RichardBruskiewich closed 2 years ago

RichardBruskiewich commented 2 years ago

BMT doesn't really (yet) have a method to simply validate whether or not a given xmlns prefix is known to the model (ie. is in the list of resolved prefixes)

Would we get that directly from a LinkML call?

We're not really thinking solely of category id_prefixes enumerated prefixes.

Rather, Eric Deutsch is suggesting that the CURIE's in the attribute_type_id field be validated as belonging to a Biolink-known prefix namespace (preferably a value mapped onto an association slot, if the CURIE given isn't strictly speaking a Biolink term)

His specific commentary is regarding validation of the attribute_type_id (preferably inheriting from biolink:association_slot):

The constraint is not really absolute, mostly because many of the concepts we want to convey are not in biolink. So I think we should enforce a curie, so if there's not colon, then that should be an error. If the prefix is not biolink, that should be a warning. If the prefix is not known to biolink that should be a double warning. Are we able to report warnings? or just errors?

I guess that the prefixes are loaded via the SchemaDefinition?

Or rather, viewable in the SchemaView which is available in the BMT Toolkit.view instance attribute.

Oddly enough, it is not obvious how one directly checks if a prefix exists in the Namespaces although one can perhaps simulate the checking using a try block wrapped Namespaces.sri_or_curie_for() call?

RichardBruskiewich commented 2 years ago

An empty return value from get_element_by_prefix() would not suffice here, since it covers id_prefixes known in all classes and slots