Example usage for org.apache.commons.cli OptionBuilder hasArg

List of usage examples for org.apache.commons.cli OptionBuilder hasArg

Introduction

In this page you can find the example usage for org.apache.commons.cli OptionBuilder hasArg.

Prototype

public static OptionBuilder hasArg(boolean hasArg) 

Source Link

Document

The next Option created will require an argument value if hasArg is true.

Usage

From source file:org.mitre.ccv.mapred.CompleteCompositionVectors.java

/**
 *
 * The JSO data will be the same as {@link org.mitre.ccv.CompleteMatrix#jsonCompleteMatrix}, but the features
 * will be in a different order. This version, by default sorts, only by entropy values, whereas the
 * ccv in-memory version sorts by the k-mer natural order (i.e., lexigraphic).
 * @param argv// www .  j av  a  2 s . c o m
 * @return
 * @throws java.lang.Exception
 */
@Override
@SuppressWarnings("static-access") // For OptionBuilder
public int run(String[] argv) throws Exception {
    JobConf conf = new JobConf(getConf());
    String cli_title = "CompleteCompositionVectorHadoop";

    int start = CalculateKmerCounts.DEFAULT_START;
    int end = CalculateKmerCounts.DEFAULT_END;
    int topkmers = 0;

    String input = null;
    String output = null;
    String vectorJsonOutput = null;
    //String kmerJsonOutput = null;

    boolean cleanLogs = false;

    /** create the Options */
    Options options = new Options();

    /** Hadoop Options */
    options.addOption(
            OptionBuilder.withArgName("number").hasArg(true).withDescription("number of maps").create("m"));
    options.addOption(
            OptionBuilder.withArgName("number").hasArg(true).withDescription("number of reducers").create("r"));

    // org.hadoop.util.GenericOptionsParser should captures this, but it doesn't
    options.addOption(OptionBuilder.withArgName("property=value").hasArg(true).withValueSeparator()
            .withDescription("use value for given property").create("D"));

    /** CompleteCompositionVector Options */
    options.addOption(OptionBuilder.withArgName("number").hasArg(true)
            .withDescription("number of top k-mers to use in calculations").create("topKmers"));
    options.addOption(OptionBuilder.withArgName("start").hasArg(true).withDescription("starting length of tile")
            .create("start"));
    options.addOption(OptionBuilder.withArgName("end").hasArg(true).withDescription("ending length of title")
            .create("end"));
    options.addOption(OptionBuilder.hasArg(true).withArgName("file")
            .withDescription("JSON file to write out k-mers to").create("kmersfile"));

    options.addOption(OptionBuilder.hasArg(true).withArgName("file")
            .withDescription("JSON file to write out feature vectors to "
                    + "(Overrides kmersout, only one file will be written).")
            .create("vectorsfile"));

    options.addOption(OptionBuilder.withArgName("number").hasArg(true)
            .withDescription("What preference to use: 0-min 1-median 2-avg(min,med): default is median")
            .create("prefval"));

    options.addOption(OptionBuilder.withArgName("help").hasArg(false).withDescription("print this message")
            .create("help"));

    // automatically generate the help statement
    HelpFormatter formatter = new HelpFormatter();

    //GenericOptionsParser gop = new GenericOptionsParser(conf, options, argv);
    GenericOptionsParser gop = new GenericOptionsParser(conf, argv);

    String[] remaining_args = gop.getRemainingArgs();

    // create the parser
    CommandLineParser parser = new GnuParser();
    //CommandLine line = gop.getCommandLine();
    String[] other_args = new String[] {};

    try {
        CommandLine line = parser.parse(options, remaining_args);
        other_args = line.getArgs();

        // Make sure there is a parameter left.
        if (other_args.length == 0) {
            System.out.println(cli_title);
            System.out.println("Missing input path!");
            formatter.printHelp("hccv [options] <input> [<output>] ", options);
            GenericOptionsParser.printGenericCommandUsage(System.out);
            return -1;
        }

        Option[] opts = line.getOptions();
        if (line.hasOption("help")) {
            System.out.println(cli_title);
            formatter.printHelp("hccv [options] <input> [<output>] ", options);
            GenericOptionsParser.printGenericCommandUsage(System.out);
            return -1;
        }

        // could also use line.iterator()
        for (Option opt : opts) {
            if (opt.getOpt().equals("m")) {
                conf.setNumMapTasks(Integer.parseInt(opt.getValue()));
            }
            if (opt.getOpt().equals("r")) {
                conf.setNumReduceTasks(Integer.parseInt(opt.getValue()));
            }
            if (opt.getOpt().equals("D")) {
                // We can have multiple properties we want to set
                String[] properties = opt.getValues();
                for (String property : properties) {
                    String[] keyval = property.split("=");
                    conf.set(keyval[0], keyval[1]);
                }
            }
            if (opt.getOpt().equals("start")) {
                start = Integer.parseInt(opt.getValue());
            }
            if (opt.getOpt().equals("end")) {
                end = Integer.parseInt(opt.getValue());
            }
            if (opt.getOpt().equals("topKmers")) {
                topkmers = Integer.parseInt(opt.getValue());
            }
            if (opt.getOpt().equals("vectorsfile")) {
                vectorJsonOutput = opt.getValue();
            }
        }
    } catch (ParseException e) {
        LOG.warn("options parsing faild: " + e.getMessage());
        System.out.println(cli_title);
        formatter.printHelp("hccv [options] <input> [<output>] ", options);
        GenericOptionsParser.printGenericCommandUsage(System.out);
    }
    if (start <= 2) {
        throw new IllegalArgumentException("Value of 'start' argument must be larger than 2");
    }

    input = other_args[0];
    if (other_args.length < 2) {
        output = input + "_" + FileUtils.getSimpleDate();
    } else {
        output = other_args[2];
    }

    /**
     * Check output path. Either needs to exist as a directory or not exist
     */
    Path outputPath = new Path(output);
    FileSystem fs = outputPath.getFileSystem(conf);
    if (!fs.exists(outputPath)) {
        fs.mkdirs(outputPath);
    } else if (fs.exists(outputPath) || !fs.getFileStatus(outputPath).isDir()) {
        LOG.fatal(String.format("Output directory %s already exists", outputPath.makeQualified(fs)));
        throw new FileAlreadyExistsException(
                String.format("Output directory %s already exists", outputPath.makeQualified(fs)));
    }

    String outputDir = output + Path.SEPARATOR;

    int res;
    /**
     * Zero, CalculateCompositionVectors
     */
    LOG.info("Starting CalculateCompositionVectors Map-Reduce job");
    CalculateCompositionVectors cv = new CalculateCompositionVectors();
    res = cv.initJob(conf, start, end, input, outputDir + COMPOSITION_VECTORS, cleanLogs);
    if (res != 0) {
        LOG.info("CalculateCompositionVectors returned non-zero result!");
        return res;
    }
    // We can stop now or continue to reduce dimensionallity using RRE or other means

    /**
     * First, CalculateKmerCounts
     */
    LOG.info("Starting CalculateKmerCounts Map-Reduce job");
    // FastMap option for CalculateKmers!?!
    CalculateKmerCounts ckc = new CalculateKmerCounts();
    res = ckc.initJob(conf, start, end, input, outputDir + KMER_COUNTS);
    if (res != 0) {
        LOG.fatal("CalculateKmerCounts returned non-zero result!");
        return res;
    }

    /**
     * Second, TotalSequenceLength
     */
    LOG.info("Starting TotalSequenceLength Map-Reduce job");
    TotalSequenceLength tsl = new TotalSequenceLength();
    res = tsl.initJob(conf, input, outputDir + TOTAL_LENGTH, cleanLogs);
    if (res != 0) {
        LOG.fatal("TotalSequenceLength returned non-zero result!");
        return res;
    }
    int length = tsl.getCount(conf, outputDir + TOTAL_LENGTH);

    if (length < 3) {
        LOG.fatal("TotalSequenceLength returned a total sequence length of less than 3.");
        return -1;
    } else {
        LOG.info(String.format("TotalSequenceLength returned a total sequence length of %d.", length));
    }

    /**
     * Third, CalculateKmerProbabilities
     */
    LOG.info("Starting CalculateKmerProbabilities Map-Reduce job");
    CalculateKmerProbabilities ckp = new CalculateKmerProbabilities();
    res = ckp.initJob(conf, start, end, length, outputDir + KMER_COUNTS, outputDir + KMER_PROBABILITIES,
            cleanLogs);
    if (res != 0) {
        LOG.fatal("CalculateKmerProbabilities returned non-zero result!");
        return res;
    }

    /**
     * Fourth, InvertKmerProbabilities
     */
    LOG.info("Starting InvertKmerProbabilities Map-Reduce job");
    InvertKmerProbabilities ikp = new InvertKmerProbabilities();
    res = ikp.initJob(conf, outputDir + KMER_PROBABILITIES, outputDir + INVERTED_KMER_PROBABILITIES, cleanLogs);
    if (res != 0) {
        LOG.fatal("InvertKmerProbabilities returned non-zero result!");
        return res;
    }

    /**
     * Fifth, CalculateKmerPiValues
     */
    LOG.info("Starting CalculateKmerPiValues Map-Reduce job");
    CalculateKmerPiValues kpv = new CalculateKmerPiValues();
    res = kpv.initJob(conf, start, end, outputDir + INVERTED_KMER_PROBABILITIES, outputDir + KMER_PI_VALUES,
            cleanLogs);
    if (res != 0) {
        LOG.fatal("CalculateKmerPiValues returned non-zero result!");
        return res;
    }

    /**
     * Sixth,CalculateKmerRevisedRelativeEntropy
     */
    LOG.info("Starting CalculateKmerRevisedRelativeEntropy Map-Reduce job");
    CalculateKmerRevisedRelativeEntropy krre = new CalculateKmerRevisedRelativeEntropy();
    res = krre.initJob(conf, outputDir + KMER_PI_VALUES, outputDir + COMPOSITION_VECTORS,
            outputDir + ENTROPY_VALUES, cleanLogs);
    if (res != 0) {
        LOG.fatal("CalculateKmerRevisedRelativeEntropy returned non-zero result!");
        return res;
    }

    /**
     * Seventh, SortKmerRevisedRelativeEntropies
     */
    SortKmerRevisedRelativeEntropies srre = new SortKmerRevisedRelativeEntropies();
    res = srre.initJob(conf, outputDir + ENTROPY_VALUES, outputDir + SORTED_ENTROPY_VALUES, cleanLogs);
    if (res != 0) {
        LOG.fatal("SortKmerRevisedRelativeEntropies returned non-zero result!");
        return res;
    }

    /**
     * Eigth, GenerateFeatureVectors
     *
     * Generate a flatten list to add to the cache to be distributed to the map-tasks.
     */
    Path listOutputPath = new Path(outputDir + Integer.toString(topkmers) + KMER_ENTROPY_SET);
    LOG.info(String.format("Loading %d sorted k-mers from %s to %s", topkmers,
            outputDir + SORTED_ENTROPY_VALUES, listOutputPath.toString()));
    int num = CompleteCompositionVectorUtils.flattenKmerEntropySequenceFile(conf, topkmers,
            outputDir + SORTED_ENTROPY_VALUES, listOutputPath.toString(), cleanLogs);

    if (num != topkmers) {
        LOG.fatal(String.format("Requested %d k-mers, but got %d. Using %d", topkmers, num, num));
        topkmers = num;
    }
    GenerateFeatureVectors fv = new GenerateFeatureVectors();
    res = fv.initJob(conf, listOutputPath.toString(), topkmers, outputDir + COMPOSITION_VECTORS,
            outputDir + FEATURE_VECTORS, cleanLogs);
    if (res != 0) {
        LOG.fatal("GenerateFeatureVectors returned non-zero result!");
        return res;
    }

    /**
     * Save feature vectors, features (k-mers), and properties to a JSON file.
     *
     * The data will be the same as {@link org.mitre.ccv.CompleteMatrix#jsonCompleteMatrix}, but the features
     * will be in a different order. This version, by default sorts, only by entropy values, whereas the
     * ccv in-memory version sorts by the k-mer natural order (i.e., lexigraphic).
     */
    if (vectorJsonOutput != null && vectorJsonOutput.length() > 0) {
        LOG.info("Writing features out to " + vectorJsonOutput);
        CompleteCompositionVectorUtils.featureVectors2Json(conf, start, end, topkmers,
                outputDir + SORTED_ENTROPY_VALUES, outputDir + FEATURE_VECTORS, vectorJsonOutput);
    }

    LOG.info("All done generating complete composition vectors and feature vectors.");
    return res;
}

From source file:org.nuunframework.cli.NuunCliPlugin.java

private Option createOptionFromField(Field field) {
    Option option = null;/*  w  w  w .j ava  2s  .co m*/
    // Cli Option Builder is completly static :-/
    // so we synchronized it ...
    synchronized (OptionBuilder.class) {
        // reset the builder creating a dummy option
        OptionBuilder.withLongOpt("dummy");
        OptionBuilder.create();

        // 
        NuunOption nuunOption = field.getAnnotation(NuunOption.class);

        if (nuunOption == null) {
            for (Annotation anno : field.getAnnotations()) {
                if (AssertUtils.hasAnnotationDeep(anno.annotationType(), NuunOption.class)) {
                    nuunOption = AssertUtils.annotationProxyOf(NuunOption.class, anno);
                    break;
                }
            }
        }

        // longopt
        if (!Strings.isNullOrEmpty(nuunOption.longOpt())) {
            OptionBuilder.withLongOpt(nuunOption.longOpt());
        }
        // description
        if (!Strings.isNullOrEmpty(nuunOption.description())) {
            OptionBuilder.withDescription(nuunOption.description());
        }
        // required
        OptionBuilder.isRequired((nuunOption.required()));

        // arg
        OptionBuilder.hasArg((nuunOption.arg()));

        // args
        if (nuunOption.args()) {
            if (nuunOption.numArgs() > 0) {
                OptionBuilder.hasArgs(nuunOption.numArgs());
            } else {
                OptionBuilder.hasArgs();
            }
        }
        // is optional 
        if (nuunOption.optionalArg()) {
            OptionBuilder.hasOptionalArg();
        }

        // nuun 
        OptionBuilder.withValueSeparator(nuunOption.valueSeparator());

        // opt 
        if (!Strings.isNullOrEmpty(nuunOption.opt())) {
            option = OptionBuilder.create(nuunOption.opt());
        } else {
            option = OptionBuilder.create();
        }
    }

    return option;

}

From source file:org.openmainframe.ade.main.ControlDB.java

@Override
protected void parseArgs(String[] args) throws AdeException {

    final Option helpOpt = new Option("h", "help", false, "Print help message and exit");
    final Option forceOpt = new Option("f", "force", false, "Force operation. Do not prompt for confirmation");

    OptionBuilder.withLongOpt("create");
    OptionBuilder.hasArg(false);
    OptionBuilder.isRequired(false);/*from w w  w  .  j a v  a  2 s .  com*/
    OptionBuilder.withDescription("Create Ade DB tables");
    final Option createOpt = OptionBuilder.create('c');

    OptionBuilder.withLongOpt("drop");
    OptionBuilder.hasArg(false);
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Drops all Ade DB tables, and clears the data store dictionaries");
    final Option deleteOpt = OptionBuilder.create('d');

    OptionBuilder.withLongOpt("reset");
    OptionBuilder.hasArg(false);
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Clears all Ade DB tables content");
    final Option resetOpt = OptionBuilder.create('r');

    OptionBuilder.withLongOpt("query");
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("SQL query string");
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Performs the input query");
    final Option queryOpt = OptionBuilder.create('q');

    final OptionGroup actionGroupOpt = new OptionGroup().addOption(createOpt).addOption(deleteOpt)
            .addOption(resetOpt).addOption(queryOpt);
    actionGroupOpt.setRequired(true);

    final Options options = new Options();
    options.addOption(helpOpt);
    options.addOption(forceOpt);
    options.addOptionGroup(actionGroupOpt);

    final CommandLineParser parser = new GnuParser();
    CommandLine line = null;

    try {
        // parse the command line arguments
        line = parser.parse(options, args);
    } catch (MissingOptionException exp) {
        logger.error("Command line parsing failed.", exp);
        new HelpFormatter().printHelp(ControlDB.class.getName(), options);
        System.exit(0);
    } catch (ParseException exp) {
        // oops, something went wrong
        logger.error("Parsing failed.  Reason: " + exp.getMessage());
        throw new AdeUsageException("Argument Parsing failed", exp);
    }

    if (line.hasOption('h')) {
        new HelpFormatter().printHelp(getClass().getSimpleName(), options);
        closeAll();
        System.exit(0);
    }

    if (line.hasOption('f')) {
        m_forceOp = true;
    }

    if (line.hasOption('c')) {
        m_op = ControlDBOperator.Create;
    } else if (line.hasOption('d')) {
        m_op = ControlDBOperator.Drop;
    } else if (line.hasOption('r')) {
        m_op = ControlDBOperator.Reset;
    } else if (line.hasOption('q')) {
        m_op = ControlDBOperator.Query;
        m_args = new String[] { line.getOptionValue('q') };
    }
}

From source file:org.semanticscience.narf.graphs.main.CycleExtractor.java

@SuppressWarnings("static-access")
private static Options createOptions() {
    Options o = new Options();
    OptionBuilder.withArgName("/path/to/input/dir");
    Option inputPDBDir = OptionBuilder.hasArg(true)
            .withDescription("The directory where your input PDB files are located").create("inputPDBDir");
    Option inputSeqFile = OptionBuilder.hasArg(true)
            .withDescription("The path to the file of one aptamer sequence per line").create("inputSeqFile");
    Option outputDir = OptionBuilder.withArgName("/path/to/output/dir").hasArg(true)
            .withDescription("The directory where the cycle output will be stored").create("outputDir");
    Option outputFormat = OptionBuilder.withArgName("outputFormat").hasArg(true)
            .withDescription("The output format for the cycles (RDF|tsv)").isRequired().create("outputFormat");
    o.addOption(inputSeqFile);// w w w .ja va 2  s . c  o m
    o.addOption(outputFormat);
    o.addOption(inputPDBDir);
    o.addOption(outputDir);
    return o;
}

From source file:org.semanticscience.PDBAptamerRetriever.main.RetrieveAptamers.java

@SuppressWarnings("static-access")
private static Options createOptions() {
    Options o = new Options();
    // help option
    Option help = new Option("help", false, "Print this message");
    Option getAll = OptionBuilder.hasArg(false).withDescription(
            "use this flag if you wish to download all rna and dna containing pdb structures both x-ray and nmr")
            .create("getall");
    Option expMethod = OptionBuilder.withArgName("X-RAY").hasArg(true)
            .withDescription("Enter an expeirmental method. Valid options are X-RAY, NMR or all").create("em");
    Option moleculeType = OptionBuilder.withArgName("RNA").hasArg(true)
            .withDescription("Enter a molecule type. Valid options are DNA, RNA, BOTH, ALLDNA or ALLRNA")
            .create("mt");
    Option outputFastaDir = OptionBuilder.withArgName("/path/to/local/dir").hasArg(true)
            .withDescription("The directory where you wish to save your FASTA files").create("fastaDir");
    Option concatenateFASTA = OptionBuilder.hasArg(false).withDescription(
            "Add this parameter if you want all of your FASTA files to be downloaded into a single file")
            .create("cf");
    Option outputPDBDir = OptionBuilder.withArgName("/path/to/local/dir").hasArg(true)
            .withDescription("The directory where you wish to save your PDB files").create("pdbDir");
    Option outputPDBMLDir = OptionBuilder.withArgName("/path/to/loca/pdbml/dir").hasArg(true)
            .withDescription("The directory where you wish to save your PDBML files").create("pdbmlDir");
    Option ligandReport = OptionBuilder.hasArg(false)
            .withDescription("Add this parameter to create a ligand report").create("lr");
    Option ligandFreqs = OptionBuilder.hasArg(false)
            .withDescription("Add this parameter to compute ligand counts").create("lf");
    Option click = OptionBuilder.withArgName("/path/to/click/outputDir").hasArg(true).withDescription(
            "Add this parameter to run Click on all PDB files. Specify where to store the output of Click")
            .create("click");
    Option needle = OptionBuilder.withArgName("/path/to/needle/outputDir").hasArg(true)
            .withDescription("Add this parameter to run EMBOSS's needle program on the downloaded fasta files")
            .create("needle");
    Option gapOpen = OptionBuilder.withArgName("Gap open penalty").hasArg(true)
            .withDescription("Add this parameter if you are running Needle").create("gapOpen");
    Option gapExtend = OptionBuilder.withArgName("Gap extend penalty").hasArg(true)
            .withDescription("Add this parameter if you are running Needle").create("gapExtend");
    o.addOption(getAll);/*from  ww w.ja  v a  2  s.c o m*/
    o.addOption(outputPDBMLDir);
    o.addOption(gapExtend);
    o.addOption(gapOpen);
    o.addOption(help);
    o.addOption(expMethod);
    o.addOption(moleculeType);
    o.addOption(outputFastaDir);
    o.addOption(concatenateFASTA);
    o.addOption(outputPDBDir);
    o.addOption(ligandReport);
    o.addOption(ligandFreqs);
    o.addOption(click);
    o.addOption(needle);
    return o;
}

From source file:org.servalproject.maps.dataman.DataManCli.java

private static Options createOptions() {

    Options options = new Options();

    // path to the input file
    OptionBuilder.withArgName("path");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("path to the input file");
    OptionBuilder.isRequired(true);/*from w w w. j a v  a2 s  .co m*/
    options.addOption(OptionBuilder.create("input"));

    // path to the output file
    OptionBuilder.withArgName("path");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("path to the output file");
    OptionBuilder.isRequired(true);
    options.addOption(OptionBuilder.create("output"));

    // task to undertake
    OptionBuilder.withArgName("text");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("manipulation task to undertake");
    OptionBuilder.isRequired(true);
    options.addOption(OptionBuilder.create("task"));

    // style information
    OptionBuilder.withArgName("text");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("style definition information");
    OptionBuilder.isRequired(false);
    options.addOption(OptionBuilder.create("style"));

    // verbose output or not
    options.addOption(new Option("verbose", "use verbose output"));

    return options;
}

From source file:org.servalproject.maps.indexgenerator.MapIndexGenerator.java

private static Options createOptions() {

    Options options = new Options();

    OptionBuilder.withArgName("path");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("path to the input directory");
    OptionBuilder.isRequired(true);//from ww w  .  j a  va2s . co  m
    options.addOption(OptionBuilder.create("input"));

    OptionBuilder.withArgName("path");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("path to the output file");
    OptionBuilder.isRequired(true);
    options.addOption(OptionBuilder.create("output"));

    OptionBuilder.withArgName("text");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("output format type");
    OptionBuilder.isRequired(true);
    options.addOption(OptionBuilder.create("format"));

    return options;

}

From source file:org.servalproject.maps.mapfiletester.MapFileTester.java

private static Options createOptions() {

    Options options = new Options();

    OptionBuilder.withArgName("path");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("path to the input file / directory");
    OptionBuilder.isRequired(true);//from w w  w.ja va 2  s  . c o m
    options.addOption(OptionBuilder.create("input"));

    return options;

}

From source file:org.servalproject.maps.osmbboxsplit.OsmBBoxSplit.java

private static Options createOptions() {

    Options options = new Options();

    OptionBuilder.withArgName("path");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("path to the input file / directory");
    OptionBuilder.isRequired(true);//w ww  .j a  va2  s  .com
    options.addOption(OptionBuilder.create("input"));

    OptionBuilder.withArgName("int");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("minimum size of file in MB to split (Default: " + MIN_FILE_SIZE + " MB)");
    OptionBuilder.isRequired(false);
    options.addOption(OptionBuilder.create("minsize"));

    OptionBuilder.withArgName("path");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("path to the ignore list file");
    OptionBuilder.isRequired(false);
    options.addOption(OptionBuilder.create("ignore"));

    OptionBuilder.withArgName("path");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("path to the output directory");
    OptionBuilder.isRequired(false);
    options.addOption(OptionBuilder.create("output"));

    OptionBuilder.withArgName("path");
    OptionBuilder.hasArg(true);
    OptionBuilder.withDescription("path to the osmosis script template");
    OptionBuilder.isRequired(false);
    options.addOption(OptionBuilder.create("template"));

    return options;

}

From source file:org.structnetalign.CLI.java

private static Options getOptions() {
    Options options = new Options();
    options.addOption(OptionBuilder.hasArg(true)
            .withDescription(//from  w ww.  j a v a2  s  . co m
                    "The number of cores to use. Defaults to the number of available processors minus one.")
            .isRequired(false).create("cores"));
    options.addOption(OptionBuilder.hasArg(true).withDescription(
            "The directory containing cached PDB files. Defaults to the AtomCache default, which is probably in your system's temporary directory (e.g. /tmp). It is okay if this is an empty directory, but the directory must exist. You should set up a PDB cache path if you plan to run "
                    + PROGRAM_NAME + " multiple times.")
            .isRequired(false).create("pdb_dir"));
    options.addOption(OptionBuilder.hasArg(true).withDescription(
            "The maximum search depth for traversal during crossing. If a vertex v shares an interaction edge x with vertex s, vertex v shares an interaction edge y with vertex t, and there is no path from u to t and no path from v to s, then x will be updated by y if and only if u and v are seperated by no more than xi homology edges (inclusive), AND s and t are seperated by no more than xi homology edges. Defaults to "
                    + PipelineManager.XI + ". See paper for more details.")
            .isRequired(false).create("xi"));
    options.addOption(OptionBuilder.hasArg(true).withDescription(
            "A threshold probability prior for running the crossing process. Prior to crossing, any homology edge with probability less than tau will be removed. Defaults to "
                    + PipelineManager.TAU + ".")
            .isRequired(false).create("tau"));
    options.addOption(OptionBuilder.hasArg(true).withDescription(
            "A threshold probability prior for running the merging process. Prior to merging, any homology edge with probability less than zeta will be removed. Note that this is performed after a similar process for tau, so zeta should be no greater than tau. Defaults to "
                    + PipelineManager.ZETA + ".")
            .isRequired(false).create("zeta"));
    options.addOption(OptionBuilder.hasArg(false).withDescription(
            "If set, generates an HTML report page with accompanying graph visualizations in the specified directory.")
            .isRequired(false).create("report"));
    options.addOption(
            OptionBuilder.hasArg(false).withDescription("Do not run the vertex degeneracy removal process.")
                    .isRequired(false).create("no_merge"));
    options.addOption(OptionBuilder.hasArg(false).withDescription("Do not run the probability update process.")
            .isRequired(false).create("no_cross"));
    options.addOption(OptionBuilder.hasArg(true).withDescription("Required. The input PSI-MI25 XML file.")
            .isRequired(true).create("input"));
    options.addOption(OptionBuilder.hasArg(true).withDescription("Required. The output PSI-MI25 XML file.")
            .isRequired(true).create("output"));
    //      options.addOption(OptionBuilder.hasArg(true)
    //            .withDescription("The name of the PSI-MI25 confidence short label to use to give the initial weighting (probability) of an interaction as input to " + CLI.PROGRAM_NAME + ". Defaults to " + GraphInteractionAdaptor.INITIAL_CONFIDENCE_LABEL).isRequired(false)
    //            .create("input_conf"));
    //      options.addOption(OptionBuilder.hasArg(true)
    //            .withDescription("The default weighting (probability) of an interaction if the interaction does not have a weight described by input_conf. Defaults to " + GraphInteractionAdaptor.DEFAULT_PROBABILITY).isRequired(false)
    //            .create("default_weight"));
    //      options.addOption(OptionBuilder.hasArg(true)
    //            .withDescription("The name of the PSI-MI25 confidence short label to use to describe the certainty of an interaction as determined by " + CLI.PROGRAM_NAME + ". Defaults to " + GraphInteractionAdaptor.CONFIDENCE_SHORT_LABEL).isRequired(false)
    //            .create("output_conf_label"));
    //      options.addOption(OptionBuilder.hasArg(true)
    //            .withDescription("The name of the PSI-MI25 confidence full name to use to describe certainty of an interaction as determined by " + CLI.PROGRAM_NAME + ". Defaults to " + GraphInteractionAdaptor.CONFIDENCE_FULL_NAME).isRequired(false)
    //            .create("output_conf_name"));
    options.addOption(OptionBuilder.hasArg(false).withDescription("Output a GraphML file for each step.")
            .isRequired(false).create("write_steps"));
    options.addOption(OptionBuilder.hasArg(true).withDescription(
            "Skip the weighting process and use the specified GraphML file to indicate homology instead.")
            .isRequired(false).create("graphml_homology"));
    return options;
}