Search in sources :

Example 11 with MappedCurieHandler

use of org.geneontology.minerva.curie.MappedCurieHandler 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 12 with MappedCurieHandler

use of org.geneontology.minerva.curie.MappedCurieHandler 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 13 with MappedCurieHandler

use of org.geneontology.minerva.curie.MappedCurieHandler 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)

Example 14 with MappedCurieHandler

use of org.geneontology.minerva.curie.MappedCurieHandler in project minerva by geneontology.

the class StartUpTool method main.

public static void main(String[] args) throws Exception {
    Opts opts = new Opts(args);
    MinervaStartUpConfig conf = new MinervaStartUpConfig();
    while (opts.hasArgs()) {
        if (opts.nextEq("-g|--graph")) {
            conf.ontology = opts.nextOpt();
        } else if (opts.nextEq("-c|--catalog")) {
            conf.catalog = opts.nextOpt();
        } else if (opts.nextEq("-f|--journal-file")) {
            conf.journalFile = opts.nextOpt();
        } else if (opts.nextEq("--export-folder")) {
            conf.exportFolder = opts.nextOpt();
        } else if (opts.nextEq("--model-id-prefix")) {
            conf.modelIdPrefix = opts.nextOpt();
        } else if (opts.nextEq("--model-id-curie")) {
            conf.modelIdcurie = opts.nextOpt();
        } else if (opts.nextEq("-p|--protein-folder")) {
            System.err.println("specific protein ontologies are no longer supported");
            System.exit(-1);
        } else if (opts.nextEq("--gaf-folder")) {
            System.err.println("--gaf-folder is not longer supported");
            System.exit(-1);
        } else if (opts.nextEq("--context-prefix")) {
            conf.contextPrefix = opts.nextOpt();
        } else if (opts.nextEq("--port")) {
            conf.port = Integer.parseInt(opts.nextOpt());
        } else if (opts.nextEq("-i|--import|--additional-import")) {
            System.err.println("-i|--import|--additional-import is no longer supported, all imports are expected to be in the source ontology '-g|--graph'");
            System.exit(-1);
        } else if (opts.nextEq("--obsolete-import")) {
            System.err.println("--obsolete-import is no longer supported");
            System.exit(-1);
        } else if (opts.nextEq("--set-relevant-relations")) {
            System.err.println("--set-relevant-relations is no longer supported, use '--set-important-relation-parent' instead");
            System.exit(-1);
        } else if (opts.nextEq("--add-relevant-relations")) {
            System.err.println("--add-relevant-relations is no longer supported, use '--set-important-relation-parent' instead");
            System.exit(-1);
        } else if (opts.nextEq("--add-relevant-relation")) {
            System.err.println("--add-relevant-relation is no longer supported, use '--set-important-relation-parent' instead");
            System.exit(-1);
        } else if (opts.nextEq("--set-important-relation-parent")) {
            conf.importantRelationParent = opts.nextOpt();
        } else if (opts.nextEq("--skip-class-id-validation")) {
            conf.checkLiteralIds = false;
        } else if (opts.nextEq("--golr-cache-size")) {
            String sizeString = opts.nextOpt();
            conf.golrCacheSize = Integer.parseInt(sizeString);
        } else // --golr-labels http://noctua-golr.berkeleybop.org/
        if (opts.nextEq("--golr-labels")) {
            conf.golrUrl = opts.nextOpt();
        } else if (opts.nextEq("--monarch-labels")) {
            conf.monarchUrl = opts.nextOpt();
        } else if (opts.nextEq("--golr-seed")) {
            conf.golrSeedUrl = opts.nextOpt();
        } else if (opts.nextEq("--no-reasoning|--no-reasoner")) {
            conf.reasonerOpt = null;
        } else if (opts.nextEq("--slme-hermit")) {
            conf.reasonerOpt = "slme-hermit";
        } else if (opts.nextEq("--slme-elk")) {
            conf.reasonerOpt = "slme-elk";
        } else if (opts.nextEq("--elk")) {
            conf.reasonerOpt = "elk";
        } else if (opts.nextEq("--arachne")) {
            conf.reasonerOpt = "arachne";
        } else if (opts.nextEq("--use-request-logging|--request-logging")) {
            conf.useRequestLogging = true;
        } else if (opts.nextEq("--use-golr-url-logging|--golr-url-logging")) {
            conf.useGolrUrlLogging = true;
        } else if (opts.nextEq("--prefix-mappings")) {
            conf.prefixesFile = opts.nextOpt();
        } else if (opts.nextEq("--sparql-endpoint-timeout")) {
            conf.sparqlEndpointTimeout = Integer.parseInt(opts.nextOpt());
        } else if (opts.nextEq("--ontojournal")) {
            conf.pathToOntologyJournal = opts.nextOpt();
        } else {
            break;
        }
    }
    if (conf.pathToOntologyJournal == null) {
        System.err.println("No blazegraph journal containing tbox ontology provided. exit.");
        System.exit(-1);
    }
    if (conf.ontology == null) {
        System.err.println("No ontology graph available");
        System.exit(-1);
    }
    if (conf.journalFile == null) {
        System.err.println("No journal file available");
        System.exit(-1);
    }
    // if (conf.golrUrl == null) {
    // conf.golrUrl = "http://noctua-golr.berkeleybop.org/";
    // System.err.println("No GOLR service configured.  This is required, please add e.g. --golr-labels http://noctua-golr.berkeleybop.org/ to start up parameters ");
    // //System.exit(-1);
    // }
    conf.contextString = "/";
    if (conf.contextPrefix != null) {
        conf.contextString = "/" + conf.contextPrefix;
    }
    // set curie handler
    final CurieMappings mappings;
    if (conf.prefixesFile != null) {
        mappings = DefaultCurieHandler.loadMappingsFromFile(new File(conf.prefixesFile));
    } else {
        mappings = DefaultCurieHandler.loadDefaultMappings();
    }
    CurieMappings localMappings = new CurieMappings.SimpleCurieMappings(Collections.singletonMap(conf.modelIdcurie, conf.modelIdPrefix));
    conf.curieHandler = new MappedCurieHandler(mappings, localMappings);
    // wrap the Golr service with a cache
    // get rid of external look ups altogether.
    // if (conf.golrUrl != null) {
    // conf.lookupService = new GolrExternalLookupService(conf.golrUrl, conf.curieHandler, conf.useGolrUrlLogging);
    // LOGGER.info("Setting up Golr cache with size: "+conf.golrCacheSize+" duration: "+
    // conf.golrCacheDuration+" "+conf.golrCacheDurationUnit+
    // " use url logging: "+conf.useGolrUrlLogging);
    // conf.lookupService = new CachingExternalLookupService(conf.lookupService, conf.golrCacheSize, conf.golrCacheDuration, conf.golrCacheDurationUnit);
    // }
    // if (conf.monarchUrl != null) {
    // conf.lookupService = new MonarchExternalLookupService(conf.monarchUrl, conf.curieHandler, conf.useGolrUrlLogging);
    // LOGGER.info("Setting up Monarch Golr cache with size: "+conf.golrCacheSize+" duration: "+
    // conf.golrCacheDuration+" "+conf.golrCacheDurationUnit+
    // " use url logging: "+conf.useGolrUrlLogging);
    // conf.lookupService = new CachingExternalLookupService(conf.lookupService, conf.golrCacheSize, conf.golrCacheDuration, conf.golrCacheDurationUnit);
    // }
    // TODO maybe make these command line parameters
    URL shex_schema_url = new URL(conf.shexFileUrl);
    File shex_schema_file = new File("./target/shex-schema.shex");
    org.apache.commons.io.FileUtils.copyURLToFile(shex_schema_url, shex_schema_file);
    URL shex_map_url = new URL(conf.goshapemapFileUrl);
    File shex_map_file = new File("./target/go-cam-shapes.shapeMap");
    org.apache.commons.io.FileUtils.copyURLToFile(shex_map_url, shex_map_file);
    // reasoner set in next phase after ontologies loaded
    conf.shex = new MinervaShexValidator(shex_schema_file, shex_map_file, conf.curieHandler, null);
    Server server = startUp(conf);
    try {
        server.join();
    } finally {
        server.stop();
        server.destroy();
    }
}
Also used : MappedCurieHandler(org.geneontology.minerva.curie.MappedCurieHandler) CurieMappings(org.geneontology.minerva.curie.CurieMappings) Server(org.eclipse.jetty.server.Server) Opts(owltools.cli.Opts) File(java.io.File) URL(java.net.URL) MinervaShexValidator(org.geneontology.minerva.server.validation.MinervaShexValidator)

Example 15 with MappedCurieHandler

use of org.geneontology.minerva.curie.MappedCurieHandler in project minerva by geneontology.

the class BatchModelHandlerTest method init.

static void init(ParserWrapper pw) throws OWLOntologyCreationException, IOException, UnknownIdentifierException {
    final MinervaOWLGraphWrapper graph = pw.parseToOWLGraph("src/test/resources/go-lego-minimal.owl");
    final OWLObjectProperty legorelParent = StartUpTool.getRelation("http://purl.obolibrary.org/obo/LEGOREL_0000000", graph);
    assertNotNull(legorelParent);
    importantRelations = StartUpTool.getAssertedSubProperties(legorelParent, graph);
    assertFalse(importantRelations.isEmpty());
    // 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);
    InferenceProviderCreator ipc = CachingInferenceProviderCreatorImpl.createElk(false, null);
    models = new UndoAwareMolecularModelManager(graph.getSourceOntology(), curieHandler, modelIdPrefix, folder.newFile().getAbsolutePath(), null, ontology_journal_file, true);
    lookupService = createTestProteins(curieHandler);
    handler = new JsonOrJsonpBatchHandler(models, "development", ipc, importantRelations, lookupService) {

        @Override
        protected String generateDateString() {
            // hook for overriding the date generation with a custom counter
            if (dateGenerator.useCounter) {
                int count = dateGenerator.counter;
                dateGenerator.counter += 1;
                return Integer.toString(count);
            }
            return super.generateDateString();
        }
    };
    JsonOrJsonpBatchHandler.VALIDATE_BEFORE_SAVE = true;
}
Also used : MappedCurieHandler(org.geneontology.minerva.curie.MappedCurieHandler) CurieMappings(org.geneontology.minerva.curie.CurieMappings) MinervaOWLGraphWrapper(org.geneontology.minerva.MinervaOWLGraphWrapper) UndoAwareMolecularModelManager(org.geneontology.minerva.UndoAwareMolecularModelManager) InferenceProviderCreator(org.geneontology.minerva.server.inferences.InferenceProviderCreator) OWLObjectProperty(org.semanticweb.owlapi.model.OWLObjectProperty)

Aggregations

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