Skip to content

Commit cdbb804

Browse files
committed
Changing behavior for reduce, fixes #321
Previously the procedure included axioms such as Domain in its test for redundant axioms. This mean it was too vigorous in throwing out SubClassOf axioms. Now an axiom is only reduced if it can be inferred purely from SubClassOf plus OPCharacteristic axioms (e.g. transitivity)
1 parent e69ef9d commit cdbb804

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

robot-core/src/main/java/org/obolibrary/robot/ReduceOperation.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
import org.semanticweb.owlapi.model.OWLClassExpression;
1717
import org.semanticweb.owlapi.model.OWLDataFactory;
1818
import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom;
19+
import org.semanticweb.owlapi.model.OWLObjectPropertyCharacteristicAxiom;
1920
import org.semanticweb.owlapi.model.OWLOntology;
2021
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
2122
import org.semanticweb.owlapi.model.OWLOntologyManager;
2223
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom;
24+
import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom;
2325
import org.semanticweb.owlapi.model.parameters.Imports;
2426
import org.semanticweb.owlapi.reasoner.Node;
2527
import org.semanticweb.owlapi.reasoner.OWLReasoner;
@@ -99,10 +101,10 @@ public static void reduce(
99101
OWLDataFactory dataFactory = manager.getOWLDataFactory();
100102

101103
// we treat an axiom as redundant if its is redundant within the
102-
// subClassOf graph, excluding equivalence axioms
104+
// subClassOf graph, including OP characteristic axioms (e.g. transitivity)
103105
OWLOntology subOntology = manager.createOntology();
104106
for (OWLAxiom a : ontology.getAxioms(Imports.INCLUDED)) {
105-
if (!(a instanceof OWLEquivalentClassesAxiom)) {
107+
if (a instanceof OWLSubClassOfAxiom || a instanceof OWLObjectPropertyCharacteristicAxiom) {
106108
manager.addAxiom(subOntology, a);
107109
}
108110
}

robot-core/src/test/java/org/obolibrary/robot/ReduceOperationTest.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void testReduceWithEquiv() throws IOException, OWLOntologyCreationExcepti
120120
assertIdentical("/equiv_reduce_test_reduced.obo", reasoned);
121121
}
122122

123-
/**
123+
/**
124124
* Edge case, taken from GO
125125
*
126126
* <p>See: 'central nervous system development' in the test file
@@ -135,8 +135,26 @@ public void testReduceEdgeCase() throws IOException, OWLOntologyCreationExceptio
135135

136136
Map<String, String> options = new HashMap<String, String>();
137137
options.put("remove-redundant-subclass-axioms", "true");
138-
138+
139139
ReduceOperation.reduce(reasoned, reasonerFactory, options);
140140
assertIdentical("/reduce-edgecase-cnd-reduced.obo", reasoned);
141141
}
142+
143+
/**
144+
* Domain case, see https://github.com/ontodev/robot/issues/321
145+
*
146+
*
147+
* @throws IOException
148+
* @throws OWLOntologyCreationException
149+
*/
150+
@Test
151+
public void testReduceDomainCase() throws IOException, OWLOntologyCreationException {
152+
OWLOntology reasoned = loadOntology("/reduce-domain-test.owl");
153+
OWLReasonerFactory reasonerFactory = new org.semanticweb.elk.owlapi.ElkReasonerFactory();
154+
155+
Map<String, String> options = new HashMap<String, String>();
156+
157+
ReduceOperation.reduce(reasoned, reasonerFactory, options);
158+
assertIdentical("/reduce-domain-test.owl", reasoned);
159+
}
142160
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Prefix: : <http://x.org/>
2+
Ontology: <http://x.org/>
3+
4+
ObjectProperty: supplies Domain: artery
5+
6+
Class: brain_artery
7+
EquivalentTo: artery and supplies some brain
8+
SubClassOf: artery
9+
SubClassOf: supplies some brain
10+
11+
Class: artery
12+
Class: brain

0 commit comments

Comments
 (0)