annotate src/GalaxyOWLAPI.java @ 21:ffde1fafa066 draft

README corrected with proper installation instructions for mercurial (hg pull + hg update)
author Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
date Mon, 08 Oct 2012 13:10:44 +0200
parents cc270db37d33
children
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;
13
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
13 import java.util.Set;
11
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
14
18
d3616fac4ca5 Elk support added
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 17
diff changeset
15 import org.apache.log4j.Level;
d3616fac4ca5 Elk support added
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 17
diff changeset
16 import org.apache.log4j.Logger;
13
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
17 import org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser;
11
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.coode.owlapi.obo.parser.OBOOntologyFormat;
13
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
19 import org.coode.parsers.BidirectionalShortFormProviderAdapter;
11
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.HermiT.Reasoner;
18
d3616fac4ca5 Elk support added
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 17
diff changeset
21 import org.semanticweb.elk.owlapi.ElkReasonerFactory;
11
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.apibinding.OWLManager;
13
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
23 import org.semanticweb.owlapi.expression.OWLEntityChecker;
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
24 import org.semanticweb.owlapi.expression.ParserException;
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
25 import org.semanticweb.owlapi.expression.ShortFormEntityChecker;
11
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.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
27 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
28 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
29 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
30 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
31 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
32 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
33 import org.semanticweb.owlapi.model.OWLClass;
13
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
34 import org.semanticweb.owlapi.model.OWLClassExpression;
11
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.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
36 import org.semanticweb.owlapi.model.OWLLiteral;
13
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
37 import org.semanticweb.owlapi.model.OWLNamedIndividual;
11
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.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
39 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
40 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
41 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
42 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
43 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
44 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
45 import org.semanticweb.owlapi.reasoner.OWLReasonerFactory;
13
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
46 import org.semanticweb.owlapi.util.BidirectionalShortFormProvider;
11
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 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
48 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
49 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
50 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
51 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
52 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
53 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
54 import org.semanticweb.owlapi.util.OWLEntityRenamer;
17
c9e01f86b07c New tool added for merging imported ontologies (GalaxyOWLAPI and README changed and test ontologies added accordingly). Memory settings changed in all the tools XML files
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 15
diff changeset
55 import org.semanticweb.owlapi.util.OWLOntologyImportsClosureSetProvider;
11
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
56 import org.semanticweb.owlapi.util.OWLOntologyMerger;
13
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
57 import org.semanticweb.owlapi.util.SimpleShortFormProvider;
11
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
58 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
59 import org.semanticweb.owlapi.vocab.OWLRDFVocabulary;
13
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
60 import org.semanticweb.owlapi.reasoner.Node;
11
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 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
63
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
64 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
65
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
66 /**
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
67 * 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
68 *
17
c9e01f86b07c New tool added for merging imported ontologies (GalaxyOWLAPI and README changed and test ontologies added accordingly). Memory settings changed in all the tools XML files
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 15
diff changeset
69 * @author Mikel Egana Aranguren
11
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 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
72 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
73 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
74 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
75 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
76
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
77 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
78 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
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 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
81 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
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 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
84 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
85 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
86 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
87 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
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
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
90 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
91 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
92 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
93 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
94
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
95 // 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
96 // 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
97 // }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
98
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
99 // 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
100 // 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
101 // 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
102 // 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
103
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
104 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
105 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
106 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
107 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
108 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
109 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
110 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
111 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
112 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
113 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
114 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
115 }
18
d3616fac4ca5 Elk support added
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 17
diff changeset
116 public void setReasonerElk (){
d3616fac4ca5 Elk support added
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 17
diff changeset
117 reasonerFactory = new ElkReasonerFactory();
d3616fac4ca5 Elk support added
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 17
diff changeset
118 Logger.getLogger("org.semanticweb.elk").setLevel(Level.OFF);
d3616fac4ca5 Elk support added
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 17
diff changeset
119 reasoner = reasonerFactory.createReasoner(ontology);
d3616fac4ca5 Elk support added
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 17
diff changeset
120 }
d3616fac4ca5 Elk support added
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 17
diff changeset
121 public void disposeReasoner(){
d3616fac4ca5 Elk support added
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 17
diff changeset
122 reasoner.dispose();
d3616fac4ca5 Elk support added
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 17
diff changeset
123 }
17
c9e01f86b07c New tool added for merging imported ontologies (GalaxyOWLAPI and README changed and test ontologies added accordingly). Memory settings changed in all the tools XML files
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 15
diff changeset
124 public void merge (String ontologyIRI) throws OWLOntologyCreationException, OWLOntologyStorageException{
11
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
125 OWLOntologyMerger merger = new OWLOntologyMerger(manager);
17
c9e01f86b07c New tool added for merging imported ontologies (GalaxyOWLAPI and README changed and test ontologies added accordingly). Memory settings changed in all the tools XML files
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 15
diff changeset
126 // OWLOntologyMerger merger = new OWLOntologyMerger(new OWLOntologyImportsClosureSetProvider(manager, ontology));
c9e01f86b07c New tool added for merging imported ontologies (GalaxyOWLAPI and README changed and test ontologies added accordingly). Memory settings changed in all the tools XML files
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 15
diff changeset
127 IRI mergedOntologyIRI = IRI.create(ontologyIRI);
c9e01f86b07c New tool added for merging imported ontologies (GalaxyOWLAPI and README changed and test ontologies added accordingly). Memory settings changed in all the tools XML files
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 15
diff changeset
128 // OWLOntology merged_ontology = merger.createMergedOntology(manager, mergedOntologyIRI);
11
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
129 ontology = merger.createMergedOntology(manager, mergedOntologyIRI);
17
c9e01f86b07c New tool added for merging imported ontologies (GalaxyOWLAPI and README changed and test ontologies added accordingly). Memory settings changed in all the tools XML files
Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 15
diff changeset
130 // manager.saveOntology(ontology, new RDFXMLOntologyFormat(), new SystemOutDocumentTarget());
11
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
131 }
13
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
132
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
133 public OWLClassExpression parseMOSClassExpression (String expr) throws ParserException{
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
134 Set<OWLOntology> importsClosure = ontology.getImportsClosure();
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
135 BidirectionalShortFormProvider bidiShortFormProvider = new BidirectionalShortFormProviderAdapter(manager, importsClosure, new SimpleShortFormProvider());
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
136 OWLEntityChecker entityChecker = new ShortFormEntityChecker(bidiShortFormProvider);
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
137 ManchesterOWLSyntaxEditorParser MOSparser = new ManchesterOWLSyntaxEditorParser(manager.getOWLDataFactory(), expr);
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
138 MOSparser.setOWLEntityChecker(entityChecker);
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
139 return MOSparser.parseClassExpression();
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
140 }
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
141
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
142 public Set<OWLNamedIndividual> getIndividuals (OWLClassExpression expr){
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
143 return (reasoner.getInstances(expr, false)).getFlattened();
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
144 }
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
145 public Set<OWLClass> getEquivalentClasses (OWLClassExpression expr){
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
146 Node<OWLClass> equivalentClasses = reasoner.getEquivalentClasses(expr);
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
147 Set<OWLClass> result;
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
148 if (expr.isAnonymous()) {
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
149 result = equivalentClasses.getEntities();
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
150 }
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
151 else {
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
152 result = equivalentClasses.getEntitiesMinus(expr.asOWLClass());
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
153 }
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
154 return result;
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
155 }
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
156
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
157 public Set<OWLClass> getDirectSuperClasses (OWLClassExpression expr){
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
158 return (reasoner.getSuperClasses(expr, true)).getFlattened();
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
159 }
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
160
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
161 public Set<OWLClass> getAncestors (OWLClassExpression expr){
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
162 return (reasoner.getSuperClasses(expr, false)).getFlattened();
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
163 }
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
164
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
165 public Set<OWLClass> getDirectSubClasses (OWLClassExpression expr){
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
166 return (reasoner.getSubClasses(expr, true)).getFlattened();
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
167 }
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
168
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
169 public Set<OWLClass> getDescendants (OWLClassExpression expr){
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
170 return (reasoner.getSubClasses(expr, false)).getFlattened();
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
171 }
7e6604a5ee55 New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents: 11
diff changeset
172
11
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
173 // 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
174
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
175 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
176 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
177 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
178 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
179 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
180 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
181 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
182
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
183 // 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
184
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
185 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
186 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
187 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
188 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
189 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
190 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
191 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
192
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
193 // 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
194 // 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
195 // 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
196 // 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
197 // 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
198 // 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
199 // 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
200 // }
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 // 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
203
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
204 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
205 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
206 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
207 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
208 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
209 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
210 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
211
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
212 // 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
213
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
214 // 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
215 // 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
216 // 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
217 // 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
218 // 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
219 // 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
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 // 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
223
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
224 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
225 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
226 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
227 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
228 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
229 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
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
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
232 // 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
233
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
234 // 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
235 // 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
236 // 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
237 // 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
238 // };());
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
239 // 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
240 // 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
241 // }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
242
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
243 // 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
244
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
245 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
246 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
247 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
248 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
249 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
250 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
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
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
253 // 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
254
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
255 // 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
256 // 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
257 // 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
258 // 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
259 // 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
260 // 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
261 // }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
262
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
263 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
264 // 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
265 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
266 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
267 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
268 // 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
269 else{
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
270 // 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
271 // 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
272
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
273 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
274 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
275 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
276 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
277 // 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
278
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
279 // 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
280 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
281 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
282 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
283 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
284 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
285 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
286 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
287
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
288 // 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
289 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
290
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
291 // 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
292 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
293 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
294 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
295 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
296
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
297 // 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
298 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
299 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
300 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
301 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
302 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
303
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
304 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
305 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
306 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
307 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
308 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
309
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
310 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
311 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
312 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
313 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
314 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
315 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
316 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
317 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
318 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
319 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
320 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
321 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
322 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
323 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
324 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
325 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
326 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
327 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
328 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
329 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
330 }
6ca67b155e32 Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff changeset
331 }