INCATools / ontology-access-kit

Ontology Access Kit: A python library and command line application for working with ontologies
https://incatools.github.io/ontology-access-kit/
Apache License 2.0
113 stars 26 forks source link

`relationships`: Add warning/error when invalid predicates #680

Open joeflack4 opened 10 months ago

joeflack4 commented 10 months ago

Overview

Both in the CLI and in the Python API, I've mistakenly used relationships to try to access a number of edges at once which include mappings, rather than using relationships and mappings commands separately. I suggest that if invalid predicates are passed, a warning or error should occur

Current behavior

The behavior is inconsistent. In (1), the predicate invalid predicate is not returned, and in (2) they are.

  1. CLI: The invalid predicate I passed (oboInOwl:hasDbXref) is simply ignored and not returned.

  2. Python API: The invalid predicates I passed (skos:exactMatch, skos:narrowMatch) were returned. Additional info: They are not returned when .relationships() is used without passing the predicates flag, which is a logical inconsistency and in conflict with what the docstring says (:param predicates: constrain search to these predicates). That is to say, any relationship returned when passing the predicates flag should also be present if not passing the flag.

Expected behavior

The command/method should show a warning or throw an error, and possibly also detect if these are mapping predicates and suggest to use that method instead.

cmungall commented 9 months ago

The challenge here is that client code may need to be generic; for example:

Not every ontology instantiates every one of these, so if we use lookups to determine validity, this will yield false positive errors.

We could do some hardcoding (e.g hardcode a set of RO IDs as never being mapping predicates, hardcode skos to never be a relationship predicate), but this would only catch a subset of errors, and would not be very generic.

What is the algorithm for determining if something is a valid predicate? Unfortunately there are a large number of different ontologies out there that represent things in different ways.

We could simply look up the predicate in the existing ontology.

joeflack4 commented 9 months ago

Oh, I didn't realize that this could be a difficult thing. I actually thought that (though I see how that is naive) the same predicate would be used in the same way for any ontology. And I also thought that OAK was already doing hard-coding of such 'invalid' predicates.