comparison OPPL/Tool.java @ 9:14bfd77f8520

Interface improved (Imports first) and proper handling of import/merge options added
author Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
date Tue, 18 Oct 2011 10:30:16 +0200
parents 40adbcb2a7cc
children
comparison
equal deleted inserted replaced
8:40adbcb2a7cc 9:14bfd77f8520
180 iog.fillOntology(manager, OWL_ontology); 180 iog.fillOntology(manager, OWL_ontology);
181 } 181 }
182 182
183 // Print the ontology to the standard output so other galaxy tools can operate on it 183 // Print the ontology to the standard output so other galaxy tools can operate on it
184 184
185 // Do not merge ontologies 185 // Merge ontologies (Only in case there are imports)
186 if(merge_URI.equals("NoMerge")){ 186 if(!merge_URI.equals("NoMerge") && !imports_file_path.equals("NoImports")){
187 saveOntology(manager, OWL_ontology, Output_format);
188 }
189 // Merge ontologies
190 else{
191 OWLOntologyMerger merger = new OWLOntologyMerger(manager); 187 OWLOntologyMerger merger = new OWLOntologyMerger(manager);
192 IRI mergedOntologyIRI = IRI.create(merge_URI); 188 IRI mergedOntologyIRI = IRI.create(merge_URI);
193 OWLOntology merged = merger.createMergedOntology(manager, mergedOntologyIRI); 189 OWLOntology merged = merger.createMergedOntology(manager, mergedOntologyIRI);
194 saveOntology(manager, merged, Output_format); 190 saveOntology(manager, merged, Output_format);
191 }
192 // Do not merge ontologies (Even in the case in which a URI is provided, if there are not imports do not merge)
193 else{
194 saveOntology(manager, OWL_ontology, Output_format);
195 } 195 }
196 } 196 }
197 197
198 private static void saveOntology (OWLOntologyManager manager, OWLOntology ontology, String Format) throws OWLOntologyStorageException, IOException, URISyntaxException { 198 private static void saveOntology (OWLOntologyManager manager, OWLOntology ontology, String Format) throws OWLOntologyStorageException, IOException, URISyntaxException {
199 199
211 for(OWLClass cls : ontology.getClassesInSignature()){ 211 for(OWLClass cls : ontology.getClassesInSignature()){
212 // Remove annotations (OWL API generates bad OBO annotations) 212 // Remove annotations (OWL API generates bad OBO annotations)
213 213
214 // Keep rdfs:label 214 // Keep rdfs:label
215 String class_name = null; 215 String class_name = null;
216 for (OWLAnnotation annotation : cls.getAnnotations(ontology, label)) { 216 for (OWLAnnotation annotation : cls.getAnnotations(ontology, label)){
217 if (annotation.getValue() instanceof OWLLiteral) { 217 if (annotation.getValue() instanceof OWLLiteral) {
218 OWLLiteral val = (OWLLiteral) annotation.getValue(); 218 OWLLiteral val = (OWLLiteral) annotation.getValue();
219 class_name = val.getLiteral(); 219 class_name = val.getLiteral();
220 } 220 }
221 } 221 }
222 222
223 // I have to remove all the annotations cause I don't know which ones are rendered properly 223 // I have to remove all the annotations cause I don't know which ones are rendered properly
224 manager.removeAxioms(ontology,ontology.getAnnotationAssertionAxioms(cls.getIRI())); 224 manager.removeAxioms(ontology,ontology.getAnnotationAssertionAxioms(cls.getIRI()));
225 225
226 // Add rdfs:label again 226 // Add rdfs:label again