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 10 forks source link

Possible bug in qualifier value range slot_usage access in some biolink:Association subclasses #147

Closed RichardBruskiewich closed 11 months ago

RichardBruskiewich commented 11 months ago

A curious defect was noticed in qualifier value range slot_usage access in some biolink:Association subclasses.

The specific anomaly noted from accessing the following in the Biolink class:

  chemical affects gene association:
...
    slots:
...
      - object part qualifier
      - object aspect qualifier
...
    slot_usage:
...
      object part qualifier:
        range: GeneOrGeneProductOrChemicalPartQualifierEnum
      object aspect qualifier:
        range: GeneOrGeneProductOrChemicalEntityAspectEnum

Note that the object aspect qualifier range recorded in the model is GeneOrGeneProductOrChemicalEntityAspectEnum.

However, when using an toolkit class instance 'bmt' (e.g. from release 3.5.2)

association_element = bmt.get_element("biolink:ChemicalAffectsGeneAssociation")
qualifier_type = association_element["slot_usage"]["object aspect qualifier"]
value_range = qualifier_type.range

one gets the following

 value_range == GeneOrGeneProductOrChemicalPartQualifierEnum

which seems to be the value of the range of the preceding object part qualifier entry, not the expected GeneOrGeneProductOrChemicalEntityAspectEnum range enum for object aspect qualifier. This, of course, causes reasoner validation false positive errors. Here's one known example of this:

"errors": {
      "error.knowledge_graph.edge.qualifiers.qualifier.value.unresolved": {
        "infores:lincs -> infores:improving-agent": {
          "activity_or_abundance": [
            {
              "edge_id": "NCBIGene:57019[biolink:Gene]--biolink:regulates->NCBIGene:310[biolink:Gene]",
              "qualifier_type_id": "biolink:object_aspect_qualifier"
            } ...

which has an matches to chemical affects gene association but fails to be validated inside bmt.validate_qualifier() (in code similar to the above).

RichardBruskiewich commented 11 months ago

Sigh... Alas, I'm scratching my head tonight. I wrote a unit test assuming the correct value, and it seems to work. I'm wondering if there is a stale dependency in contexts where the error is manifested. I'll take a closer look at this over the next day or so.

RichardBruskiewich commented 11 months ago

Ah... this was actually a Biolink Model 3.5.2 bug, fixed in 3.5.3... I was puzzled for the longest while about this, LOL.