annotate OPPL/src/GalaxyOWLAPI.java @ 11:6ca67b155e32

Imports simplified, new tool for inference added
author Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
date Fri, 09 Mar 2012 16:15:27 +0100
parents
children 7e6604a5ee55
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
1 /**
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
2 *
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
3 */
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
4 package es.upm.fi.dia.oeg.oppl.galaxy;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
5
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
6 import java.io.BufferedWriter;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
7 import java.io.File;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
8 import java.io.IOException;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
9 import java.io.OutputStreamWriter;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
10 import java.util.ArrayList;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
11 import java.util.List;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
12 import java.util.Scanner;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
13
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
14 import org.coode.owlapi.obo.parser.OBOOntologyFormat;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
15 import org.semanticweb.HermiT.Reasoner;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
16 import org.semanticweb.owlapi.apibinding.OWLManager;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
17 import org.semanticweb.owlapi.io.RDFXMLOntologyFormat;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
18 import org.semanticweb.owlapi.io.SystemOutDocumentTarget;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
19 import org.semanticweb.owlapi.model.AddAxiom;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
20 import org.semanticweb.owlapi.model.IRI;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
21 import org.semanticweb.owlapi.model.OWLAnnotation;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
22 import org.semanticweb.owlapi.model.OWLAnnotationProperty;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
23 import org.semanticweb.owlapi.model.OWLAxiom;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
24 import org.semanticweb.owlapi.model.OWLClass;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
25 import org.semanticweb.owlapi.model.OWLDataFactory;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
26 import org.semanticweb.owlapi.model.OWLLiteral;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
27 import org.semanticweb.owlapi.model.OWLOntology;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
28 import org.semanticweb.owlapi.model.OWLOntologyChange;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
29 import org.semanticweb.owlapi.model.OWLOntologyCreationException;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
30 import org.semanticweb.owlapi.model.OWLOntologyManager;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
31 import org.semanticweb.owlapi.model.OWLOntologyStorageException;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
32 import org.semanticweb.owlapi.reasoner.InferenceType;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
33 import org.semanticweb.owlapi.reasoner.OWLReasoner;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
34 import org.semanticweb.owlapi.reasoner.OWLReasonerFactory;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
35 import org.semanticweb.owlapi.util.InferredAxiomGenerator;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
36 import org.semanticweb.owlapi.util.InferredClassAssertionAxiomGenerator;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
37 import org.semanticweb.owlapi.util.InferredDisjointClassesAxiomGenerator;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
38 import org.semanticweb.owlapi.util.InferredOntologyGenerator;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
39 import org.semanticweb.owlapi.util.InferredSubClassAxiomGenerator;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
40 import org.semanticweb.owlapi.util.InferredSubDataPropertyAxiomGenerator;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
41 import org.semanticweb.owlapi.util.InferredSubObjectPropertyAxiomGenerator;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
42 import org.semanticweb.owlapi.util.OWLEntityRenamer;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
43 import org.semanticweb.owlapi.util.OWLOntologyMerger;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
44 import org.semanticweb.owlapi.vocab.OWL2Datatype;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
45 import org.semanticweb.owlapi.vocab.OWLRDFVocabulary;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
46
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
47 import uk.ac.manchester.cs.factplusplus.owlapiv3.FaCTPlusPlusReasonerFactory;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
48
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
49 import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
50
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
51 /**
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
52 * A wrapper of the OWL API
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
53 *
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
54 * @author Mikel EgaƱa Aranguren
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
55 */
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
56 public class GalaxyOWLAPI {
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
57 private OWLOntologyManager manager;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
58 private OWLOntology ontology;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
59 private OWLReasonerFactory reasonerFactory;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
60 private OWLReasoner reasoner;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
61
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
62 public GalaxyOWLAPI (){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
63 manager = OWLManager.createOWLOntologyManager();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
64 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
65 public OWLOntologyManager getOWLManager(){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
66 return manager;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
67 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
68 public OWLOntology getMainOntology(){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
69 return ontology;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
70 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
71 public OWLReasoner getReasoner(){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
72 return reasoner;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
73 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
74
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
75 public void loadMainOntology(String OWLFilePath) throws OWLOntologyCreationException{
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
76 File owl_file = new File(OWLFilePath);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
77 ontology = manager.loadOntologyFromOntologyDocument(owl_file);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
78 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
79
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
80 // public void loadImportedOntology(IRI importedOntologyIRI) throws OWLOntologyCreationException{
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
81 // manager.loadOntologyFromOntologyDocument(importedOntologyIRI);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
82 // }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
83
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
84 // OWLLink: The problem is that Racer, for example, listens in 8080, the same port as Galaxy
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
85 // I have to change Racer settings and OWLLink settings
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
86 // OWLlinkHTTPXMLReasonerFactory factory = new OWLlinkHTTPXMLReasonerFactory();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
87 // reasoner = factory.createReasoner(OWL_ontology);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
88
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
89 public void setReasonerPellet (){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
90 reasonerFactory = new PelletReasonerFactory();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
91 reasoner = reasonerFactory.createReasoner(ontology);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
92 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
93 public void setReasonerFaCT (){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
94 reasonerFactory = new FaCTPlusPlusReasonerFactory();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
95 reasoner = reasonerFactory.createReasoner(ontology);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
96 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
97 public void setReasonerHermit (){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
98 reasonerFactory = new Reasoner.ReasonerFactory();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
99 reasoner = reasonerFactory.createReasoner(ontology);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
100 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
101 public void merge () throws OWLOntologyCreationException{
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
102 OWLOntologyMerger merger = new OWLOntologyMerger(manager);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
103 IRI mergedOntologyIRI = IRI.create("http://oeg-upm.net/oppl_galaxy/merged.owl");
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
104 ontology = merger.createMergedOntology(manager, mergedOntologyIRI);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
105 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
106
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
107 // CLASS_ASSERTIONS Denotes the computation of the direct types of individuals for each individual in the signature of the imports closure of the root ontology.
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
108
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
109 public void addCLASS_ASSERTIONS(){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
110 reasoner.precomputeInferences(InferenceType.CLASS_ASSERTIONS);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
111 List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
112 gens.add(new InferredClassAssertionAxiomGenerator());
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
113 InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
114 iog.fillOntology(manager, ontology);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
115 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
116
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
117 // CLASS_HIERARCHY Denotes the computation of the class hierarchy.
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
118
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
119 public void addCLASS_HIERARCHY(){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
120 reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
121 List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
122 gens.add(new InferredSubClassAxiomGenerator());
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
123 InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
124 iog.fillOntology(manager, ontology);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
125 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
126
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
127 // DATA_PROPERTY_ASSERTIONS Denotes the computation of relationships between individuals and data property values for each individual in the signature of the imports closure of the root ontology.
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
128 // public void addDATA_PROPERTY_ASSERTIONS(){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
129 // reasoner.precomputeInferences(InferenceType.DATA_PROPERTY_ASSERTIONS);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
130 // List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
131 // gens.add(new InferredDataPropertyAxiomGenerator());
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
132 // InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
133 // iog.fillOntology(manager, ontology);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
134 // }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
135
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
136 // DATA_PROPERTY_HIERARCHY Denotes the computation of the data property hierarchy.
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
137
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
138 public void addDATA_PROPERTY_HIERARCHY(){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
139 reasoner.precomputeInferences(InferenceType.DATA_PROPERTY_HIERARCHY);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
140 List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
141 gens.add(new InferredSubDataPropertyAxiomGenerator());
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
142 InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
143 iog.fillOntology(manager, ontology);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
144 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
145
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
146 // DIFFERENT_INDIVIDUALS Denotes the computation of sets of individuals that are different from each individual in the signature of the imports closure of the root ontology.
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
147
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
148 // public void addDIFFERENT_INDIVIDUALS(){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
149 // reasoner.precomputeInferences(InferenceType.DIFFERENT_INDIVIDUALS);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
150 // List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
151 // gens.add(new Inferred);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
152 // InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
153 // iog.fillOntology(manager, ontology);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
154 // }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
155
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
156 // DISJOINT_CLASSES Denotes the computation of sets of classes that are disjoint for each class in the signature of the imports closure of the root ontology.
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
157
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
158 public void addDISJOINT_CLASSES(){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
159 reasoner.precomputeInferences(InferenceType.DISJOINT_CLASSES);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
160 List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
161 gens.add(new InferredDisjointClassesAxiomGenerator());
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
162 InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
163 iog.fillOntology(manager, ontology);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
164 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
165
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
166 // OBJECT_PROPERTY_ASSERTIONS Denotes the computation of relationships between individuals in the signature of the imports closure of the root ontology.
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
167
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
168 // public void addOBJECT_PROPERTY_ASSERTIONS(){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
169 // reasoner.precomputeInferences(InferenceType.OBJECT_PROPERTY_ASSERTIONS);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
170 // List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
171 // gens.add(new InferredObjectPropertyAxiomGenerator<OWLAxiom>() {
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
172 // };());
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
173 // InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
174 // iog.fillOntology(manager, ontology);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
175 // }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
176
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
177 // OBJECT_PROPERTY_HIERARCHY Denotes the computation of the object property hierarchy.
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
178
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
179 public void addOBJECT_PROPERTY_HIERARCHY(){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
180 reasoner.precomputeInferences(InferenceType.OBJECT_PROPERTY_HIERARCHY);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
181 List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
182 gens.add(new InferredSubObjectPropertyAxiomGenerator());
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
183 InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
184 iog.fillOntology(manager, ontology);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
185 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
186
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
187 // SAME_INDIVIDUAL Denotes the computation of individuals that are interpreted as the same object for each individual in the imports closure of the root ontology.
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
188
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
189 // public void addSAME_INDIVIDUAL(){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
190 // reasoner.precomputeInferences(InferenceType.SAME_INDIVIDUAL);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
191 // List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
192 // gens.add(new Infer);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
193 // InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
194 // iog.fillOntology(manager, ontology);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
195 // }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
196
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
197 public void saveOntology (boolean OWL) throws OWLOntologyStorageException, IOException, OWLOntologyCreationException{
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
198 // OWL format
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
199 if(OWL){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
200 manager.saveOntology(ontology, new RDFXMLOntologyFormat(), new SystemOutDocumentTarget());
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
201 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
202 // OBO format
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
203 else{
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
204 // OWL API generates bad OBO but OBOformat doesn't work either so I correct the OWL API problems (More predictable) in a temporary file
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
205 // Very inefficient but no time for another solution
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
206
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
207 OWLDataFactory factory = manager.getOWLDataFactory();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
208 OWLEntityRenamer renamer = new OWLEntityRenamer (manager, manager.getOntologies());
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
209 OWLAnnotationProperty label = factory.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI());
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
210 for(OWLClass cls : ontology.getClassesInSignature()){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
211 // Remove annotations (OWL API generates bad OBO annotations)
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
212
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
213 // Keep rdfs:label
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
214 String class_name = null;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
215 for (OWLAnnotation annotation : cls.getAnnotations(ontology, label)){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
216 if (annotation.getValue() instanceof OWLLiteral) {
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
217 OWLLiteral val = (OWLLiteral) annotation.getValue();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
218 class_name = val.getLiteral();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
219 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
220 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
221
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
222 // I have to remove all the annotations cause I don't know which ones are rendered properly
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
223 manager.removeAxioms(ontology,ontology.getAnnotationAssertionAxioms(cls.getIRI()));
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
224
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
225 // Add rdfs:label again
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
226 OWLAnnotation labelAnno = factory.getOWLAnnotation(factory.getOWLAnnotationProperty(
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
227 OWLRDFVocabulary.RDFS_LABEL.getIRI()),factory.getOWLLiteral(class_name,OWL2Datatype.XSD_STRING));
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
228 OWLAxiom ax = factory.getOWLAnnotationAssertionAxiom(cls.getIRI(), labelAnno);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
229 manager.applyChange(new AddAxiom(ontology, ax));
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
230
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
231 // Rename entities
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
232 String cls_IRI = cls.getIRI().toString();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
233 String cls_proper_IRI = cls_IRI.replace("_", ":");
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
234 List<OWLOntologyChange> changes = renamer.changeIRI(cls, IRI.create(cls_proper_IRI));
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
235 manager.applyChanges(changes);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
236 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
237
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
238 File file = new File("tmp.obo");
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
239 manager.saveOntology(ontology, new OBOOntologyFormat(), IRI.create(file.toURI()));
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
240 BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
241 Scanner input = new Scanner(file);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
242 String buffer = "";
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
243
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
244 while(input.hasNext()){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
245 String nextLine = input.nextLine();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
246 if(nextLine.contains("[Term]") || nextLine.contains("[Typedef]")){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
247 if(buffer.isEmpty()){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
248 bw.write(buffer);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
249 bw.newLine();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
250 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
251 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
252 if(!nextLine.contains("is_a: Thing") && !nextLine.contains("auto-generated-by:") && !nextLine.contains("id_space:") && !nextLine.contains("! ----")){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
253 if(!nextLine.isEmpty() && !buffer.contains("relationship:")){
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
254 bw.write(nextLine);
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
255 bw.newLine();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
256 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
257 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
258 buffer = nextLine;
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
259 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
260 input.close();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
261 bw.close();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
262 file.delete();
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
263 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
264 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
265 }