Search in sources :

Example 6 with ModelContainer

use of org.geneontology.minerva.ModelContainer in project minerva by geneontology.

the class ModelARTHandler method addToModel.

private void addToModel(String modelId, ModelARTResult result) throws Exception {
    IRI modelIri = curieHandler.getIRI(modelId);
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLOntology currentOntology = m3.getModelAbox(modelIri);
    OWLOntology storedOntology = m3.loadModelABox(modelIri, manager);
    // OWLOntology stored_ontology = man1.copyOntology(storedOntology, OntologyCopy.DEEP);
    ModelContainer storedMC = new ModelContainer(modelIri, null, storedOntology);
    final MolecularModelJsonRenderer storedRenderer = createModelRenderer(storedMC, go_lego, null, curieHandler);
    JsonModel jsonStoredModel = storedRenderer.renderModel();
    ModelContainer activeMC = new ModelContainer(modelIri, null, currentOntology);
    InferenceProvider inferenceProvider = ipc.create(activeMC);
    final MolecularModelJsonRenderer renderer = createModelRenderer(activeMC, go_lego, inferenceProvider, curieHandler);
    JsonModel jsonActiveModel = renderer.renderModel();
    result.storedModel = jsonStoredModel;
    result.activeModel = jsonActiveModel;
    result.diffModel = getDiff(jsonStoredModel, jsonActiveModel);
}
Also used : IRI(org.semanticweb.owlapi.model.IRI) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) JsonModel(org.geneontology.minerva.json.JsonModel) InferenceProvider(org.geneontology.minerva.json.InferenceProvider) OWLOntologyManager(org.semanticweb.owlapi.model.OWLOntologyManager) ModelContainer(org.geneontology.minerva.ModelContainer) MolecularModelJsonRenderer(org.geneontology.minerva.json.MolecularModelJsonRenderer)

Example 7 with ModelContainer

use of org.geneontology.minerva.ModelContainer in project minerva by geneontology.

the class ModelCreator method createModel.

ModelContainer createModel(String userId, Set<String> providerGroups, UndoMetadata token, VariableResolver resolver, JsonAnnotation[] annotationValues) throws UnknownIdentifierException, OWLOntologyCreationException {
    ModelContainer model = m3.generateBlankModel(token);
    Set<OWLAnnotation> annotations = extract(annotationValues, userId, providerGroups, resolver, model);
    annotations = addDefaultModelState(annotations, model.getOWLDataFactory());
    if (annotations != null) {
        m3.addModelAnnotations(model, annotations, token);
    }
    updateModelAnnotations(model, userId, providerGroups, token, m3);
    // Disallow undo of initial annotations
    m3.clearUndoHistory(model.getModelId());
    return model;
}
Also used : ModelContainer(org.geneontology.minerva.ModelContainer)

Example 8 with ModelContainer

use of org.geneontology.minerva.ModelContainer in project minerva by geneontology.

the class GoCamModelTest method testRootTypesForComplements.

@Test
public void testRootTypesForComplements() throws Exception {
    String ontologyJournalFile = "/tmp/test-go-lego-blazegraph-complements.jnl";
    OWLOntologyManager man = OWLManager.createOWLOntologyManager();
    OWLOntology tboxOntology = man.loadOntologyFromOntologyDocument(new File("src/test/resources/go-basic.obo"));
    CurieHandler curieHandler = new MappedCurieHandler();
    String inputDB = "/tmp/test-blazegraph-models-complements.jnl";
    UndoAwareMolecularModelManager m3 = null;
    m3 = new UndoAwareMolecularModelManager(tboxOntology, curieHandler, "gomodel", inputDB, null, ontologyJournalFile, true);
    m3.importModelToDatabase(new File("src/test/resources/test-complement-roots.ttl"), true);
    ModelContainer mc = m3.getModel(IRI.create("http://model.geneontology.org/61f3310500000003"));
    OWLOntology gocam_via_mc = mc.getAboxOntology();
    GoCamModel g = new GoCamModel(gocam_via_mc, m3);
    assertTrue("Can get roots for classes and complements", g.ind_types.get(man.getOWLDataFactory().getOWLNamedIndividual(IRI.create("http://model.geneontology.org/61f3310500000003/61f3310500000004"))).contains("http://purl.obolibrary.org/obo/GO_0008150"));
    assertTrue("Can get roots for classes and complements", g.ind_types.get(man.getOWLDataFactory().getOWLNamedIndividual(IRI.create("http://model.geneontology.org/61f3310500000003/61f3310500000005"))).contains("http://purl.obolibrary.org/obo/GO_0008150"));
    m3.getGolego_repo().dispose();
}
Also used : MappedCurieHandler(org.geneontology.minerva.curie.MappedCurieHandler) UndoAwareMolecularModelManager(org.geneontology.minerva.UndoAwareMolecularModelManager) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) CurieHandler(org.geneontology.minerva.curie.CurieHandler) MappedCurieHandler(org.geneontology.minerva.curie.MappedCurieHandler) OWLOntologyManager(org.semanticweb.owlapi.model.OWLOntologyManager) ModelContainer(org.geneontology.minerva.ModelContainer) File(java.io.File) Test(org.junit.Test)

Example 9 with ModelContainer

use of org.geneontology.minerva.ModelContainer in project minerva by geneontology.

the class GoCamModelTest method testGoModelStats.

@Test
public void testGoModelStats() throws Exception {
    OWLOntologyManager man = OWLManager.createOWLOntologyManager();
    OWLOntology tbox_ontology = man.loadOntology(IRI.create("http://purl.obolibrary.org/obo/go/extensions/go-lego.owl"));
    CurieHandler curieHandler = new MappedCurieHandler();
    String inputDB = "/tmp/test-blazegraph-models.jnl";
    // load it into a journal and launch an m3
    UndoAwareMolecularModelManager m3 = null;
    File f = new File(gocam_dir);
    if (f.isDirectory()) {
        // remove anything that existed from previous runs
        File bgdb = new File(inputDB);
        if (bgdb.exists()) {
            bgdb.delete();
        }
        // set it up with empty db
        m3 = new UndoAwareMolecularModelManager(tbox_ontology, curieHandler, "gomodel", inputDB, null, ontology_journal_file, true);
        onto_repo = m3.getGolego_repo();
        // load the db
        for (File file : f.listFiles()) {
            if (file.getName().endsWith("ttl")) {
                m3.importModelToDatabase(file, true);
            }
        }
    }
    // read it back out and check on stats
    for (IRI modelIRI : m3.getAvailableModelIds()) {
        ModelContainer mc = m3.getModel(modelIRI);
        OWLOntology gocam_via_mc = mc.getAboxOntology();
        GoCamModel g = new GoCamModel(gocam_via_mc, m3);
        // testing for an issue with the OWL blazegraph loader
        assertFalse("title not read out of M3 retrieved model " + modelIRI, (g.getTitle() == null));
        // these reactions are not counted as activities, but causal relations coming from them are counted.
        if (modelIRI.toString().contains("R-HSA-5654719")) {
            // SHC-mediated cascade:FGFR4
            assertTrue("wrong n activities " + g.getStats().n_activity_units, g.getStats().n_activity_units == 4);
            assertTrue("wrong n complete activities " + g.getStats().n_complete_activity_units, g.getStats().n_complete_activity_units == 2);
            assertTrue("wrong n unenabled activities " + g.getStats().n_no_enabler, g.getStats().n_no_enabler == 2);
            assertTrue("wrong n causal relations " + g.getStats().n_causal_in_relation_assertions, g.getStats().n_causal_in_relation_assertions == 6);
        } else if (modelIRI.toString().contains("R-HSA-201688")) {
            // WNT mediated activation of DVL
            assertTrue("wrong n activities " + g.getStats().n_activity_units, g.getStats().n_activity_units == 4);
            assertTrue("wrong n complete activities " + g.getStats().n_complete_activity_units, g.getStats().n_complete_activity_units == 3);
            assertTrue("wrong n unenabled activities " + g.getStats().n_no_enabler, g.getStats().n_no_enabler == 1);
            assertTrue("wrong n causal relations " + g.getStats().n_causal_in_relation_assertions, g.getStats().n_causal_in_relation_assertions == 3);
        } else if (modelIRI.toString().contains("R-HSA-5654733")) {
            // Negative regulation of FGFR4 signaling
            assertTrue("wrong n activities " + g.getStats().n_activity_units, g.getStats().n_activity_units == 3);
            assertTrue("wrong n complete activities " + g.getStats().n_complete_activity_units, g.getStats().n_complete_activity_units == 2);
            assertTrue("wrong n unenabled activities " + g.getStats().n_no_enabler, g.getStats().n_no_enabler == 1);
            assertTrue("wrong n causal relations " + g.getStats().n_causal_in_relation_assertions, g.getStats().n_causal_in_relation_assertions == 3);
        }
    }
}
Also used : MappedCurieHandler(org.geneontology.minerva.curie.MappedCurieHandler) IRI(org.semanticweb.owlapi.model.IRI) UndoAwareMolecularModelManager(org.geneontology.minerva.UndoAwareMolecularModelManager) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) CurieHandler(org.geneontology.minerva.curie.CurieHandler) MappedCurieHandler(org.geneontology.minerva.curie.MappedCurieHandler) OWLOntologyManager(org.semanticweb.owlapi.model.OWLOntologyManager) ModelContainer(org.geneontology.minerva.ModelContainer) File(java.io.File) Test(org.junit.Test)

Aggregations

ModelContainer (org.geneontology.minerva.ModelContainer)9 UndoAwareMolecularModelManager (org.geneontology.minerva.UndoAwareMolecularModelManager)5 Test (org.junit.Test)4 File (java.io.File)3 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)3 OWLOntologyManager (org.semanticweb.owlapi.model.OWLOntologyManager)3 UndoMetadata (org.geneontology.minerva.UndoAwareMolecularModelManager.UndoMetadata)2 CurieHandler (org.geneontology.minerva.curie.CurieHandler)2 MappedCurieHandler (org.geneontology.minerva.curie.MappedCurieHandler)2 InferenceProvider (org.geneontology.minerva.json.InferenceProvider)2 InferenceProviderCreator (org.geneontology.minerva.server.inferences.InferenceProviderCreator)2 IRI (org.semanticweb.owlapi.model.IRI)2 IOException (java.io.IOException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 JsonModel (org.geneontology.minerva.json.JsonModel)1 JsonOwlIndividual (org.geneontology.minerva.json.JsonOwlIndividual)1 MolecularModelJsonRenderer (org.geneontology.minerva.json.MolecularModelJsonRenderer)1 ValidationResultSet (org.geneontology.minerva.validation.ValidationResultSet)1