robot icon indicating copy to clipboard operation
robot copied to clipboard

How to delete a deprecated axiom?

Open psiotwo opened this issue 3 years ago • 13 comments

For now, I am able to remove deprecated entities if annotated by owl:deprecated true using the following command:

robot remove --select "owl:deprecated='true'^^xsd:boolean"

However, if I deprecate not a class, but an axiom (e.g. subClassOf, or propertyChain) the whole term gets removed, not just the axiom.

psiotwo avatar Apr 14 '22 10:04 psiotwo

Just as an aside - I would caution very very strongly against using owl:deprecated on axioms. I can see the appeal for provenance reasons, but the amount of confusion this could cause for downstream users of your ontology are immense.

In any case, you if is true what you are saying, that given this example:

a rdfs:label "some label"
a owl:subClassOf b { deprecated=true }

your query would delete the label, then I agree, something is wrong. Can you supply a minimal example that replicates the behaviour (command + short ontology)?

matentzn avatar Apr 14 '22 10:04 matentzn

Thanks for response. We need the axiom-level granularity for our own curation process and happily downstream users never touch/see this bit, so using this fine-grained deprecation should be on safe side on our end.

The MWE is:

input.owl:

<?xml version="1.0"?>
<rdf:RDF
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
     <owl:Ontology rdf:about="https://test.org/ontology"/>
     <owl:Class rdf:about="http://purl.obolibrary.org/obo/SYMP_0019159">
         <rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/SYMP_0000459"/>
         <rdfs:label>gastroenteritis</rdfs:label>
     </owl:Class>
     <owl:Axiom>
         <owl:annotatedSource rdf:resource="http://purl.obolibrary.org/obo/SYMP_0019159"/>
         <owl:annotatedProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#subClassOf"/>
         <owl:annotatedTarget rdf:resource="http://purl.obolibrary.org/obo/SYMP_0000459"/>
         <owl:deprecated rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</owl:deprecated>
     </owl:Axiom>
</rdf:RDF>

And the robot command is:

robot remove --input input.owl --output output.owl --select "owl:deprecated='true'^^xsd:boolean"

The command outputs an empty ontology.

<?xml version="1.0"?>
<rdf:RDF xmlns="https://test.org/ontology#"
     xml:base="https://test.org/ontology"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
    <owl:Ontology rdf:about="https://test.org/ontology"/>
</rdf:RDF>

psiotwo avatar Apr 14 '22 10:04 psiotwo

@matentzn were you able to replicate this issue using the MWE attached?

psiotwo avatar Jun 14 '22 11:06 psiotwo

Yes, I can confirm this in ROBOT 1.8.4 and this is a bug.

Would you be able to make a PR that fixes this issue?

matentzn avatar Jun 15 '22 07:06 matentzn

@matentzn I solved it earlier for our pipeline with a custom robot command https://github.com/psiotwo/robot/blob/988-remove-axioms-command/docs/axioms.md (as discussed in https://github.com/ontodev/robot/issues/987) that is dedicated to working with axioms.

I can create a PR for it. However, I am not sure if it is aligned well with the ROBOT API architecture. To cover the functionality, extensions at least to remove, annotate commands would be needed, which would mean quite some effort IMO.

psiotwo avatar Jun 21 '22 07:06 psiotwo

Would be great to see the opinion from the core ROBOT team on this. Thanks a lot!

psiotwo avatar Jun 21 '22 13:06 psiotwo

Yeah that is too involved for ROBOT I think - the problem here should be considerably smaller - a fix to ensure that owl:deprecated on axioms is ignored, and only owl:deprecated on entities should work - the behaviour is just wrong now.

matentzn avatar Jun 21 '22 15:06 matentzn

Yes, agree. Might take a look at it at some point, based on time ...

psiotwo avatar Jun 21 '22 16:06 psiotwo

Until now, all the use cases I've seen apply the owl:deprecated predicate to a named entity subject (i.e. with an IRI). The OWL spec supports that usage:

An annotation with the owl:deprecated annotation property and the value equal to "true"^^xsd:boolean can be used to specify that an IRI is deprecated.

That's what I was thinking of when I designed the "Pattern Subset Selectors" for ROBOT: selecting named entities, not axioms. Sometimes I don't manage to think through all the cases. It would be simpler to just clarify / enforce that behaviour.

On the other hand, the domain of owl:deprecated is rdfs:Resource, which I guess encompasses everything, including anonymous stuff?

So I prefer to go with @matentzn's "smaller" fix at this point in time, and @psiotwo seems to agree. Let me know if I've misunderstood.

jamesaoverton avatar Jun 22 '22 15:06 jamesaoverton

@jamesaoverton owl:Axiom rdfs:subClassOf rdfs:Resource ., as per https://www.w3.org/TR/owl2-rdf-based-semantics/#Semantic_Conditions_for_the_RDFS_Vocabulary.

If there is a consensus that selectors should widely support also axioms (in addition to OWL entities), then I absolutely agree with @matentzn that fixing the current ROBOT commands is the way forward. The use-cases for which I designed the axioms command described above should be solvable by extending the 'remove' and 'annotate' command with axiom-based selectors.

psiotwo avatar Jun 22 '22 18:06 psiotwo

Sorry, now I'm confused again.

  1. I don't think that the existing selectors can be changed to also select axioms. The design of ROBOT remove/filter is about building sets of "terms", then finding the axioms that they occur in, and then removing or filtering those axioms. I spent a long time on that design, and since it still confuses everybody maybe it was a bad design, but I don't see how we can change it now.

  2. If I were to design a system for removing/filtering axioms in general, I think I would want to write something more like DL query or Manchester with variables.

  3. Maybe @psiotwo you are not asking for full generality (1), just covering this specific use case: Remove an OWLAxiom when a (new) selector matches its OWLAnnotationAxiom?

jamesaoverton avatar Jun 24 '22 15:06 jamesaoverton

@jamesaoverton thanks for response.

  1. I believe it is more towards the core ROBOT team - being a newbie to ROBOT, I have no clear position on this

  2. Yes, it might be an option IMO too. However, I believe that e.g. annotation-based selectors could be well extendable from terms towards axioms too (not saying this functionality needs to be covered by the same ROBOT commands, and also not saying there are enough use-cases to support this)

  3. Not just that - actually, I also need a variant of "annotate" for axioms - e.g. to mark all axioms in an ontology deprecated. The rationale behind this is described here - https://github.com/ontodev/robot/issues/987. But in this case I am not speaking about selectors - I abuse the selector syntax to specify which annotation should be added - so here it could be definitely redesigned in another way.

psiotwo avatar Jun 25 '22 14:06 psiotwo

@psiotwo The recent discussion in #886 about selecting axiom annotations seems very close to this topic. Your feedback on that issue would be appreciated!

jamesaoverton avatar Jul 06 '22 16:07 jamesaoverton