Search in sources :

Example 1 with ModuleType

use of uk.ac.manchester.cs.owlapi.modularity.ModuleType in project minerva by geneontology.

the class InferenceProviderCreatorImpl method create.

// public static InferenceProviderCreator createHermiT(MinervaShexValidator shex) {
// int maxConcurrent = Runtime.getRuntime().availableProcessors();
// return createHermiT(maxConcurrent, shex);
// }
// public static InferenceProviderCreator createHermiT(int maxConcurrent, MinervaShexValidator shex) {
// return new InferenceProviderCreatorImpl(new org.semanticweb.HermiT.ReasonerFactory(), maxConcurrent, true, "Hermit-SLME", shex);
// }
@Override
public InferenceProvider create(ModelContainer model) throws OWLOntologyCreationException, InterruptedException, IOException {
    OWLOntology ont = model.getAboxOntology();
    final OWLOntologyManager m = ont.getOWLOntologyManager();
    OWLOntology module = null;
    OWLReasoner reasoner = null;
    OWLOntology temp_ont = null;
    try {
        InferenceProvider provider;
        synchronized (ont) {
            concurrentLock.acquire();
            try {
                if (useSLME) {
                    LOG.info("Creating for module: " + model.getModelId());
                    ModuleType mtype = ModuleType.BOT;
                    SyntacticLocalityModuleExtractor sme = new SyntacticLocalityModuleExtractor(m, ont, mtype);
                    Set<OWLEntity> seeds = new HashSet<OWLEntity>(ont.getIndividualsInSignature());
                    module = ont = sme.extractAsOntology(seeds, IRI.generateDocumentIRI());
                    LOG.info("Done creating module: " + model.getModelId());
                }
                // add root types for gene products.
                // TODO investigate performance impact
                // tradefoff these queries versus loading all possible genes into tbox
                // temp_ont = addRootTypesToCopy(ont, shex.externalLookupService);
                temp_ont = addAllInferredTypesToCopyLocalOntoBlazegraph(ont);
                // do reasoning and validation on the enhanced model
                reasoner = rf.createReasoner(temp_ont);
                provider = MapInferenceProvider.create(reasoner, temp_ont, shex);
            } finally {
                concurrentLock.release();
            }
        }
        return provider;
    } finally {
        if (reasoner != null) {
            reasoner.dispose();
        }
        if (module != null) {
            m.removeOntology(module);
        }
        if (temp_ont != null) {
            temp_ont.getOWLOntologyManager().removeOntology(temp_ont);
        }
    }
}
Also used : ModuleType(uk.ac.manchester.cs.owlapi.modularity.ModuleType) InferenceProvider(org.geneontology.minerva.json.InferenceProvider) OWLReasoner(org.semanticweb.owlapi.reasoner.OWLReasoner) SyntacticLocalityModuleExtractor(uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor)

Aggregations

InferenceProvider (org.geneontology.minerva.json.InferenceProvider)1 OWLReasoner (org.semanticweb.owlapi.reasoner.OWLReasoner)1 ModuleType (uk.ac.manchester.cs.owlapi.modularity.ModuleType)1 SyntacticLocalityModuleExtractor (uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor)1