Mercurial > repos > mikel-egana-aranguren > oppl
diff OPPL/Tool.java @ 4:4f60202c58d9
Added option to push inferred subsumption axioms into output ontology
author | Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu> |
---|---|
date | Wed, 14 Sep 2011 19:52:06 +0200 |
parents | 5255f1333cc4 |
children | 68935f90c2db |
line wrap: on
line diff
--- a/OPPL/Tool.java Wed Sep 07 10:46:29 2011 +0200 +++ b/OPPL/Tool.java Wed Sep 14 19:52:06 2011 +0200 @@ -25,6 +25,7 @@ import java.io.OutputStream; import java.io.PipedOutputStream; import java.io.PrintStream; +import java.util.ArrayList; import java.util.List; import java.util.Scanner; import java.util.logging.Level; @@ -44,13 +45,18 @@ import org.semanticweb.owlapi.io.RDFXMLOntologyFormat; import org.semanticweb.owlapi.io.SystemOutDocumentTarget; import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLAxiom; 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.InferenceType; import org.semanticweb.owlapi.reasoner.OWLReasoner; import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; +import org.semanticweb.owlapi.util.InferredAxiomGenerator; +import org.semanticweb.owlapi.util.InferredOntologyGenerator; +import org.semanticweb.owlapi.util.InferredSubClassAxiomGenerator; import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; @@ -74,6 +80,7 @@ String OWLFilePath = args [0]; String OPPL_script_file = args [1]; String Output_format = args [2]; + String Add_inferred = args [3]; String OPPL_script_source = ""; // Load the flat file with script in memory @@ -107,15 +114,22 @@ List<OWLAxiomChange> changes = extractor.visit(OPPLscript); manager.applyChanges(changes); + // Add the inferred axioms as asserted axioms to the original ontology + if(Add_inferred.equals("Add_inferred")){ + reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY); + List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>(); + gens.add(new InferredSubClassAxiomGenerator()); + InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens); + iog.fillOntology(manager, OWL_ontology); + } + // Print the ontology to the standard output so other galaxy tools can operate on the output - OWLOntologyDocumentTarget documentTarget = new SystemOutDocumentTarget(); - + 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()); } - } }