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);
}
Aggregations