Search in sources :

Example 1 with JsonOwlIndividual

use of org.geneontology.minerva.json.JsonOwlIndividual in project minerva by geneontology.

the class ModelReasonerTest method testReasoner.

// FIXME @Test
public void testReasoner() throws Exception {
    List<M3Request> batch = new ArrayList<>();
    M3Request r;
    final String individualId = "http://model.geneontology.org/5525a0fc00000001/5525a0fc0000023";
    final IRI individualIRI = IRI.create(individualId);
    final String individualIdCurie = curieHandler.getCuri(individualIRI);
    final String modelId = "http://model.geneontology.org/5525a0fc00000001";
    final ModelContainer model = models.getModel(IRI.create(modelId));
    assertNotNull(model);
    boolean found = false;
    boolean foundCurie = false;
    Set<OWLNamedIndividual> individuals = model.getAboxOntology().getIndividualsInSignature();
    for (OWLNamedIndividual individual : individuals) {
        if (individualIRI.equals(individual.getIRI())) {
            found = true;
            foundCurie = individualIdCurie.equals(curieHandler.getCuri(individual.getIRI()));
        }
    }
    assertTrue(found);
    assertTrue(foundCurie);
    // get model
    r = new M3Request();
    r.entity = Entity.model;
    r.operation = Operation.get;
    r.arguments = new M3Argument();
    r.arguments.modelId = modelId;
    batch.add(r);
    M3BatchResponse response = executeBatch(batch);
    JsonOwlIndividual[] responseIndividuals = BatchTestTools.responseIndividuals(response);
    JsonOwlIndividual targetIndividual = null;
    for (JsonOwlIndividual individual : responseIndividuals) {
        if (individualIdCurie.equals(individual.id)) {
            targetIndividual = individual;
            break;
        }
    }
    assertNotNull(targetIndividual);
    assertNotNull(targetIndividual.inferredType);
    assertEquals("Expected two inferences", 2, targetIndividual.inferredType.length);
}
Also used : ArrayList(java.util.ArrayList) ModelContainer(org.geneontology.minerva.ModelContainer) JsonOwlIndividual(org.geneontology.minerva.json.JsonOwlIndividual)

Example 2 with JsonOwlIndividual

use of org.geneontology.minerva.json.JsonOwlIndividual in project minerva by geneontology.

the class UndoAwareMolecularModelManagerTest method testUndoRedo.

@Test
public void testUndoRedo() throws Exception {
    OWLOntology tbox = OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(this.getClass().getResourceAsStream("/go-mgi-signaling-test.obo"));
    m3 = new UndoAwareMolecularModelManager(tbox, curieHandler, "http://testmodel.geneontology.org/", folder.newFile().getAbsolutePath(), null, go_lego_journal_file, true);
    String userId = "test-user-id";
    ModelContainer model = m3.generateBlankModel(null);
    // GO:0001158 ! enhancer sequence-specific DNA binding
    OWLNamedIndividual bindingIdividual = m3.createIndividual(model.getModelId(), "GO:0001158", null, new UndoMetadata(userId));
    String bindingId = bindingIdividual.getIRI().toString();
    // BFO:0000066 GO:0005654 ! occurs_in nucleoplasm
    m3.addType(model.getModelId(), bindingId, "BFO:0000066", "GO:0005654", new UndoMetadata(userId));
    MolecularModelJsonRenderer renderer = new MolecularModelJsonRenderer(model, null, curieHandler);
    JsonOwlIndividual render1 = renderer.renderObject(bindingIdividual);
    assertEquals(2, render1.type.length);
    // check event count
    Pair<List<ChangeEvent>, List<ChangeEvent>> undoRedoEvents = m3.getUndoRedoEvents(model.getModelId());
    List<ChangeEvent> undoEvents = undoRedoEvents.getLeft();
    List<ChangeEvent> redoEvents = undoRedoEvents.getRight();
    assertEquals(0, redoEvents.size());
    assertEquals(2, undoEvents.size());
    // undo
    assertTrue(m3.undo(model, userId));
    JsonOwlIndividual render2 = renderer.renderObject(bindingIdividual);
    assertEquals(1, render2.type.length);
    // redo
    assertTrue(m3.redo(model, userId));
    JsonOwlIndividual render3 = renderer.renderObject(bindingIdividual);
    assertEquals(2, render3.type.length);
    // undo again
    assertTrue(m3.undo(model, userId));
    JsonOwlIndividual render4 = renderer.renderObject(bindingIdividual);
    assertEquals(1, render4.type.length);
    // add new type
    // GO:0001664 ! G-protein coupled receptor binding
    m3.addType(model.getModelId(), bindingId, "GO:0001664", new UndoMetadata(userId));
    // redo again, should fail
    assertFalse(m3.redo(model, userId));
    if (m3 != null) {
        m3.dispose();
    }
}
Also used : ChangeEvent(org.geneontology.minerva.UndoAwareMolecularModelManager.ChangeEvent) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) UndoMetadata(org.geneontology.minerva.UndoAwareMolecularModelManager.UndoMetadata) OWLNamedIndividual(org.semanticweb.owlapi.model.OWLNamedIndividual) List(java.util.List) JsonOwlIndividual(org.geneontology.minerva.json.JsonOwlIndividual) MolecularModelJsonRenderer(org.geneontology.minerva.json.MolecularModelJsonRenderer) Test(org.junit.Test)

Aggregations

JsonOwlIndividual (org.geneontology.minerva.json.JsonOwlIndividual)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ModelContainer (org.geneontology.minerva.ModelContainer)1 ChangeEvent (org.geneontology.minerva.UndoAwareMolecularModelManager.ChangeEvent)1 UndoMetadata (org.geneontology.minerva.UndoAwareMolecularModelManager.UndoMetadata)1 MolecularModelJsonRenderer (org.geneontology.minerva.json.MolecularModelJsonRenderer)1 Test (org.junit.Test)1 OWLNamedIndividual (org.semanticweb.owlapi.model.OWLNamedIndividual)1 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)1