comparison OPPL/src/OPPLGalaxy.java @ 18:d3616fac4ca5 draft

Elk support added
author Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
date Thu, 20 Sep 2012 12:46:36 +0200
parents 7e6604a5ee55
children
comparison
equal deleted inserted replaced
17:c9e01f86b07c 18:d3616fac4ca5
5 5
6 import java.io.File; 6 import java.io.File;
7 import java.io.IOException; 7 import java.io.IOException;
8 import java.util.List; 8 import java.util.List;
9 import java.util.Scanner; 9 import java.util.Scanner;
10 import java.util.logging.Level;
10 import java.util.logging.Logger; 11 import java.util.logging.Logger;
11 12
13 //import org.apache.log4j.Level;
12 import org.coode.oppl.ChangeExtractor; 14 import org.coode.oppl.ChangeExtractor;
13 import org.coode.oppl.OPPLParser; 15 import org.coode.oppl.OPPLParser;
14 import org.coode.oppl.OPPLScript; 16 import org.coode.oppl.OPPLScript;
15 import org.coode.oppl.ParserFactory; 17 import org.coode.oppl.ParserFactory;
16 import org.coode.oppl.exceptions.QuickFailRuntimeExceptionHandler; 18 import org.coode.oppl.exceptions.QuickFailRuntimeExceptionHandler;
19 import org.coode.oppl.log.Logging;
17 import org.coode.parsers.ErrorListener; 20 import org.coode.parsers.ErrorListener;
18 import org.coode.parsers.LoggerErrorListener; 21 import org.coode.parsers.LoggerErrorListener;
19 import org.semanticweb.owlapi.model.OWLAxiomChange; 22 import org.semanticweb.owlapi.model.OWLAxiomChange;
20 import org.semanticweb.owlapi.model.OWLOntology; 23 import org.semanticweb.owlapi.model.OWLOntology;
21 import org.semanticweb.owlapi.model.OWLOntologyCreationException; 24 import org.semanticweb.owlapi.model.OWLOntologyCreationException;
23 import org.semanticweb.owlapi.model.OWLOntologyStorageException; 26 import org.semanticweb.owlapi.model.OWLOntologyStorageException;
24 import org.semanticweb.owlapi.reasoner.OWLReasoner; 27 import org.semanticweb.owlapi.reasoner.OWLReasoner;
25 28
26 29
27 30
31
28 /** 32 /**
29 * @author Mikel Egaña Aranguren 33 * @author Mikel Ega��a Aranguren
30 * 34 *
31 */ 35 */
32 public class OPPLGalaxy { 36 public class OPPLGalaxy {
33 37
34 /** 38 /**
38 * @throws IOException 42 * @throws IOException
39 */ 43 */
40 public static void main(String[] args) throws OWLOntologyCreationException, OWLOntologyStorageException, IOException { 44 public static void main(String[] args) throws OWLOntologyCreationException, OWLOntologyStorageException, IOException {
41 // Get the arguments from command-line 45 // Get the arguments from command-line
42 String OWLFilePath = args [0]; 46 String OWLFilePath = args [0];
43 String reasoner_type = args [1]; // Pellet|FaCTPlusPlus|HermiT 47 String reasoner_type = args [1]; // Pellet|FaCTPlusPlus|Elk|HermiT
44 48
45 String OPPL_script_file = args [2]; 49 String OPPL_script_file = args [2];
46 String OWL = args [3]; // OWL|OBO 50 String OWL = args [3]; // OWL|OBO
47 51
48 // Create the manager 52 // Create the manager
58 galaxyowlapi.setReasonerPellet(); 62 galaxyowlapi.setReasonerPellet();
59 } 63 }
60 // FaCTPlusPlus 64 // FaCTPlusPlus
61 else if (reasoner_type.equals("FaCTPlusPlus")){ 65 else if (reasoner_type.equals("FaCTPlusPlus")){
62 galaxyowlapi.setReasonerFaCT(); 66 galaxyowlapi.setReasonerFaCT();
67 }
68 // Elk
69 else if (reasoner_type.equals("Elk")){
70 galaxyowlapi.setReasonerElk();
63 } 71 }
64 // HermiT 72 // HermiT
65 else{ 73 else{
66 galaxyowlapi.setReasonerHermit(); 74 galaxyowlapi.setReasonerHermit();
67 } 75 }
81 OWLReasoner reasoner = galaxyowlapi.getReasoner(); 89 OWLReasoner reasoner = galaxyowlapi.getReasoner();
82 90
83 // Parse the OPPL script 91 // Parse the OPPL script
84 ParserFactory parserFactory = new ParserFactory(manager, ontology, reasoner); 92 ParserFactory parserFactory = new ParserFactory(manager, ontology, reasoner);
85 Logger logger = Logger.getLogger(OPPLGalaxy.class.getName()); 93 Logger logger = Logger.getLogger(OPPLGalaxy.class.getName());
94 // logger.setLevel(Level.OFF);
86 // Logging.getQueryLogger().setLevel(Level.OFF); // The normal messages are errors for galaxy (Fixed in Galaxy by 2 > /dev/null) 95 // Logging.getQueryLogger().setLevel(Level.OFF); // The normal messages are errors for galaxy (Fixed in Galaxy by 2 > /dev/null)
96
87 ErrorListener errorListener = (ErrorListener)new LoggerErrorListener(logger); 97 ErrorListener errorListener = (ErrorListener)new LoggerErrorListener(logger);
88 OPPLParser opplparser = parserFactory.build(errorListener); 98 OPPLParser opplparser = parserFactory.build(errorListener);
89 OPPLScript OPPLscript = opplparser.parse(OPPL_script_source); 99 OPPLScript OPPLscript = opplparser.parse(OPPL_script_source);
90
91
92 100
93 // Execute the script 101 // Execute the script
94 ChangeExtractor extractor = new ChangeExtractor(new QuickFailRuntimeExceptionHandler(), true); 102 ChangeExtractor extractor = new ChangeExtractor(new QuickFailRuntimeExceptionHandler(), true);
95 List<OWLAxiomChange> changes = extractor.visit(OPPLscript); 103 List<OWLAxiomChange> changes = extractor.visit(OPPLscript);
96 manager.applyChanges(changes); 104 manager.applyChanges(changes);
105
106 galaxyowlapi.disposeReasoner();
97 107
98 // Merge imported ontologies if requested 108 // Merge imported ontologies if requested
99 // if(merge.equals("Merge")){ 109 // if(merge.equals("Merge")){
100 // galaxyowlapi.merge(); 110 // galaxyowlapi.merge();
101 // } 111 // }