ontodev / robot

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

relax is currently incomplete #1183

Open cmungall opened 9 months ago

cmungall commented 9 months ago

A subClassOf B and R some C is currently shielded from relax.

This has a long chain of unintended consequences...

chatgpt suggests the following which I think is correct:

// Assuming ontology is already loaded into an OWLOntology object named 'ontology'
OWLDataFactory factory = OWLManager.getOWLDataFactory();

for (OWLSubClassOfAxiom axiom : ontology.getAxioms(AxiomType.SUBCLASS_OF)) {
    // Check if the RHS is an ObjectIntersectionOf
    if (axiom.getSuperClass() instanceof OWLObjectIntersectionOf) {
        OWLObjectIntersectionOf intersection = (OWLObjectIntersectionOf) axiom.getSuperClass();
        OWLClassExpression subclass = axiom.getSubClass();

        // Remove the original axiom
        ontology.removeAxiom(axiom);

        // Create and add new axioms for each part of the intersection
        for (OWLClassExpression part : intersection.getOperands()) {
            OWLSubClassOfAxiom newAxiom = factory.getOWLSubClassOfAxiom(subclass, part);
            ontology.addAxiom(newAxiom);
        }
    }
}

// Save the ontology or perform further processing

I don't think we need to worry about inner ANDs, so no need for conversion to NNF or anything

cmungall commented 9 months ago

For now I am relaxing in place using this

(perl, functional syntax, and ChatGPT... what could go wrong?)

cmungall commented 8 months ago

Additionally it would be useful to do relaxation of cardinality constraints too.

E.g.

id: UPa:UCR00783
name: H(2)O + ferricytochrome c + nitric oxide = H(+) + ferrocytochrome c + nitrite
namespace: reaction
xref: KEGG:R00783 "KEGG reaction"
xref: RHEA:15236 "Rhea reaction"
xref: METACYC:NITRITE-REDUCTASE-CYTOCHROME-RXN "MetaCyc REACTION" {source=Rhea,source=MetaCyc}
relationship: has_input_compound UPa:UPC00001 {cardinality="1"} ! UPa:UPC00001 ! H(2)O
relationship: has_input_compound UPa:UPC00125 {cardinality="1"} ! UPa:UPC00125 ! ferricytochrome c
relationship: has_input_compound UPa:UPC00533 {cardinality="1"} ! UPa:UPC00533 ! nitric oxide
relationship: has_output_compound UPa:UPC00080 {cardinality="1"} ! UPa:UPC00080 ! H(+)
relationship: has_output_compound UPa:UPC00088 {cardinality="1"} ! UPa:UPC00088 ! nitrite
relationship: has_output_compound UPa:UPC00126 {cardinality="1"} ! UPa:UPC00126 ! ferrocytochrome c
relationship: part_of UPa:UER00707 {cardinality="1", order="1", direction="RL"}

Should generate someValuesFrom on relaxation

gouttegd commented 8 months ago

Is that really within the scope of relax though?

ROBOT currently defines the relax operation as being solely about removing equivalence axioms:

Robot can be used to relax Equivalence Axioms to weaker SubClassOf axioms. […] Many ontology make use of OWL EquivalenceAxioms, particularly during the development cycle. These are required for being able to use the reason command to classify an ontology. However, many downstream applications are not equipped to use these. […] The relax command allows us to capture some of the information in a form that is accessible to basic downstream applications.

matentzn commented 8 months ago

Relax is doing two things:

  1. Relaxing EquivalentClasses to SubClassOf
  2. Relaxing complex conjunctive expressions to individual SubClassOf axioms

So I think this is in scope.

I have now implemented some of this in #1188:

Note: cardinality constraints of the type you mention where always processed the way @cmungall is saying; I didnt touch this code, but added a test that illustrates this.