use of org.geneontology.rules.engine.WorkingMemory in project minerva by geneontology.
the class GPADSPARQLTest method testSuppressUberonExtensionsWhenEMAPA.
/**
* This test needs improvements; the current background axioms used in the tests are resulting in the Uberon inference we're trying to avoid
*
* @throws Exception
*/
@Test
public void testSuppressUberonExtensionsWhenEMAPA() throws Exception {
Model model = ModelFactory.createDefaultModel();
model.read(this.getClass().getResourceAsStream("/no_uberon_with_emapa.ttl"), "", "ttl");
Set<Triple> triples = model.listStatements().toList().stream().map(s -> Bridge.tripleFromJena(s.asTriple())).collect(Collectors.toSet());
WorkingMemory mem = arachne.processTriples(JavaConverters.asScalaSetConverter(triples).asScala());
Set<GPADData> annotations = exporter.getGPAD(mem, IRI.create("http://test.org"));
Assert.assertTrue(annotations.stream().anyMatch(a -> a.getAnnotationExtensions().stream().anyMatch(e -> e.getFiller().toString().startsWith("http://purl.obolibrary.org/obo/EMAPA_"))));
Assert.assertTrue(annotations.stream().noneMatch(a -> a.getAnnotationExtensions().stream().anyMatch(e -> e.getFiller().toString().startsWith("http://purl.obolibrary.org/obo/UBERON_"))));
}
use of org.geneontology.rules.engine.WorkingMemory in project minerva by geneontology.
the class GPADSPARQLTest method testGPADContainsAcceptedAndCreatedDates.
@Test
@Ignore
public void testGPADContainsAcceptedAndCreatedDates() throws Exception {
Model model = ModelFactory.createDefaultModel();
model.read(this.getClass().getResourceAsStream("/created-date-test.ttl"), "", "ttl");
Set<Triple> triples = model.listStatements().toList().stream().map(s -> Bridge.tripleFromJena(s.asTriple())).collect(Collectors.toSet());
WorkingMemory mem = arachne.processTriples(JavaConverters.asScalaSetConverter(triples).asScala());
Set<GPADData> annotations = exporter.getGPAD(mem, IRI.create("http://test.org"));
IRI gene = IRI.create("http://identifiers.org/wormbase/WBGene00001326");
Pair<String, String> creationDate = Pair.of("creation-date", "2021-05-13");
Assert.assertTrue(annotations.stream().anyMatch(a -> a.getObject().equals(gene) && a.getAnnotations().contains(creationDate)));
}
use of org.geneontology.rules.engine.WorkingMemory in project minerva by geneontology.
the class GPADSPARQLTest method testGPADOutput.
@Test
public void testGPADOutput() throws Exception {
Model model = ModelFactory.createDefaultModel();
model.read(this.getClass().getResourceAsStream("/581e072c00000473.ttl"), "", "ttl");
Set<Triple> triples = model.listStatements().toList().stream().map(s -> Bridge.tripleFromJena(s.asTriple())).collect(Collectors.toSet());
WorkingMemory mem = arachne.processTriples(JavaConverters.asScalaSetConverter(triples).asScala());
String gpad = exporter.exportGPAD(mem, IRI.create("http://test.org"));
int lines = gpad.split("\n", -1).length;
// TODO test contents of annotations; dumb test for now
Assert.assertTrue(gpad.contains("model-state=production"));
Assert.assertTrue("Should produce annotations", lines > 2);
}
use of org.geneontology.rules.engine.WorkingMemory in project minerva by geneontology.
the class CoreMolecularModelManager method createCanonicalInferredModel.
public WorkingMemory createCanonicalInferredModel(IRI modelId) {
// swap out any non-canonical types
OWLOntology source_abox = getModelAbox(modelId);
OWLOntologyManager aman = OWLManager.createOWLOntologyManager();
OWLDataFactory df = aman.getOWLDataFactory();
OWLAnnotationProperty canonical_record = df.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/canonical_record"));
OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory();
try {
OWLOntology abox = aman.copyOntology(source_abox, OntologyCopy.DEEP);
OWLReasoner abox_reasoner = reasonerFactory.createReasoner(abox);
// convert to canonical wherever possible
abox.getIndividualsInSignature().forEach(i -> {
Set<OWLClass> types = abox_reasoner.getTypes(i, true).getFlattened();
for (OWLClass type : types) {
Collection<OWLAnnotation> canons = EntitySearcher.getAnnotationObjects(type, tbox, canonical_record);
// more correct to create new instances for each
if (canons != null && canons.size() > 0) {
for (OWLAnnotation canon : canons) {
if (canon.getValue().asIRI().isPresent()) {
OWLClass canonical = df.getOWLClass(canon.getValue().asIRI().get());
// direct swap
// remove the old one
OWLClassAssertionAxiom original = df.getOWLClassAssertionAxiom(type, i);
aman.removeAxiom(abox, original);
// add the new one
OWLClassAssertionAxiom canonical_type = df.getOWLClassAssertionAxiom(canonical, i);
aman.addAxiom(abox, canonical_type);
}
}
}
}
});
WorkingMemory inferred = createInferredModel(abox, modelId);
abox_reasoner.dispose();
aman.removeOntology(abox);
return inferred;
} catch (OWLOntologyCreationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return createInferredModel(source_abox, modelId);
}
}
Aggregations