Repository 'oppl'
hg clone https://toolshed.g2.bx.psu.edu/repos/mikel-egana-aranguren/oppl

Changeset 3:5255f1333cc4 (2011-09-07)
Previous changeset 2:0a374d0b7759 (2011-09-06) Next changeset 4:4f60202c58d9 (2011-09-14)
Commit message:
Version 1.0.1 Added output choice: OBO or OWL(RDF/XML)
modified:
OPPL/README
OPPL/oppl.sh
OPPL/oppl.xml
OPPL/oppl_galaxy_tool.jar
added:
OPPL/Tool.java
b
diff -r 0a374d0b7759 -r 5255f1333cc4 OPPL/README
--- a/OPPL/README Tue Sep 06 14:55:49 2011 -0400
+++ b/OPPL/README Wed Sep 07 10:46:29 2011 +0200
b
@@ -30,7 +30,7 @@
 Note that if you want you can use any java parameter by editing oppl.xml
 , eg: <command>java -Xmx7000M -Xms250M -DentityExpansionLimit=1000000000 
 -jar ${__tool_data_path__}/shared/jars/oppl_galaxy_tool.jar $input $OPPL 
-> $output </command>
+$format > $output </command>
 
 
 
b
diff -r 0a374d0b7759 -r 5255f1333cc4 OPPL/Tool.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/OPPL/Tool.java Wed Sep 07 10:46:29 2011 +0200
[
@@ -0,0 +1,121 @@
+/**
+ * Copyright (C) 2011, Mikel Egaña Aranguren
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package es.upm.fi.dia.oeg.oppl.galaxy;
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FilterOutputStream;
+import java.io.OutputStream;
+import java.io.PipedOutputStream;
+import java.io.PrintStream;
+import java.util.List;
+import java.util.Scanner;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.coode.oppl.ChangeExtractor;
+import org.coode.oppl.OPPLParser;
+import org.coode.oppl.OPPLScript;
+import org.coode.oppl.ParserFactory;
+import org.coode.oppl.exceptions.QuickFailRuntimeExceptionHandler;
+import org.coode.oppl.log.Logging;
+import org.coode.owlapi.obo.parser.OBOOntologyFormat;
+import org.coode.parsers.ErrorListener;
+import org.coode.parsers.LoggerErrorListener;
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.io.OWLOntologyDocumentTarget;
+import org.semanticweb.owlapi.io.RDFXMLOntologyFormat;
+import org.semanticweb.owlapi.io.SystemOutDocumentTarget;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLAxiomChange;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+import org.semanticweb.owlapi.model.OWLOntologyStorageException;
+import org.semanticweb.owlapi.reasoner.OWLReasoner;
+import org.semanticweb.owlapi.reasoner.OWLReasonerFactory;
+
+import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory;
+
+
+/**
+ * @author Mikel Egaña Aranguren
+ *
+ */
+public class Tool {
+
+ /**
+  * @param OWL file 
+  * @param OPPL script 
+  * @throws FileNotFoundException 
+  * @throws OWLOntologyCreationException 
+  * @throws OWLOntologyStorageException 
+  */
+ public static void main(String[] args) throws FileNotFoundException, OWLOntologyCreationException, OWLOntologyStorageException {
+  
+ // Get the arguments from command-line
+ String OWLFilePath = args [0]; 
+ String OPPL_script_file = args [1];
+ String Output_format = args [2];
+ String OPPL_script_source = "";
+
+ // Load the flat file with script in memory
+ File file = new File(OPPL_script_file);
+ Scanner input = new Scanner(file);
+ while(input.hasNext()) {
+     String nextToken = input.next();
+     OPPL_script_source = OPPL_script_source + " " + nextToken;
+ }
+ input.close();
+
+ // Load the OWL ontology
+ File owl_file = new File(OWLFilePath);
+ OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); 
+ OWLOntology OWL_ontology = manager.loadOntologyFromOntologyDocument(owl_file);
+
+ // Sync reasoner and check consistency
+ OWLReasonerFactory reasonerFactory = new PelletReasonerFactory(); 
+ OWLReasoner reasoner = reasonerFactory.createReasoner(OWL_ontology);
+
+ // Parse the OPPL script
+ ParserFactory parserFactory = new ParserFactory(manager, OWL_ontology, reasoner); 
+ Logger logger = Logger.getLogger(Tool.class.getName());
+ Logging.getQueryLogger().setLevel(Level.OFF); // The normal messages are errors for galaxy
+ ErrorListener errorListener = (ErrorListener)new LoggerErrorListener(logger);
+ OPPLParser opplparser = parserFactory.build(errorListener);
+ OPPLScript OPPLscript = opplparser.parse(OPPL_script_source);
+
+ // Execute the script
+ ChangeExtractor extractor = new ChangeExtractor(new QuickFailRuntimeExceptionHandler(), true);
+ List<OWLAxiomChange> changes = extractor.visit(OPPLscript);
+ manager.applyChanges(changes);
+
+ // Print the ontology to the standard output so other galaxy tools can operate on the output
+ OWLOntologyDocumentTarget documentTarget = new SystemOutDocumentTarget();
+
+ if(Output_format.equals("OBO")){
+ manager.saveOntology(OWL_ontology, new OBOOntologyFormat(), new SystemOutDocumentTarget());
+ }
+ else{
+ manager.saveOntology(OWL_ontology, new RDFXMLOntologyFormat(), new SystemOutDocumentTarget());
+ }
+
+ }
+}
b
diff -r 0a374d0b7759 -r 5255f1333cc4 OPPL/oppl.sh
--- a/OPPL/oppl.sh Tue Sep 06 14:55:49 2011 -0400
+++ b/OPPL/oppl.sh Wed Sep 07 10:46:29 2011 +0200
b
@@ -3,3 +3,4 @@
 java -Xmx7000M -Xms250M -DentityExpansionLimit=1000000000 -jar oppl_galaxy_tool.jar test.owl test.oppl > test_new.owl
 
 
+
b
diff -r 0a374d0b7759 -r 5255f1333cc4 OPPL/oppl.xml
--- a/OPPL/oppl.xml Tue Sep 06 14:55:49 2011 -0400
+++ b/OPPL/oppl.xml Wed Sep 07 10:46:29 2011 +0200
b
@@ -1,9 +1,13 @@
-<tool id="oppl" name="Execute an OPPL file against an OWL file" version="1.0.0">
+<tool id="oppl" name="Execute an OPPL file against an ontology" version="1.0.1">
   <description>It executes an OPPL script against the input ontology and generates a new ontology with the changes described in the OPPL script</description>
-  <command>java -jar ${__tool_data_path__}/shared/jars/oppl_galaxy_tool.jar $input $OPPL > $output </command>
+  <command>java -jar ${__tool_data_path__}/shared/jars/oppl_galaxy_tool.jar $input $OPPL $format > $output </command>
   <inputs>
-    <param format="text" name="input" type="data" label="Source OWL file"/>
+    <param format="text" name="input" type="data" label="Input ontology file"/>
     <param format="text" name="OPPL" type="data" label="OPPL file"/>
+    <param name="format" type="select" label="Choose ontology output format">
+        <option value="OWL" selected="true">OWL</option>
+ <option value="OBO">OBO</option>
+    </param>
   </inputs>
   <outputs>
     <data format="text" name="output" />
@@ -13,6 +17,7 @@
     <test>
       <param name="input" value="test.owl"/>
       <param name="OPPL" value="test.oppl"/>
+      <param name="format" value="OWL"/>
       <output name="out_file" file="test_new.owl"/>
     </test>
   </tests>
@@ -21,11 +26,11 @@
 
 **About OPPL-Galaxy**
 
-  OPPL-Galaxy can be used to execute an OPPL script against an (OWL) ontology, generating a new ontology. OPPL (Ontology Pre Processor Language) is a high level scripting language, based in the Manchester OWL Syntax, to automate the manipulation of an ontology (Adding or removing axioms). An OPPL script (See bellow or test.oppl) defines a query to be performed against the ontology, and some actions that affect the entities that will be retrieved. Those entities can be named or defined by a variable. OPPL is a powerful method for defining and executing modelling patterns that are repeated in a given ontology, saving time and effort.  
+  OPPL-Galaxy can be used to execute an OPPL script against an ontology, generating a new ontology. OPPL (Ontology Pre Processor Language) is a high level scripting language, based in the Manchester OWL Syntax, to automate the manipulation of an ontology (Adding or removing axioms). An OPPL script (See bellow or test.oppl) defines a query to be performed against the ontology, and some actions that affect the entities that will be retrieved. Those entities can be named or defined by a variable. OPPL is a powerful method for defining and executing modelling patterns that are repeated in a given ontology, saving time and effort.  
 
 **Formats**
 
-  OPPL-Galaxy uses the OWL API, and therefore can work with any ontology format that such API is able to load. That includes: OBO flat file, OWL (RDF/XML, OWL/XML, Functional, Manchester), turtle, and KRSS.
+  OPPL-Galaxy uses the OWL API, and therefore it can load any ontology format that such API is able to load: OBO flat file, OWL (RDF/XML, OWL/XML, Functional, Manchester), turtle, and KRSS. The available output formats are OBO flat file and OWL (RDF/XML).
 
 **Usage**
 
@@ -33,7 +38,7 @@
 
   Then execute the OPPL file against the OWL file with Ontology Pre Processor Language >> Execute an OPPL file against an OWL file.
 
-  This is the OPPL script provided in the bundle, test.oppl. Variables start with ?: 
+  This is the OPPL script provided in the bundle, test.oppl (Variables start with ?): 
 
   ?whole:CLASS,
   ?part:CLASS
@@ -55,11 +60,9 @@
 
 **Features that will be implemented soon**
 
-  OWL import closure
+  OWL import closure.
 
-  Choose output format (Right now only OWL RDF/XML is available)
-
-  Choose reasoner (Right now only Pellet is available)
+  Choose reasoner (Right now only Pellet is available).
 
 **Contact**
 
b
diff -r 0a374d0b7759 -r 5255f1333cc4 OPPL/oppl_galaxy_tool.jar
b
Binary file OPPL/oppl_galaxy_tool.jar has changed