use of uk.ac.ebi.spot.goci.exception.OWLConversionException in project goci by EBISPOT.
the class DefaultGWASOWLConverter method createConversionOntology.
public OWLOntology createConversionOntology() throws OWLConversionException {
try {
// create a new graph to represent our data dump
OWLOntology conversion = getManager().createOntology(IRI.create(OntologyConstants.GWAS_ONTOLOGY_BASE_IRI + "/" + new SimpleDateFormat("yyyy/MM/dd").format(new Date())));
// import the gwas ontology schema and efo
OWLImportsDeclaration gwasImportDecl = getDataFactory().getOWLImportsDeclaration(IRI.create(OntologyConstants.GWAS_ONTOLOGY_SCHEMA_IRI));
ImportChange gwasImport = new AddImport(conversion, gwasImportDecl);
getManager().applyChange(gwasImport);
OWLImportsDeclaration efoImportDecl = getDataFactory().getOWLImportsDeclaration(IRI.create(OntologyConstants.EFO_ONTOLOGY_SCHEMA_IRI));
ImportChange efoImport = new AddImport(conversion, efoImportDecl);
getManager().applyChange(efoImport);
return conversion;
} catch (OWLOntologyCreationException e) {
throw new OWLConversionException("Failed to create new ontology", e);
}
}
use of uk.ac.ebi.spot.goci.exception.OWLConversionException in project goci by EBISPOT.
the class DefaultGWASOWLPublisher method publishGWASDataInferredView.
public OWLReasoner publishGWASDataInferredView(OWLOntology ontology) throws OWLConversionException {
getLog().debug("Loading any missing imports...");
StringBuilder loadedOntologies = new StringBuilder();
int n = 1;
for (OWLOntology o : ontology.getOWLOntologyManager().getOntologies()) {
loadedOntologies.append("\t").append(n++).append(") ").append(o.getOntologyID().getOntologyIRI()).append("\n");
}
getLog().debug("Imports collected: the following ontologies have been loaded in this session:\n" + loadedOntologies.toString());
getLog().info("Classifying ontology from " + ontology.getOntologyID().getOntologyIRI());
getLog().debug("Creating reasoner... ");
OWLReasonerFactory factory = new Reasoner.ReasonerFactory();
ConsoleProgressMonitor progressMonitor = new ConsoleProgressMonitor();
OWLReasonerConfiguration config = new SimpleConfiguration(progressMonitor);
OWLReasoner reasoner = factory.createReasoner(ontology, config);
getLog().debug("Precomputing inferences...");
reasoner.precomputeInferences();
getLog().debug("Checking ontology consistency...");
reasoner.isConsistent();
getLog().debug("Checking for unsatisfiable classes...");
if (reasoner.getUnsatisfiableClasses().getEntitiesMinusBottom().size() > 0) {
throw new OWLConversionException("Once classified, unsatisfiable classes were detected");
} else {
getLog().info("Reasoning complete! ");
return reasoner;
}
}
use of uk.ac.ebi.spot.goci.exception.OWLConversionException in project goci by EBISPOT.
the class DefaultGWASOWLPublisher method saveGWASDataInferredView.
public void saveGWASDataInferredView(OWLReasoner reasoner, File outputFile) throws OWLConversionException {
try {
// create new ontology to hold inferred axioms
OWLOntology inferredOntology = getConverter().createConversionOntology();
getLog().info("Saving inferred view...");
List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
// we require all inferred stuff except for disjoints...
gens.add(new InferredClassAssertionAxiomGenerator());
gens.add(new InferredDataPropertyCharacteristicAxiomGenerator());
gens.add(new InferredEquivalentClassAxiomGenerator());
gens.add(new InferredEquivalentDataPropertiesAxiomGenerator());
gens.add(new InferredEquivalentObjectPropertyAxiomGenerator());
gens.add(new InferredInverseObjectPropertiesAxiomGenerator());
gens.add(new InferredObjectPropertyCharacteristicAxiomGenerator());
gens.add(new InferredPropertyAssertionGenerator());
gens.add(new InferredSubClassAxiomGenerator());
gens.add(new InferredSubDataPropertyAxiomGenerator());
gens.add(new InferredSubObjectPropertyAxiomGenerator());
// now create the target ontology and save
OWLOntologyManager inferredManager = inferredOntology.getOWLOntologyManager();
InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);
iog.fillOntology(inferredManager, inferredOntology);
inferredManager.saveOntology(inferredOntology, IRI.create(outputFile));
getLog().info("Inferred view saved ok");
} catch (OWLOntologyStorageException e) {
throw new OWLConversionException("Failed to save GWAS data (inferred view)", e);
}
}
use of uk.ac.ebi.spot.goci.exception.OWLConversionException in project goci by EBISPOT.
the class DefaultGWASOWLPublisher method saveGWASData.
public void saveGWASData(OWLOntology ontology, File outputFile) throws OWLConversionException {
try {
getLog().info("Saving GWAS catalog data...");
OWLOntologyFormat format = new RDFXMLOntologyFormat();
getManager().saveOntology(ontology, format, IRI.create(outputFile));
getLog().info("GWAS catalog data saved ok");
getLog().info("Resulting ontology contains " + ontology.getAxiomCount() + " axioms " + "and is saved at " + outputFile.getAbsolutePath());
} catch (OWLOntologyStorageException e) {
throw new OWLConversionException("Failed to save GWAS data", e);
}
}
use of uk.ac.ebi.spot.goci.exception.OWLConversionException in project goci by EBISPOT.
the class GOCIDataPublisherDriver method publishAndSave.
public void publishAndSave(File assertedOntologyFile, File inferredOntologyFile) throws RuntimeException {
try {
// publishAndSave the data
System.out.println("Attempting to convert and publish GWAS data as OWL...");
OWLOntology ontology = getGwasOwlPublisher().publishGWASData();
// and save the result
System.out.print("Ontology converted, saving asserted results...");
getGwasOwlPublisher().saveGWASData(ontology, assertedOntologyFile);
System.out.println("..done!");
if (inferredOntologyFile != null) {
// now get the inferred view
System.out.println("Evaluating inferred view...");
OWLReasoner reasoner = getGwasOwlPublisher().publishGWASDataInferredView(ontology);
// now save inferred view
System.out.print("Ontology fully classified, saving inferred results...");
getGwasOwlPublisher().saveGWASDataInferredView(reasoner, inferredOntologyFile);
System.out.println("..done!");
}
} catch (OWLConversionException e) {
System.err.println("Failed to publish data to OWL: " + e.getMessage());
getLog().error("Failed to publish data to OWL: ", e);
throw new RuntimeException(e);
} catch (Exception e) {
System.err.println("Failed to publish data to OWL (an unexpected exception occurred): " + e.getMessage());
getLog().error("Failed to publish data to OWL (an unexpected exception occurred): ", e);
throw new RuntimeException(e);
}
}
Aggregations