ontodev / robot

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

'remove' command behaves unexpectedly when IAO:0000115 annotations themselves have annotation properties #1161

Open allysonlister opened 1 year ago

allysonlister commented 1 year ago

(Apologies in advance if the title isn't quite right - please edit as required!)

As discussed on Slack here, I have experienced some odd behaviour when using robot remove in the following situation...

Goal: retain labels, isDefinedBy, and definitions from a subset of CHMO that I've previously created with extract. Actual result: the command below works as expected ONLY when the IAO definitions DO NOT themselves have annotation properties on them. When the definitions themselves have annotation properties, the entire definition is removed.

Here is my command (feel free to just use the entire CHMO ontology here instead of my tmp file of course ;-) ):

java -jar ~/Programs/robot.jar remove --input chmo-import-tmp.owl --term rdfs:label --term IAO:0000115 --term rdfs:isDefinedBy --select complement --select annotation-properties --output chmo-import-tmp2.owl

Although some classes, such as BFO independent continuant are being correctly modified with the above command, the CHMO classes are NOT. Here is an example CHMO class before running the remove command:

<!-- http://purl.obolibrary.org/obo/CHMO_0000156 -->

    <owl:Class rdf:about="http://purl.obolibrary.org/obo/CHMO_0000156">
        <rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/CHMO_0000141"/>
        <obo:IAO_0000115>A method for determining structure by directing a beam of X-rays at the sample and detecting the positions and intensities of the diffracted X-rays as a pattern of spots on a photographic plate.</obo:IAO_0000115>
        <oboInOwl:hasExactSynonym>X-Ray crystallographic analysis</oboInOwl:hasExactSynonym>
        <oboInOwl:hasExactSynonym>X-ray analysis</oboInOwl:hasExactSynonym>
        <oboInOwl:hasExactSynonym>X-ray crystallography</oboInOwl:hasExactSynonym>
        <oboInOwl:hasExactSynonym>X-ray diffraction analysis</oboInOwl:hasExactSynonym>
        <oboInOwl:hasExactSynonym>X-ray diffractometry</oboInOwl:hasExactSynonym>
        <oboInOwl:hasExactSynonym>X-ray structure determination</oboInOwl:hasExactSynonym>
        <oboInOwl:hasExactSynonym>XRD</oboInOwl:hasExactSynonym>
        <oboInOwl:id>CHMO:0000156</oboInOwl:id>
        <rdfs:isDefinedBy rdf:resource="http://purl.obolibrary.org/obo/chmo.owl"/>
        <rdfs:label>X-ray diffraction</rdfs:label>
    </owl:Class>
    <owl:Axiom>
        <owl:annotatedSource rdf:resource="http://purl.obolibrary.org/obo/CHMO_0000156"/>
        <owl:annotatedProperty rdf:resource="http://purl.obolibrary.org/obo/IAO_0000115"/>
        <owl:annotatedTarget>A method for determining structure by directing a beam of X-rays at the sample and detecting the positions and intensities of the diffracted X-rays as a pattern of spots on a photographic plate.</owl:annotatedTarget>
        <oboInOwl:hasDbXref>FIX:0000007</oboInOwl:hasDbXref>
        <oboInOwl:hasDbXref>ISBN:90190280031-0</oboInOwl:hasDbXref>
    </owl:Axiom>

And here is the same CHMO class after running remove (label and isDefinedBy are kept, but definition has been "incorrectly" removed):

<!-- http://purl.obolibrary.org/obo/CHMO_0000156 -->

    <owl:Class rdf:about="http://purl.obolibrary.org/obo/CHMO_0000156">
        <rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/CHMO_0000141"/>
        <rdfs:isDefinedBy rdf:resource="http://purl.obolibrary.org/obo/chmo.owl"/>
        <rdfs:label>X-ray diffraction</rdfs:label>
    </owl:Class>

At Philip's suggestion, I then created a test version of CHMO that didn't have the annotations on IAO definition. When I run the remove command over that modified ontology, remove functions as expected:

<!-- http://purl.obolibrary.org/obo/CHMO_0000156 -->

    <owl:Class rdf:about="http://purl.obolibrary.org/obo/CHMO_0000156">
        <rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/CHMO_0000141"/>
        <obo:IAO_0000115>A method for determining structure by directing a beam of X-rays at the sample and detecting the positions and intensities of the diffracted X-rays as a pattern of spots on a photographic plate.</obo:IAO_0000115>
        <rdfs:isDefinedBy rdf:resource="http://purl.obolibrary.org/obo/chmo.owl"/>
        <rdfs:label>X-ray diffraction</rdfs:label>
    </owl:Class>

I would be agnostic about whether or not the associated properties are retained or removed. The important thing for me is that the definition is retained.

Thanks!

jamesaoverton commented 11 months ago

I'm terrified of digging into the remove code. As a workaround, could you remove the annotations from the IAO annotation properties in a first step, then do this task as a second step?

allysonlister commented 11 months ago

I understand, and I can do that - thanks!