Search in sources :

Example 1 with Opts

use of owltools.cli.Opts 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)

Aggregations

File (java.io.File)1 URL (java.net.URL)1 Server (org.eclipse.jetty.server.Server)1 CurieMappings (org.geneontology.minerva.curie.CurieMappings)1 MappedCurieHandler (org.geneontology.minerva.curie.MappedCurieHandler)1 MinervaShexValidator (org.geneontology.minerva.server.validation.MinervaShexValidator)1 Opts (owltools.cli.Opts)1