Search in sources :

Example 1 with OWLValidationReport

use of org.geneontology.minerva.validation.OWLValidationReport in project minerva by geneontology.

the class MapInferenceProvider method create.

public static InferenceProvider create(OWLReasoner r, OWLOntology ont, MinervaShexValidator shex) throws OWLOntologyCreationException, IOException {
    Map<OWLNamedIndividual, Set<OWLClass>> inferredTypes = new HashMap<>();
    Map<OWLNamedIndividual, Set<OWLClass>> inferredTypesWithIndirects = new HashMap<>();
    boolean isConsistent = r.isConsistent();
    if (isConsistent) {
        Set<OWLNamedIndividual> individuals = ont.getIndividualsInSignature();
        for (OWLNamedIndividual individual : individuals) {
            Set<OWLClass> inferred = new HashSet<>();
            Set<OWLClass> flattened = r.getTypes(individual, true).getFlattened();
            for (OWLClass cls : flattened) {
                if (cls.isBuiltIn() == false) {
                    inferred.add(cls);
                }
            }
            inferredTypes.put(individual, inferred);
            // adding the rest of the types
            // TODO consider filtering down to root types - depending on use cases
            Set<OWLClass> all_inferred = new HashSet<>();
            Set<OWLClass> all_flattened = r.getTypes(individual, false).getFlattened();
            for (OWLClass cls : all_flattened) {
                if (cls.isBuiltIn() == false) {
                    all_inferred.add(cls);
                }
            }
            inferredTypesWithIndirects.put(individual, all_inferred);
        }
    }
    // reasoner
    OWLValidationReport reasoner_validation = new OWLValidationReport();
    reasoner_validation.setConformant(isConsistent);
    if (!isConsistent) {
        Violation i_v = new Violation("id of inconsistent node");
        reasoner_validation.addViolation(i_v);
    }
    // shex
    ShexValidationReport shex_validation = new ShexValidationReport();
    if (shex.isActive()) {
        // generate an RDF model
        Model model = JenaOwlTool.getJenaModel(ont);
        // add superclasses to types used in model - needed for shex to find everything
        // model may now have additional inferred assertions from Arachne
        model = shex.enrichSuperClasses(model);
        try {
            LOGGER.info("Running shex validation - model (enriched with superclass hierarchy) size:" + model.size());
            shex_validation = shex.runShapeMapValidation(model);
            LOGGER.info("Done with shex validation. model is conformant is: " + shex_validation.isConformant());
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    ValidationResultSet all_validations = new ValidationResultSet(reasoner_validation, shex_validation);
    return new MapInferenceProvider(isConsistent, inferredTypes, inferredTypesWithIndirects, all_validations);
}
Also used : Violation(org.geneontology.minerva.validation.Violation) ShexValidationReport(org.geneontology.minerva.validation.ShexValidationReport) ValidationResultSet(org.geneontology.minerva.validation.ValidationResultSet) OWLOntologyCreationException(org.semanticweb.owlapi.model.OWLOntologyCreationException) IOException(java.io.IOException) OWLNamedIndividual(org.semanticweb.owlapi.model.OWLNamedIndividual) Model(org.apache.jena.rdf.model.Model) OWLClass(org.semanticweb.owlapi.model.OWLClass) ValidationResultSet(org.geneontology.minerva.validation.ValidationResultSet) OWLValidationReport(org.geneontology.minerva.validation.OWLValidationReport)

Aggregations

IOException (java.io.IOException)1 Model (org.apache.jena.rdf.model.Model)1 OWLValidationReport (org.geneontology.minerva.validation.OWLValidationReport)1 ShexValidationReport (org.geneontology.minerva.validation.ShexValidationReport)1 ValidationResultSet (org.geneontology.minerva.validation.ValidationResultSet)1 Violation (org.geneontology.minerva.validation.Violation)1 OWLClass (org.semanticweb.owlapi.model.OWLClass)1 OWLNamedIndividual (org.semanticweb.owlapi.model.OWLNamedIndividual)1 OWLOntologyCreationException (org.semanticweb.owlapi.model.OWLOntologyCreationException)1