Mercurial > repos > mikel-egana-aranguren > oppl
comparison OPPL/src/GalaxyOWLAPI.java @ 13:7e6604a5ee55
New query tool added
author | Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu> |
---|---|
date | Thu, 29 Mar 2012 14:49:22 +0200 |
parents | 6ca67b155e32 |
children | 622cde484f4c |
comparison
equal
deleted
inserted
replaced
12:d0722148cb59 | 13:7e6604a5ee55 |
---|---|
8 import java.io.IOException; | 8 import java.io.IOException; |
9 import java.io.OutputStreamWriter; | 9 import java.io.OutputStreamWriter; |
10 import java.util.ArrayList; | 10 import java.util.ArrayList; |
11 import java.util.List; | 11 import java.util.List; |
12 import java.util.Scanner; | 12 import java.util.Scanner; |
13 | 13 import java.util.Set; |
14 | |
15 import org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser; | |
14 import org.coode.owlapi.obo.parser.OBOOntologyFormat; | 16 import org.coode.owlapi.obo.parser.OBOOntologyFormat; |
17 import org.coode.parsers.BidirectionalShortFormProviderAdapter; | |
15 import org.semanticweb.HermiT.Reasoner; | 18 import org.semanticweb.HermiT.Reasoner; |
16 import org.semanticweb.owlapi.apibinding.OWLManager; | 19 import org.semanticweb.owlapi.apibinding.OWLManager; |
20 import org.semanticweb.owlapi.expression.OWLEntityChecker; | |
21 import org.semanticweb.owlapi.expression.ParserException; | |
22 import org.semanticweb.owlapi.expression.ShortFormEntityChecker; | |
17 import org.semanticweb.owlapi.io.RDFXMLOntologyFormat; | 23 import org.semanticweb.owlapi.io.RDFXMLOntologyFormat; |
18 import org.semanticweb.owlapi.io.SystemOutDocumentTarget; | 24 import org.semanticweb.owlapi.io.SystemOutDocumentTarget; |
19 import org.semanticweb.owlapi.model.AddAxiom; | 25 import org.semanticweb.owlapi.model.AddAxiom; |
20 import org.semanticweb.owlapi.model.IRI; | 26 import org.semanticweb.owlapi.model.IRI; |
21 import org.semanticweb.owlapi.model.OWLAnnotation; | 27 import org.semanticweb.owlapi.model.OWLAnnotation; |
22 import org.semanticweb.owlapi.model.OWLAnnotationProperty; | 28 import org.semanticweb.owlapi.model.OWLAnnotationProperty; |
23 import org.semanticweb.owlapi.model.OWLAxiom; | 29 import org.semanticweb.owlapi.model.OWLAxiom; |
24 import org.semanticweb.owlapi.model.OWLClass; | 30 import org.semanticweb.owlapi.model.OWLClass; |
31 import org.semanticweb.owlapi.model.OWLClassExpression; | |
25 import org.semanticweb.owlapi.model.OWLDataFactory; | 32 import org.semanticweb.owlapi.model.OWLDataFactory; |
26 import org.semanticweb.owlapi.model.OWLLiteral; | 33 import org.semanticweb.owlapi.model.OWLLiteral; |
34 import org.semanticweb.owlapi.model.OWLNamedIndividual; | |
27 import org.semanticweb.owlapi.model.OWLOntology; | 35 import org.semanticweb.owlapi.model.OWLOntology; |
28 import org.semanticweb.owlapi.model.OWLOntologyChange; | 36 import org.semanticweb.owlapi.model.OWLOntologyChange; |
29 import org.semanticweb.owlapi.model.OWLOntologyCreationException; | 37 import org.semanticweb.owlapi.model.OWLOntologyCreationException; |
30 import org.semanticweb.owlapi.model.OWLOntologyManager; | 38 import org.semanticweb.owlapi.model.OWLOntologyManager; |
31 import org.semanticweb.owlapi.model.OWLOntologyStorageException; | 39 import org.semanticweb.owlapi.model.OWLOntologyStorageException; |
32 import org.semanticweb.owlapi.reasoner.InferenceType; | 40 import org.semanticweb.owlapi.reasoner.InferenceType; |
41 import org.semanticweb.owlapi.reasoner.NodeSet; | |
33 import org.semanticweb.owlapi.reasoner.OWLReasoner; | 42 import org.semanticweb.owlapi.reasoner.OWLReasoner; |
34 import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; | 43 import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; |
44 import org.semanticweb.owlapi.util.BidirectionalShortFormProvider; | |
35 import org.semanticweb.owlapi.util.InferredAxiomGenerator; | 45 import org.semanticweb.owlapi.util.InferredAxiomGenerator; |
36 import org.semanticweb.owlapi.util.InferredClassAssertionAxiomGenerator; | 46 import org.semanticweb.owlapi.util.InferredClassAssertionAxiomGenerator; |
37 import org.semanticweb.owlapi.util.InferredDisjointClassesAxiomGenerator; | 47 import org.semanticweb.owlapi.util.InferredDisjointClassesAxiomGenerator; |
38 import org.semanticweb.owlapi.util.InferredOntologyGenerator; | 48 import org.semanticweb.owlapi.util.InferredOntologyGenerator; |
39 import org.semanticweb.owlapi.util.InferredSubClassAxiomGenerator; | 49 import org.semanticweb.owlapi.util.InferredSubClassAxiomGenerator; |
40 import org.semanticweb.owlapi.util.InferredSubDataPropertyAxiomGenerator; | 50 import org.semanticweb.owlapi.util.InferredSubDataPropertyAxiomGenerator; |
41 import org.semanticweb.owlapi.util.InferredSubObjectPropertyAxiomGenerator; | 51 import org.semanticweb.owlapi.util.InferredSubObjectPropertyAxiomGenerator; |
42 import org.semanticweb.owlapi.util.OWLEntityRenamer; | 52 import org.semanticweb.owlapi.util.OWLEntityRenamer; |
43 import org.semanticweb.owlapi.util.OWLOntologyMerger; | 53 import org.semanticweb.owlapi.util.OWLOntologyMerger; |
54 import org.semanticweb.owlapi.util.SimpleShortFormProvider; | |
44 import org.semanticweb.owlapi.vocab.OWL2Datatype; | 55 import org.semanticweb.owlapi.vocab.OWL2Datatype; |
45 import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; | 56 import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; |
57 import org.semanticweb.owlapi.reasoner.Node; | |
46 | 58 |
47 import uk.ac.manchester.cs.factplusplus.owlapiv3.FaCTPlusPlusReasonerFactory; | 59 import uk.ac.manchester.cs.factplusplus.owlapiv3.FaCTPlusPlusReasonerFactory; |
48 | 60 |
49 import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; | 61 import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; |
50 | 62 |
101 public void merge () throws OWLOntologyCreationException{ | 113 public void merge () throws OWLOntologyCreationException{ |
102 OWLOntologyMerger merger = new OWLOntologyMerger(manager); | 114 OWLOntologyMerger merger = new OWLOntologyMerger(manager); |
103 IRI mergedOntologyIRI = IRI.create("http://oeg-upm.net/oppl_galaxy/merged.owl"); | 115 IRI mergedOntologyIRI = IRI.create("http://oeg-upm.net/oppl_galaxy/merged.owl"); |
104 ontology = merger.createMergedOntology(manager, mergedOntologyIRI); | 116 ontology = merger.createMergedOntology(manager, mergedOntologyIRI); |
105 } | 117 } |
106 | 118 |
119 public OWLClassExpression parseMOSClassExpression (String expr) throws ParserException{ | |
120 Set<OWLOntology> importsClosure = ontology.getImportsClosure(); | |
121 BidirectionalShortFormProvider bidiShortFormProvider = new BidirectionalShortFormProviderAdapter(manager, importsClosure, new SimpleShortFormProvider()); | |
122 OWLEntityChecker entityChecker = new ShortFormEntityChecker(bidiShortFormProvider); | |
123 ManchesterOWLSyntaxEditorParser MOSparser = new ManchesterOWLSyntaxEditorParser(manager.getOWLDataFactory(), expr); | |
124 MOSparser.setOWLEntityChecker(entityChecker); | |
125 return MOSparser.parseClassExpression(); | |
126 } | |
127 | |
128 public Set<OWLNamedIndividual> getIndividuals (OWLClassExpression expr){ | |
129 return (reasoner.getInstances(expr, false)).getFlattened(); | |
130 } | |
131 public Set<OWLClass> getEquivalentClasses (OWLClassExpression expr){ | |
132 Node<OWLClass> equivalentClasses = reasoner.getEquivalentClasses(expr); | |
133 Set<OWLClass> result; | |
134 if (expr.isAnonymous()) { | |
135 result = equivalentClasses.getEntities(); | |
136 } | |
137 else { | |
138 result = equivalentClasses.getEntitiesMinus(expr.asOWLClass()); | |
139 } | |
140 return result; | |
141 } | |
142 | |
143 public Set<OWLClass> getDirectSuperClasses (OWLClassExpression expr){ | |
144 return (reasoner.getSuperClasses(expr, true)).getFlattened(); | |
145 } | |
146 | |
147 public Set<OWLClass> getAncestors (OWLClassExpression expr){ | |
148 return (reasoner.getSuperClasses(expr, false)).getFlattened(); | |
149 } | |
150 | |
151 public Set<OWLClass> getDirectSubClasses (OWLClassExpression expr){ | |
152 return (reasoner.getSubClasses(expr, true)).getFlattened(); | |
153 } | |
154 | |
155 public Set<OWLClass> getDescendants (OWLClassExpression expr){ | |
156 return (reasoner.getSubClasses(expr, false)).getFlattened(); | |
157 } | |
158 | |
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. | 159 // 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. |
108 | 160 |
109 public void addCLASS_ASSERTIONS(){ | 161 public void addCLASS_ASSERTIONS(){ |
110 reasoner.precomputeInferences(InferenceType.CLASS_ASSERTIONS); | 162 reasoner.precomputeInferences(InferenceType.CLASS_ASSERTIONS); |
111 List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>(); | 163 List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>(); |