Search in sources :

Example 41 with Option

use of org.apache.commons.cli.Option in project goci by EBISPOT.

the class GOCIDataPublisherDriver method bindOptions.

private static Options bindOptions() {
    Options options = new Options();
    // help
    Option helpOption = new Option("h", "help", false, "Print the help");
    options.addOption(helpOption);
    // add output file arguments
    Option outputFileOption = new Option("o", "output", true, "The output file to write the published ontology to");
    outputFileOption.setArgName("file");
    outputFileOption.setRequired(true);
    options.addOption(outputFileOption);
    Option pvalueFilterOption = new Option("p", "pvalue", true, "The minimum p-value on which to filter the knowledge base, in format nE-x, e.g. 5E-8");
    options.addOption(pvalueFilterOption);
    Option dateFilterOption = new Option("d", "date", true, "The date on which to filter the knowledge base, in format YYYY-MM-DD");
    options.addOption(dateFilterOption);
    return options;
}
Also used : Options(org.apache.commons.cli.Options) Option(org.apache.commons.cli.Option)

Example 42 with Option

use of org.apache.commons.cli.Option in project goci by EBISPOT.

the class AssociationFilterApplication method bindOptions.

private static Options bindOptions() {
    Options options = new Options();
    // help
    Option helpOption = new Option("h", "help", false, "Print the help");
    options.addOption(helpOption);
    // add output file arguments
    Option outputFileOption = new Option("o", "output", true, "The output file to write the filtered list to");
    outputFileOption.setArgName("output");
    outputFileOption.setRequired(true);
    options.addOption(outputFileOption);
    Option inOption = new Option("f", "file", true, "Input file - file where data to be filtered can be found");
    inOption.setArgName("file");
    inOption.setRequired(true);
    options.addOption(inOption);
    Option pruneOption = new Option("p", "prune", false, "Prune output - removes associations with p-value < 1E-5 from the result output");
    pruneOption.setRequired(false);
    options.addOption(pruneOption);
    Option thresholdOption = new Option("t", "threshold", true, "Filter only associations below the provided threshold. If no threshold is provided, the default of 1e-5 will be used.");
    thresholdOption.setRequired(false);
    options.addOption(thresholdOption);
    return options;
}
Also used : Options(org.apache.commons.cli.Options) Option(org.apache.commons.cli.Option)

Example 43 with Option

use of org.apache.commons.cli.Option in project goci by EBISPOT.

the class GOCIDataReleaseQCDriver method bindOptions.

private static Options bindOptions() {
    Options options = new Options();
    // help
    Option helpOption = new Option("h", "help", false, "Print the help");
    options.addOption(helpOption);
    // add output file arguments
    Option allQCOption = new Option("a", "all", false, "Run the full QC pipeline");
    options.addOption(allQCOption);
    Option emailOption = new Option("e", "email", false, "Check the most recently published studies and email them out");
    options.addOption(emailOption);
    Option knowledgeBaseOption = new Option("k", "knowledgebase", false, "Run knowledge base QC tasks");
    options.addOption(knowledgeBaseOption);
    Option diagramOption = new Option("d", "diagram", false, "Run diagram QC tasks");
    options.addOption(diagramOption);
    Option solrOption = new Option("s", "solr", false, "Run Solr QC tasks");
    options.addOption(solrOption);
    return options;
}
Also used : Options(org.apache.commons.cli.Options) Option(org.apache.commons.cli.Option)

Example 44 with Option

use of org.apache.commons.cli.Option in project goci by EBISPOT.

the class KBMetricsDriver method parseArguments.

private static int parseArguments(String[] args) {
    CommandLineParser parser = new GnuParser();
    HelpFormatter help = new HelpFormatter();
    Options options = bindOptions();
    int parseArgs = 0;
    try {
        CommandLine cl = parser.parse(options, args, true);
        // check for mode help option
        if (cl.hasOption("")) {
            // print out mode help
            help.printHelp("evaluate", options, true);
            parseArgs += 1;
        } else {
            System.out.println("Metrics will be calculated with the following options...");
            for (Option opt : cl.getOptions()) {
                System.out.println("\t" + opt.getLongOpt() + ": " + opt.getValue() + " (" + opt.getArgName() + ")");
            }
            if (cl.hasOption("efo")) {
                _efoLocation = new URL(cl.getOptionValue("efo"));
                System.out.println(_efoLocation);
            } else {
                System.err.println("-efo (EFO location) argument is required");
                help.printHelp("evaluate", options, true);
                parseArgs += 2;
            }
            if (cl.hasOption("gwas")) {
                _gwasSchemaLocation = new File(cl.getOptionValue("gwas")).toURI().toURL();
                System.out.println(_gwasSchemaLocation);
            } else {
                System.err.println("-gwas (GWAS Schema File) argument is required");
                help.printHelp("evaluate", options, true);
                parseArgs += 2;
            }
            if (cl.hasOption("kb")) {
                _kbLocation = new File(cl.getOptionValue("kb")).toURI().toURL();
                System.out.println(_kbLocation);
            } else {
                System.err.println("-kb (Knowledgebase File) argument is required");
                help.printHelp("evaluate", options, true);
                parseArgs += 2;
            }
            if (cl.hasOption("w")) {
                _watershedCutoff = Integer.parseInt(cl.getOptionValue("w"));
            //                    System.setProperty("watershed.cutoff", String.valueOf(_watershedCutoff));
            } else {
                System.err.println("-w (Watershed cutoff) argument is required");
                help.printHelp("evaluate", options, true);
                parseArgs += 2;
            }
            if (cl.hasOption("out")) {
                String outOpt = cl.getOptionValue("out");
                _out = new BufferedOutputStream(new FileOutputStream(new File(outOpt)));
            } else {
                System.out.println("No output file specified, report will be written to standard out");
                _out = System.out;
            }
        }
    } catch (ParseException e) {
        System.err.println("Failed to read supplied arguments (" + e.getMessage() + ")");
        help.printHelp("evaluate", options, true);
        parseArgs += 4;
    } catch (FileNotFoundException e) {
        System.err.println("Failed to read supplied arguments - file not found (" + e.getMessage() + ")");
        help.printHelp("evaluate", options, true);
        parseArgs += 5;
    } catch (MalformedURLException e) {
        System.err.println("Failed to read supplied arguments - a supplied argument was not a valid URL " + "(" + e.getMessage() + ")");
        help.printHelp("evaluate", options, true);
        parseArgs += 6;
    }
    return parseArgs;
}
Also used : Options(org.apache.commons.cli.Options) MalformedURLException(java.net.MalformedURLException) GnuParser(org.apache.commons.cli.GnuParser) FileNotFoundException(java.io.FileNotFoundException) URL(java.net.URL) HelpFormatter(org.apache.commons.cli.HelpFormatter) CommandLine(org.apache.commons.cli.CommandLine) FileOutputStream(java.io.FileOutputStream) Option(org.apache.commons.cli.Option) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 45 with Option

use of org.apache.commons.cli.Option in project goci by EBISPOT.

the class ImportExportApplication method bindOptions.

private Options bindOptions() {
    Options options = new Options();
    // help
    Option helpOption = new Option("h", "help", false, "Print the help");
    options.addOption(helpOption);
    // options are...
    // -n --ncbi        (write out NCBI export file)
    // -d --download    (write out downloads file)
    // -f --file        (file to load in)
    // -o --out         (file to write out to)
    // -a --download_alt  (write out alternative downloads file)
    // -s --stats       (write out catalog meta data)
    // add input options
    OptionGroup modeGroup = new OptionGroup();
    modeGroup.setRequired(true);
    Option ncbiOption = new Option("n", "ncbi", false, "NCBI - generate an export of the GWAS catalog to send to the NCBI for mapping");
    ncbiOption.setRequired(false);
    modeGroup.addOption(ncbiOption);
    Option downloadOption = new Option("d", "download", false, "Download - generate an export of the GWAS catalog suitable for download");
    downloadOption.setRequired(false);
    modeGroup.addOption(downloadOption);
    Option downloadAltOption = new Option("a", "download_alt", false, "Download alternative - generate an export of the GWAS catalog, including ontology mappings, suitable for download");
    downloadAltOption.setRequired(false);
    modeGroup.addOption(downloadAltOption);
    Option statsOption = new Option("s", "stats", false, "Stats - generate the meta data for the GWAS Catalog published content");
    statsOption.setRequired(false);
    modeGroup.addOption(statsOption);
    options.addOptionGroup(modeGroup);
    // add input file arguments
    OptionGroup fileGroup = new OptionGroup();
    fileGroup.setRequired(true);
    Option inOption = new Option("f", "file", true, "Input file - file where the NCBI mapped data can be found");
    inOption.setArgName("file");
    inOption.setRequired(false);
    fileGroup.addOption(inOption);
    // add output file arguments
    Option outOption = new Option("o", "out", true, "Output file - file to write the chosen data export to");
    outOption.setArgName("file");
    outOption.setRequired(false);
    fileGroup.addOption(outOption);
    options.addOptionGroup(fileGroup);
    return options;
}
Also used : Options(org.apache.commons.cli.Options) OptionGroup(org.apache.commons.cli.OptionGroup) Option(org.apache.commons.cli.Option)

Aggregations

Option (org.apache.commons.cli.Option)152 Options (org.apache.commons.cli.Options)105 CommandLine (org.apache.commons.cli.CommandLine)53 CommandLineParser (org.apache.commons.cli.CommandLineParser)52 ParseException (org.apache.commons.cli.ParseException)41 GnuParser (org.apache.commons.cli.GnuParser)39 HelpFormatter (org.apache.commons.cli.HelpFormatter)30 File (java.io.File)13 OptionGroup (org.apache.commons.cli.OptionGroup)13 FileInputStream (java.io.FileInputStream)10 IOException (java.io.IOException)10 HashMap (java.util.HashMap)9 DefaultParser (org.apache.commons.cli.DefaultParser)9 Properties (java.util.Properties)8 BasicParser (org.apache.commons.cli.BasicParser)6 ConsoleAppender (org.apache.log4j.ConsoleAppender)6 PatternLayout (org.apache.log4j.PatternLayout)6 ArrayList (java.util.ArrayList)5 PosixParser (org.apache.commons.cli.PosixParser)5 List (java.util.List)3