ontodev / robot

ROBOT is an OBO Tool
http://robot.obolibrary.org
BSD 3-Clause "New" or "Revised" License
263 stars 74 forks source link

Obographs: Class declarations w/out further assertions not in serialization #1082

Open joeflack4 opened 1 year ago

joeflack4 commented 1 year ago

Overview

My team is doing some conversions from OWL -> Obographs JSON -> FHIR JSON, and we noticed that some concepts were missing from the output.

I took a look, and these are all root nodes; they are all rdfs:subClassOf owl:Thing.

Edges that reference these nodes exist, but the declaration of the nodes themselves do not. It's not just a FHIR JSON issue. I looked in my Obographs JSON (downloadable here), and the declarations are missing there as well.

I imagine this is an issue for the other ontologies I'm working with, but for this particular ontology, comploinc.owl, these are the declarations of the root nodes that are missing from the Obographs JSON:

    <owl:Class rdf:about="https://loinc.org/LP70625-6A">
        <rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
    </owl:Class>
    <owl:Class rdf:about="https://loinc.org/lc0000001">
        <rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
    </owl:Class>
    <owl:Class rdf:about="https://loinc.org/LP33117-0">
        <rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
    </owl:Class>
    <owl:Class rdf:about="https://loinc.org/LP33103-0">
        <rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
    </owl:Class>

Expected vs Actual

Expected I would expect to see something like this in my Obographs JSON:

{
  "id": "https://loinc.org/LP33117-0",
  "type": "CLASS"
}

Or maybe something like this, with one or more nulls for missing properties:

{
  "id": "https://loinc.org/LP33117-0",
  "type": "CLASS",
  "lbl": null,
  "meta": {
    "definition": null,
    ...
  }
}

Actual No declarations appear.

Reproducibility

  1. Download merged_reasoned_loinc.owl
  2. Download robot 1.9.1 if not already present
  3. Run : `java -jar robot convert -i path/to/merged_reasoned_loinc.owl -o path/to/outfile.json --format json'

What I tried

I examined the CLI to see if there was an option dealing with root nodes, but I didn't see anything in java -jar bin/robot.jar convert -h that seems like it could help with this.

Additional information

In this example, only root nodes (subClassOf owl:Thing) were missing, but in some other ontologies I looked at, there may have been other cases missing. Will update if I have more time to get concrete examples.

Blocked by

joeflack4 commented 1 year ago

It's possible as well that there's something we are misunderstanding. I need to double check if this is really blocking us from uploading to our FHIR server, but OAK is not letting me load/convert these Obographs after I wrote a patch to manually add them back into the JSON:

key = 'https://loinc.org/lc0000001'
cooked_entry = Node(id="JsonObj(id='https://loinc.org/lc0000001')", lbl=None, type=None, meta=None)

    def order_up(key: Any, cooked_entry: YAMLRoot) -> None:
        """ A cooked entry is ready to be added to the return slot """
        if cooked_entry[key_name] != key:
>           raise ValueError(
                f"Slot: {loc(slot_name)} - attribute {loc(key_name)} " \
                f"value ({loc(cooked_entry[key_name])}) does not match key ({loc(key)})")
E           ValueError: Slot: nodes - attribute id value (JsonObj(id='https://loinc.org/lc0000001')) does not match key (https://loinc.org/lc0000001)
matentzn commented 1 year ago

ROBOT just uses the obographs parser, all obographs related issues should be reported / mirrored there as well.

I find this issue worrying though - the way you describe it there is definitely something wrong with obographs serialisation. The way to phrase it is: "class declarations without further assertions are not included by obographs serialisation". If you can add a minimum example and make an issue on the obographs tracker, as well as tagging Jules and me, that would be great.

joeflack4 commented 1 year ago

@matentzn Glad to have your eyes on this! I went ahead and opened and tagged you and Jules. Also added the minimal reproducibility steps.