Repository: ontodev/robot
Pull request #108 (2016-11-15 20:40:34)

Added support for JFact
This adds the [JFact DL reasoner](http://jfact.sourceforge.net). This possibly addresses #105.


Patch:
diff --git a/pom.xml b/pom.xml
index fc04b902..e0eb7061 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,6 +88,11 @@
             <artifactId>org.semanticweb.hermit</artifactId>
             <version>1.3.8.413</version>
        </dependency>
+       <dependency>
+           <groupId>net.sourceforge.owlapi</groupId>
+           <artifactId>jfact</artifactId>
+           <version>4.0.4</version>
+       </dependency>
     </dependencies>
 
     <reporting>
diff --git a/robot-command/src/main/java/org/obolibrary/robot/ReasonCommand.java b/robot-command/src/main/java/org/obolibrary/robot/ReasonCommand.java
index c1aa5d42..028f702e 100644
--- a/robot-command/src/main/java/org/obolibrary/robot/ReasonCommand.java
+++ b/robot-command/src/main/java/org/obolibrary/robot/ReasonCommand.java
@@ -2,14 +2,16 @@ package org.obolibrary.robot;
 
 import java.util.Map;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.Options;
 import org.geneontology.reasoner.ExpressionMaterializingReasonerFactory;
 import org.semanticweb.elk.owlapi.ElkReasonerFactory;
 import org.semanticweb.owlapi.model.OWLOntology;
 import org.semanticweb.owlapi.reasoner.OWLReasonerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import uk.ac.manchester.cs.jfact.JFactFactory;
 
 /**
  * Handles inputs and outputs for the {@link ReasonOperation}.
@@ -33,7 +35,7 @@ public class ReasonCommand implements Command {
      */
     public ReasonCommand() {
         Options o = CommandLineHelper.getCommonOptions();
-        o.addOption("r", "reasoner",  true, "reasoner to use: (ELK, HermiT)");
+        o.addOption("r", "reasoner",  true, "reasoner to use: (ELK, HermiT, JFact)");
         o.addOption("s", "remove-redundant-subclass-axioms",
                 true, "remove redundant subclass axioms");
         o.addOption("n", "create-new-ontology", true,
@@ -138,6 +140,9 @@ public class ReasonCommand implements Command {
             reasonerFactory = new org.semanticweb
                 .HermiT.Reasoner.ReasonerFactory();
         }
+        else if (reasonerName.equals("jfact")) {
+        	reasonerFactory = new JFactFactory();
+        }
         else if (reasonerName.equals("emr")) {
             ElkReasonerFactory innerReasonerFactory = new org.semanticweb
                     .elk.owlapi.ElkReasonerFactory();


Test patch:
diff --git a/robot-core/src/test/java/org/obolibrary/robot/ReasonOperationTest.java b/robot-core/src/test/java/org/obolibrary/robot/ReasonOperationTest.java
index 9b19a570..a1d4080f 100644
--- a/robot-core/src/test/java/org/obolibrary/robot/ReasonOperationTest.java
+++ b/robot-core/src/test/java/org/obolibrary/robot/ReasonOperationTest.java
@@ -13,6 +13,8 @@ import org.semanticweb.owlapi.model.OWLOntology;
 import org.semanticweb.owlapi.model.OWLOntologyCreationException;
 import org.semanticweb.owlapi.reasoner.OWLReasonerFactory;
 
+import uk.ac.manchester.cs.jfact.JFactFactory;
+
 /**
  * Tests for ReasonOperation.
  */
@@ -63,6 +65,21 @@ public class ReasonOperationTest extends CoreTest {
         assertEquals(6, reasoned.getAxiomCount());
         assertIdentical("/simple_hermit.owl", reasoned);
     }
+    
+    /**
+     * Test reasoning with JFact.
+     *
+     * @throws IOException on file problem
+     * @throws OWLOntologyCreationException on ontology problem
+     */
+    @Test
+    public void testJFact() throws IOException, OWLOntologyCreationException {
+        OWLOntology reasoned = loadOntology("/simple.owl");
+        OWLReasonerFactory reasonerFactory = new JFactFactory();
+        ReasonOperation.reason(reasoned, reasonerFactory);
+        assertEquals(6, reasoned.getAxiomCount());
+        assertIdentical("/simple_jfact.owl", reasoned);
+    }
 
     /**
      * Test inferring into new ontology.
diff --git a/robot-core/src/test/resources/simple_jfact.owl b/robot-core/src/test/resources/simple_jfact.owl
new file mode 100644
index 00000000..149d4d67
--- /dev/null
+++ b/robot-core/src/test/resources/simple_jfact.owl
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<rdf:RDF xmlns="https://github.com/ontodev/robot/robot-core/src/test/resources/simple.owl"
+     xml:base="https://github.com/ontodev/robot/robot-core/src/test/resources/simple.owl"
+     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:owl="http://www.w3.org/2002/07/owl#"
+     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
+     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+     xmlns:obo="http://purl.obolibrary.org/obo/"
+     xmlns:foaf="http://xmlns.com/foaf/0.1/">
+    <owl:Ontology rdf:about="https://github.com/ontodev/robot/robot-core/src/test/resources/simple.owl"/>
+    
+
+
+    <!-- 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Classes
+    //
+    ///////////////////////////////////////////////////////////////////////////////////////
+     -->
+
+    
+
+
+    <!-- https://github.com/ontodev/robot/robot-core/src/test/resources/simple.owl#test1 -->
+
+    <owl:Class rdf:about="https://github.com/ontodev/robot/robot-core/src/test/resources/simple.owl#test1">
+        <rdfs:label>Test 1</rdfs:label>
+        <rdfs:label>test one</rdfs:label>
+        <rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
+    </owl:Class>
+    
+
+
+    <!-- https://github.com/ontodev/robot/robot-core/src/test/resources/simple.owl#test2 -->
+
+    <owl:Class rdf:about="https://github.com/ontodev/robot/robot-core/src/test/resources/simple.owl#test2">
+        <rdfs:subClassOf rdf:resource="https://github.com/ontodev/robot/robot-core/src/test/resources/simple.owl#test1"/>
+    </owl:Class>
+</rdf:RDF>
+
+
+
+<!-- Generated by the OWL API (version 3.5.1) http://owlapi.sourceforge.net -->
+