Search in sources :

Example 6 with UndoAwareMolecularModelManager

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

the class ParallelModelReasonerTest method init.

static void init(ParserWrapper pw) throws OWLOntologyCreationException, IOException {
    // FIXME need more from go-lego
    final OWLOntology tbox = OWLManager.createOWLOntologyManager().loadOntology(IRI.create(new File("src/test/resources/go-lego-minimal.owl")));
    // curie handler
    final String modelIdcurie = "gomodel";
    final String modelIdPrefix = "http://model.geneontology.org/";
    final CurieMappings localMappings = new CurieMappings.SimpleCurieMappings(Collections.singletonMap(modelIdcurie, modelIdPrefix));
    curieHandler = new MappedCurieHandler(DefaultCurieHandler.loadDefaultMappings(), localMappings);
    models = new UndoAwareMolecularModelManager(tbox, curieHandler, modelIdPrefix, folder.newFile().getAbsolutePath(), null, go_lego_journal_file, true);
    ipc = new CountingCachingInferenceProvider(false);
    handler = new JsonOrJsonpBatchHandler(models, "development", ipc, Collections.<OWLObjectProperty>emptySet(), (ExternalLookupService) null);
// models.setPathToOWLFiles("src/test/resources/reasoner-test");
}
Also used : MappedCurieHandler(org.geneontology.minerva.curie.MappedCurieHandler) CurieMappings(org.geneontology.minerva.curie.CurieMappings) UndoAwareMolecularModelManager(org.geneontology.minerva.UndoAwareMolecularModelManager) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) File(java.io.File) OWLObjectProperty(org.semanticweb.owlapi.model.OWLObjectProperty) ExternalLookupService(org.geneontology.minerva.lookup.ExternalLookupService)

Example 7 with UndoAwareMolecularModelManager

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

the class ValidationTest method validateGoCams.

public static void validateGoCams(String input, boolean should_fail, boolean check_shex) throws Exception {
    String blazegraph_journal = makeBlazegraphJournal(input);
    UndoAwareMolecularModelManager m3 = new UndoAwareMolecularModelManager(tbox_ontology, curieHandler, modelIdPrefix, blazegraph_journal, null, go_lego_journal_file, true);
    try {
        URL shex_schema_url = new URL(shexFileUrl);
        // for some reason the temporary_model file won't parse..
        File shex_schema_file = new File("src/test/resources/validate.shex");
        org.apache.commons.io.FileUtils.copyURLToFile(shex_schema_url, shex_schema_file);
        URL shex_map_url = new URL(goshapemapFileUrl);
        File shex_map_file = new File("src/test/resources/validate.shapemap");
        org.apache.commons.io.FileUtils.copyURLToFile(shex_map_url, shex_map_file);
        MinervaShexValidator shex = new MinervaShexValidator(shex_schema_file, shex_map_file, curieHandler, m3.getGolego_repo());
        if (check_shex) {
            if (check_shex) {
                shex.setActive(true);
            } else {
                shex.setActive(false);
            }
        }
        InferenceProviderCreator ipc = StartUpTool.createInferenceProviderCreator("arachne", m3, shex);
        LOGGER.info("Validating models:");
        m3.getAvailableModelIds().stream().forEach(modelIRI -> {
            boolean isConsistent = true;
            boolean isConformant = true;
            LOGGER.info("processing \t" + modelIRI);
            ModelContainer mc = m3.getModel(modelIRI);
            Set<OWLAnnotation> annos = mc.getAboxOntology().getAnnotations();
            // this is where everything actually happens
            InferenceProvider ip;
            try {
                // this ipc.create method results in the execution of the OWL reasoner and, if shex is set to active, the shex validation
                ip = ipc.create(mc);
                isConsistent = ip.isConsistent();
                if (!should_fail) {
                    assertTrue(modelIRI + " is assessed to be (OWL) inconsistent but should not be.", isConsistent);
                } else if (!check_shex) {
                    assertFalse(modelIRI + " is assessed to be (OWL) consistent but should not be.", isConsistent);
                }
                if (check_shex) {
                    ValidationResultSet validations = ip.getValidation_results();
                    isConformant = validations.allConformant();
                    if (!should_fail) {
                        assertTrue(modelIRI + " does not conform to the shex schema and it should: \n" + annos, isConformant);
                    } else {
                        assertFalse(modelIRI + " conforms to the shex schema and it should not: \n" + annos, isConformant);
                    }
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        });
        LOGGER.info("done with validation");
    } finally {
        m3.dispose();
    }
}
Also used : UndoAwareMolecularModelManager(org.geneontology.minerva.UndoAwareMolecularModelManager) InferenceProviderCreator(org.geneontology.minerva.server.inferences.InferenceProviderCreator) InferenceProvider(org.geneontology.minerva.json.InferenceProvider) ModelContainer(org.geneontology.minerva.ModelContainer) URL(java.net.URL) RepositoryException(org.openrdf.repository.RepositoryException) RDFHandlerException(org.openrdf.rio.RDFHandlerException) IOException(java.io.IOException) RDFParseException(org.openrdf.rio.RDFParseException) File(java.io.File) ValidationResultSet(org.geneontology.minerva.validation.ValidationResultSet)

Example 8 with UndoAwareMolecularModelManager

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

the class ModelReasonerTest method init.

static void init() throws OWLOntologyCreationException, IOException {
    // FIXME need more from go-lego
    final OWLOntology tbox = OWLManager.createOWLOntologyManager().loadOntology(IRI.create(new File("src/test/resources/go-lego-minimal.owl")));
    // curie handler
    final String modelIdcurie = "gomodel";
    final String modelIdPrefix = "http://model.geneontology.org/";
    final CurieMappings localMappings = new CurieMappings.SimpleCurieMappings(Collections.singletonMap(modelIdcurie, modelIdPrefix));
    curieHandler = new MappedCurieHandler(DefaultCurieHandler.loadDefaultMappings(), localMappings);
    models = new UndoAwareMolecularModelManager(tbox, curieHandler, modelIdPrefix, folder.newFile().getAbsolutePath(), null, go_lego_journal_file, true);
    InferenceProviderCreator ipc = CachingInferenceProviderCreatorImpl.createElk(false, null);
    handler = new JsonOrJsonpBatchHandler(models, "development", ipc, Collections.<OWLObjectProperty>emptySet(), (ExternalLookupService) null);
// models.setPathToOWLFiles("src/test/resources/reasoner-test");
}
Also used : MappedCurieHandler(org.geneontology.minerva.curie.MappedCurieHandler) CurieMappings(org.geneontology.minerva.curie.CurieMappings) UndoAwareMolecularModelManager(org.geneontology.minerva.UndoAwareMolecularModelManager) InferenceProviderCreator(org.geneontology.minerva.server.inferences.InferenceProviderCreator) File(java.io.File) ExternalLookupService(org.geneontology.minerva.lookup.ExternalLookupService)

Example 9 with UndoAwareMolecularModelManager

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

the class ModelSearchHandlerTest method setUpBeforeClass.

/**
 * @throws java.lang.Exception
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    LOGGER.info("Set up molecular model manager - loading files into a journal");
    // set curie handler
    String modelIdPrefix = "http://model.geneontology.org/";
    String modelIdcurie = "gomodel";
    final CurieMappings localMappings = new CurieMappings.SimpleCurieMappings(Collections.singletonMap(modelIdcurie, modelIdPrefix));
    curieHandler = new MappedCurieHandler(DefaultCurieHandler.loadDefaultMappings(), localMappings);
    String valid_model_folder = "src/test/resources/models/should_pass/";
    String model_save = "src/test/resources/models/tmp/";
    String inputDB = makeBlazegraphJournal(valid_model_folder);
    // leave tbox empty for now
    OWLOntologyManager ontman = OWLManager.createOWLOntologyManager();
    tbox_ontology = ontman.createOntology(IRI.create("http://example.org/dummy"));
    models = new UndoAwareMolecularModelManager(tbox_ontology, curieHandler, modelIdPrefix, inputDB, model_save, go_lego_journal_file, true);
    models.addTaxonMetadata();
    LOGGER.info("Setup Jetty config.");
    // Configuration: Use an already existing handler instance
    // Configuration: Use custom JSON renderer (GSON)
    ResourceConfig resourceConfig = new ResourceConfig();
    resourceConfig.register(GsonMessageBodyHandler.class);
    resourceConfig.register(RequireJsonpFilter.class);
    ModelSearchHandler searchHandler = new ModelSearchHandler(models);
    resourceConfig = resourceConfig.registerInstances(searchHandler);
    // setup jetty server port, buffers and context path
    server = new Server();
    // create connector with port and custom buffer sizes
    HttpConfiguration http_config = new HttpConfiguration();
    int requestHeaderSize = 64 * 1024;
    int requestBufferSize = 128 * 1024;
    int port = 6800;
    String contextString = "/";
    http_config.setRequestHeaderSize(requestHeaderSize);
    ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(http_config));
    connector.setPort(port);
    server.addConnector(connector);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath(contextString);
    server.setHandler(context);
    ServletHolder h = new ServletHolder(new ServletContainer(resourceConfig));
    context.addServlet(h, "/*");
    // start jetty server
    LOGGER.info("Start server on port: " + port + " context: " + contextString);
    server.start();
    // set up a handler for testing with M3BatchRequest service
    handler = new JsonOrJsonpBatchHandler(models, "development", null, Collections.<OWLObjectProperty>emptySet(), (ExternalLookupService) null);
}
Also used : MappedCurieHandler(org.geneontology.minerva.curie.MappedCurieHandler) CurieMappings(org.geneontology.minerva.curie.CurieMappings) Server(org.eclipse.jetty.server.Server) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) UndoAwareMolecularModelManager(org.geneontology.minerva.UndoAwareMolecularModelManager) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) ServerConnector(org.eclipse.jetty.server.ServerConnector) ServletContainer(org.glassfish.jersey.servlet.ServletContainer) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) ExternalLookupService(org.geneontology.minerva.lookup.ExternalLookupService)

Example 10 with UndoAwareMolecularModelManager

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

the class TaxonHandlerTest method setUpBeforeClass.

/**
 * @throws java.lang.Exception
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    LOGGER.info("Set up molecular model manager - loading files into a journal");
    // set curie handler
    String modelIdPrefix = "http://model.geneontology.org/";
    String modelIdcurie = "gomodel";
    curieHandler = new MappedCurieHandler();
    String valid_model_folder = "src/test/resources/models/should_pass/";
    String inputDB = makeBlazegraphJournal(valid_model_folder);
    // leave tbox empty for now
    OWLOntologyManager ontman = OWLManager.createOWLOntologyManager();
    tbox_ontology = ontman.createOntology(IRI.create("http://example.org/dummy"));
    UndoAwareMolecularModelManager models = new UndoAwareMolecularModelManager(tbox_ontology, curieHandler, modelIdPrefix, inputDB, null, go_lego_journal_file, true);
    models.addTaxonMetadata();
    LOGGER.info("Setup Jetty config.");
    // Configuration: Use an already existing handler instance
    // Configuration: Use custom JSON renderer (GSON)
    ResourceConfig resourceConfig = new ResourceConfig();
    resourceConfig.register(GsonMessageBodyHandler.class);
    resourceConfig.register(RequireJsonpFilter.class);
    taxonHandler = new TaxonHandler(models);
    resourceConfig = resourceConfig.registerInstances(taxonHandler);
    // setup jetty server port, buffers and context path
    server = new Server();
    // create connector with port and custom buffer sizes
    HttpConfiguration http_config = new HttpConfiguration();
    int requestHeaderSize = 64 * 1024;
    int requestBufferSize = 128 * 1024;
    int port = 6800;
    String contextString = "/";
    http_config.setRequestHeaderSize(requestHeaderSize);
    ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(http_config));
    connector.setPort(port);
    server.addConnector(connector);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath(contextString);
    server.setHandler(context);
    ServletHolder h = new ServletHolder(new ServletContainer(resourceConfig));
    context.addServlet(h, "/*");
    // start jetty server
    LOGGER.info("Start server on port: " + port + " context: " + contextString);
    server.start();
}
Also used : MappedCurieHandler(org.geneontology.minerva.curie.MappedCurieHandler) Server(org.eclipse.jetty.server.Server) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) UndoAwareMolecularModelManager(org.geneontology.minerva.UndoAwareMolecularModelManager) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) ServerConnector(org.eclipse.jetty.server.ServerConnector) ServletContainer(org.glassfish.jersey.servlet.ServletContainer) OWLOntologyManager(org.semanticweb.owlapi.model.OWLOntologyManager) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Aggregations

UndoAwareMolecularModelManager (org.geneontology.minerva.UndoAwareMolecularModelManager)14 MappedCurieHandler (org.geneontology.minerva.curie.MappedCurieHandler)11 File (java.io.File)9 CurieMappings (org.geneontology.minerva.curie.CurieMappings)8 InferenceProviderCreator (org.geneontology.minerva.server.inferences.InferenceProviderCreator)7 ExternalLookupService (org.geneontology.minerva.lookup.ExternalLookupService)6 ModelContainer (org.geneontology.minerva.ModelContainer)5 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)4 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)4 Server (org.eclipse.jetty.server.Server)4 ServerConnector (org.eclipse.jetty.server.ServerConnector)4 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)4 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)4 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)4 ServletContainer (org.glassfish.jersey.servlet.ServletContainer)4 Test (org.junit.Test)4 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)4 CurieHandler (org.geneontology.minerva.curie.CurieHandler)3 OWLOntologyManager (org.semanticweb.owlapi.model.OWLOntologyManager)3 URL (java.net.URL)2