Example usage for org.apache.commons.cli Option Option

List of usage examples for org.apache.commons.cli Option Option

Introduction

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

Prototype

public Option(String opt, boolean hasArg, String description) throws IllegalArgumentException 

Source Link

Document

Creates an Option using the specified parameters.

Usage

From source file:com.genentech.struchk.OEMDLPercieveChecker.java

public static void main(String[] args) throws ParseException, JDOMException, IOException {
    // create command line Options object
    Options options = new Options();
    Option opt = new Option("i", true, "input file [.ism,.sdf,...]");
    opt.setRequired(true);//from  www .  ja va 2 s.  c om
    options.addOption(opt);

    opt = new Option("o", true, "output file");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("d", false, "debug: wait for user to press key at startup.");
    opt.setRequired(false);
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        exitWithHelp(options);
    }
    args = cmd.getArgs();

    if (cmd.hasOption("d")) {
        System.err.println("Start debugger and press return:");
        new BufferedReader(new InputStreamReader(System.in)).readLine();
    }

    if (args.length != 0) {
        exitWithHelp(options);
    }

    String inFile = cmd.getOptionValue("i");
    String outFile = cmd.getOptionValue("o");

    OEMDLPercieveChecker checker = null;
    try {
        checker = new OEMDLPercieveChecker();

        oemolostream out = new oemolostream(outFile);
        oemolistream in = new oemolistream(inFile);

        OEGraphMol mol = new OEGraphMol();
        while (oechem.OEReadMolecule(in, mol)) {
            if (!checker.checkMol(mol))
                oechem.OEWriteMolecule(out, mol);
        }
        checker.delete();
        in.close();
        in.delete();

        out.close();
        out.delete();

    } catch (Exception e) {
        throw new Error(e);
    }
    System.err.println("Done:");
}

From source file:gr.forth.ics.isl.preprocessfilter2.controller.Controller.java

public static void main(String[] args) throws XPathExpressionException, ParserConfigurationException,
        SAXException, IOException, PreprocessFilterException, TransformerException, ParseException {
    PropertyReader prop = new PropertyReader();

    //The following block of code is executed if there are arguments from the command line
    if (args.length > 0) {

        try {//  w  w w.  j a va  2s  .  co  m
            Options options = new Options();
            CommandLineParser PARSER = new PosixParser();
            Option inputFile = new Option("inputFile", true, "input xml file");
            Option outputFile = new Option("outputFile", true, "output xml file");
            Option parentNode = new Option("parentNode", true, "output xml file");
            Option newValuesFile = new Option("newValuesFile", true, "new values xml file");
            Option newParentNode = new Option("newParentNode", true, "new parent node");
            Option newValueTag = new Option("newValueTag", true, "new value tag");
            Option oldValueTag = new Option("oldValueTag", true, "old value tag");
            Option sameValueTag = new Option("sameValueTag", true, "same value tag");
            Option createNewValues = new Option("createNewValues", true, "create new values option");
            options.addOption(inputFile).addOption(outputFile).addOption(parentNode).addOption(newValuesFile)
                    .addOption(newParentNode).addOption(newValueTag).addOption(oldValueTag)
                    .addOption(sameValueTag).addOption(createNewValues);
            CommandLine cli = PARSER.parse(options, args);
            String inputFileArg = cli.getOptionValue("inputFile");
            String outputFileArg = cli.getOptionValue("outputFile");
            String parentNodeArg = cli.getOptionValue("parentNode");
            String newValuesFileArg = cli.getOptionValue("newValuesFile");
            String newParentNodeArg = cli.getOptionValue("newParentNode");
            String newValueTagArg = cli.getOptionValue("newValueTag");
            String oldValueTagArg = cli.getOptionValue("oldValueTag");
            String sameValueTagArg = cli.getOptionValue("sameValueTag");
            String createNewValuesArg = cli.getOptionValue("createNewValues");
            PreprocessFilterUtilities process = new PreprocessFilterUtilities();
            if (createNewValuesArg.equals("yes")) {
                if (process.createNewValuesFile(inputFileArg, newValuesFileArg, parentNodeArg)) {
                    System.out.println("Succesfull PreProcessing!!!");
                }
            } else {
                if (process.createOutputFile(inputFileArg, outputFileArg, parentNodeArg, newParentNodeArg,
                        newValueTagArg, oldValueTagArg, sameValueTagArg, newValuesFileArg)) {
                    System.out.println("Succesfull PreProcessing!!!");
                }
            }
        } catch (PreprocessFilterException ex) {
            Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex);
            throw new PreprocessFilterException("PreProcess Filter Exception:", ex);
        }

    } //If there are no command line arguments then the .config file is being used.
    else {

        try {
            String inputFilePathProp = prop.getProperty(inputFilePath);
            String outputFilePathProp = prop.getProperty(outputFilePath);
            String parentNodeProp = prop.getProperty(parentNode);

            String newValuesFilePathProp = prop.getProperty(newValuesFilePath);
            String newParentNodeProp = prop.getProperty(newParentNode);
            String newValueTagProp = prop.getProperty(newValueTag);
            String oldValueTagProp = prop.getProperty(oldValueTag);
            String sameValueTagProp = prop.getProperty(sameValueTag);
            String createNewValuesFileProp = prop.getProperty(createNewValuesFile);

            PreprocessFilterUtilities process = new PreprocessFilterUtilities();

            //The filter's code is executed with the .config file's resources as parameters
            if (createNewValuesFileProp.equals("yes")) {
                process.createNewValuesFile(inputFilePathProp, newValuesFilePathProp, parentNodeProp);
            } else {
                process.createOutputFile(inputFilePathProp, outputFilePathProp, parentNodeProp,
                        newParentNodeProp, newValueTagProp, oldValueTagProp, sameValueTagProp,
                        newValuesFilePathProp);
            }
        } catch (PreprocessFilterException ex) {
            Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex);
            throw new PreprocessFilterException("PreProcess Filter Exception:", ex);
        }
    }

}

From source file:com.yahoo.pasc.paxos.server.PaxosServer.java

/**
 * @param args/*from   ww w  . j  a  v a 2s.c  om*/
 * @throws NoSuchFieldException
 * @throws SecurityException
 * @throws IOException 
 * @throws MalformedURLException
 */
public static void main(String[] args) throws SecurityException, NoSuchFieldException, IOException {

    CommandLineParser parser = new PosixParser();
    Options options;

    {
        Option id = new Option("i", true, "client id");
        Option port = new Option("p", true, "port used by server");
        Option buffer = new Option("b", true, "number of batched messages");
        //            Option clients      = new Option("c", true, "clients (hostname:port,...)");
        Option servers = new Option("s", true, "servers (hostname:port,...)");
        Option maxInstances = new Option("m", true, "max number of instances");
        Option anm = new Option("a", false, "protection against ANM faults");
        Option udp = new Option("u", false, "use UDP");
        Option cWindow = new Option("w", true, "congestion window");
        Option threads = new Option("t", true, "number of threads");
        Option digests = new Option("d", true, "max digests");
        Option ckPeriod = new Option("k", true, "checkpointing period");
        Option inlineThresh = new Option("n", true, "threshold for sending requests iNline with accepts ");
        Option twoStages = new Option("2", false, "2 stages");
        Option digestQuorum = new Option("q", true, "digest quorum");
        Option leaderReplies = new Option("r", false, "leader replies");
        Option zookeeper = new Option("z", true, "zookeeper connection string");

        options = new Options();
        options.addOption(id).addOption(port).addOption(buffer).addOption(servers).addOption(threads)
                .addOption(anm).addOption(udp).addOption(maxInstances) //.addOption(leader)
                .addOption(cWindow).addOption(digests).addOption(ckPeriod).addOption(inlineThresh)
                .addOption(twoStages).addOption(digestQuorum).addOption(leaderReplies).addOption(zookeeper);
    }

    CommandLine line = null;
    try {
        line = parser.parse(options, args);

        String serverAddresses[] = line.hasOption('s') ? line.getOptionValue('s').split(",")
                : new String[] { "10.78.36.104:20548", "10.78.36.104:20748" };
        //            String clientAddresses[] = line.hasOption('c') ? line.getOptionValue('c').split(",") : new String[] { "localhost:9000" };
        String zookeeper = line.hasOption('z') ? line.getOptionValue('z') : "localhost:2181";
        int serverId = line.hasOption('i') ? Integer.parseInt(line.getOptionValue('i')) : 0;
        int batchSize = line.hasOption('b') ? Integer.parseInt(line.getOptionValue('b')) : 1;
        int port = line.hasOption('p') ? Integer.parseInt(line.getOptionValue('p')) : 20548;
        int maxInstances = line.hasOption('m') ? Integer.parseInt(line.getOptionValue('m')) : 16 * 1024;
        int congestionWindow = line.hasOption('w') ? Integer.parseInt(line.getOptionValue('w')) : 1;
        int digests = line.hasOption('d') ? Integer.parseInt(line.getOptionValue('d')) : 16;
        int inlineThreshold = line.hasOption('n') ? Integer.parseInt(line.getOptionValue('n')) : 1000;
        boolean protection = line.hasOption('a');
        boolean udp = line.hasOption('u');
        boolean twoStages = line.hasOption('2');
        int quorum = serverAddresses.length / 2 + 1;
        int digestQuorum = line.hasOption('q') ? Integer.parseInt(line.getOptionValue('q')) : quorum;
        int threads = line.hasOption('t') ? Integer.parseInt(line.getOptionValue('t'))
                : Runtime.getRuntime().availableProcessors() * 2 + 1;

        if (batchSize <= 0) {
            throw new RuntimeException("BatchSize must be greater than 0");
        }

        PaxosState state = new PaxosState(maxInstances, batchSize, serverId, quorum, digestQuorum,
                serverAddresses.length, congestionWindow, digests);
        if (line.hasOption('k'))
            state.setCheckpointPeriod(Integer.parseInt(line.getOptionValue('k')));
        if (line.hasOption('r'))
            state.setLeaderReplies(true);
        state.setRequestThreshold(inlineThreshold);

        if (!protection) {
            System.out.println("PANM disabled!");
        }

        final PascRuntime<PaxosState> runtime = new PascRuntime<PaxosState>(protection);
        runtime.setState(state);
        runtime.addHandler(Accept.class, new AcceptorAccept());
        runtime.addHandler(Prepare.class, new AcceptorPrepare());
        runtime.addHandler(Accepted.class, new Learner());
        runtime.addHandler(Prepared.class, new ProposerPrepared());
        runtime.addHandler(Request.class, new ProposerRequest());
        runtime.addHandler(InlineRequest.class, new ProposerRequest());
        runtime.addHandler(Digest.class, new DigestHandler());
        runtime.addHandler(PreReply.class, new LearnerPreReply());
        runtime.addHandler(Leader.class, new LeadershipHandler());

        if (udp) {
            new UdpServer(runtime, serverAddresses, null, port, threads, serverId).run();
        } else {
            new TcpServer(runtime, new EmptyStateMachine(), null, zookeeper, serverAddresses, port, threads,
                    serverId, twoStages).run();
        }
    } catch (Exception e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("Paxos", options);

        System.err.println("Unexpected exception: " + e);
        e.printStackTrace();

        System.exit(-1);
    }
}

From source file:edu.ehu.galan.lite.Lite.java

/**
 * Main entry point for LiTe from the command Line use -h option for help
 *
 * @param args//from  www .  java 2 s. c  o m
 */
public static void main(String[] args) {

    // create Options object
    Options options = new Options();
    Option corpus = new Option("c", true,
            "the location (directory) of the corpus to process, containing only one document at the moment");
    Option language = new Option("l", true,
            "the language of the corpus (lowercase ISO format, for example 'en'");
    Option algorithms = new Option("a", true, "the algorithms you want to process separated by commas: \n"
            + "see the documentation for see the available algorithms for each language");
    Option help = new Option("h", false, "print this message");
    Option resources = new Option("r", true, "the location of the lite resources folder");
    Option output = new Option("o", true,
            "The directory where the results will be stored, by default the one where the vm has been launched");
    Option listAlgs = new Option("listAlgs", false,
            " Algorithm list names with the supported languages (remember that the cvalue will be processed chosen or not):\n"
                    + "===================================================\n"
                    + "tfidf => processes the TFIDF algorithm, process terms of the input document using the Wikipedia corpus as IDF (en,es)\n"
                    + "cvalue => processes the CValue altorithm for the inputdocument, CValue is processed whether is chosed or not! (en, es)\n"
                    + "shallow => processes the shallow parsing grammar algorithm (en)\n"
                    + "rake => processes the rake algorithm (language agnostig)\n"
                    + "kpminer => processes the KPMiner algorithm (en)\n"
                    + "chisquare => processes the ChiSquare using the NLTK toolkit (language agnostic)\n"
                    + "pmi=> processes the Point Mutual Information using the NLTK toolkit (language agnostic)\n"
                    + "likehood=> processes the Likehood Ratio using the NLTK toolkit (language agnostic)\n"
                    + "tstudent=> processes the T-Student using the NLTK toolkit (language agnostic)\n"
                    + "rawfreq=> processes the raw frequency algorithm using the NLTK toolkit (language agnostic)\n"
                    + "freelingner=> processes the FreeLing ner algorithm via external call(es, en)\n");
    options.addOption(resources);
    options.addOption(corpus);
    options.addOption(language);
    options.addOption(algorithms);
    options.addOption(listAlgs);
    options.addOption(output);
    // automatically generate the help statement
    HelpFormatter formatter = new HelpFormatter();
    String[] s = new String[] {};
    // create the parser
    CommandLineParser parser = new org.apache.commons.cli.GnuParser();
    try {
        // parse the command line arguments
        CommandLine line = parser.parse(options, args);
        if (line.hasOption('c') && line.hasOption('l') && line.hasOption('a') && line.hasOption('r')) {
            if (!line.getOptionValue('l').equals("en") && !line.getOptionValue("l").equals("es")) {
                System.out.println(
                        "Supported languages \"en\" or \"es\", however you may use the statistical algorithms via the API");
            } else {
                String outputDir = "";
                if (line.hasOption('o')) {
                    outputDir = line.getOptionValue('o');
                }
                String lang = line.getOptionValue('l');
                Corpus cor = new Corpus(line.getOptionValue('l'));
                cor.loadCorpus(line.getOptionValue('c'), Document.SourceType.wikipedia);
                String res = line.getOptionValue('r');
                List<String> algs = Arrays.asList(line.getOptionValue('a').split(","));
                System.out.println("Processing.... (it may take a while...)");
                runner(lang, res + File.separator, algs, cor, outputDir);
            }
        }
        if (line.hasOption('c') && line.hasOption('l') && line.hasOption('r')) {
            if (!line.getOptionValue('l').equals("en") && !line.getOptionValue("l").equals("es")) {
                System.out.println(
                        "Supported languages \"en\" or \"es\", however you may use the statistical algorithms via the API");
            } else {
                String outputDir = "";
                if (line.hasOption('o')) {
                    outputDir = line.getOptionValue('o');
                }
                System.out.println(
                        "Processing with default algorithms (TFIDF/CValue).... (it may take a while...)");
                Corpus cor = new Corpus(line.getOptionValue('l'));
                String res = line.getOptionValue('r');
                cor.loadCorpus(line.getOptionValue('c'), Document.SourceType.wikipedia);
                String lang = line.getOptionValue('l');
                List<String> algos = null;
                switch (lang) {
                case "es": {
                    String[] algs = { "cvalue", "tfidf", "rake" };
                    algos = Arrays.asList(algs);
                    break;
                }
                case "en": {
                    String[] algs = { "cvalue", "tfidf", "rake" };
                    algos = Arrays.asList(algs);
                    break;
                }
                }
                runner(lang, res + File.separator, algos, cor, outputDir);
            }
        } else if (line.hasOption("h")) {
            formatter.printHelp("LiTe: a language indepent term extractor", options);
        } else if (line.getOptions().length == 0) {
            formatter.printHelp("LiTe: a language indepent term extractor", options);
        } else {
            System.err.println("The 'c', 'l' and 'r' arguments are required \n");
            formatter.printHelp("LiTe: a language indepent term extractor", options);
        }
    } catch (ParseException exp) {
        // oops, something went wrong
        System.err.println("Parsing failed.  Reason: " + exp.getMessage() + "\n");
        formatter.printHelp("LiTe: a language indepent term extractor", options);

    }

}

From source file:com.genentech.chemistry.openEye.apps.SDFConformerSampler.java

/**
 * @param args//from   ww  w. ja  v a 2  s .  c  o m
 */
public static void main(String... args) throws IOException { // create command line Options object
    Options options = new Options();
    Option opt = new Option(OPT_INFILE, true,
            "input file oe-supported Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_OUTFILE, true, "output file oe-supported. Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_MAX_CONFS, true, "Maximum number of conformations per input.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_TORSION_FILE, true, "Optional: to overwrite torsion definition file.");
    opt.setRequired(false);
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        exitWithHelp(options);
    }
    args = cmd.getArgs();

    if (cmd.hasOption("d")) {
        System.err.println("Start debugger and press return:");
        new BufferedReader(new InputStreamReader(System.in)).readLine();
    }

    String inFile = cmd.getOptionValue(OPT_INFILE);
    String outFile = cmd.getOptionValue(OPT_OUTFILE);
    String smartsFile = cmd.getOptionValue(OPT_TORSION_FILE);
    long maxConfs = Long.parseLong(cmd.getOptionValue(OPT_MAX_CONFS));

    SDFConformerSampler scanner = new SDFConformerSampler(smartsFile, outFile, maxConfs);

    scanner.run(inFile);
    scanner.close();
}

From source file:com.genentech.chemistry.openEye.apps.SDFRingSystemExtractor.java

/**
 * @param args/*from   w ww . j  av a 2 s. c o  m*/
 */
public static void main(String... args) throws IOException { // create command line Options object
    Options options = new Options();
    Option opt = new Option(OPT_INFILE, true, "input file oe-supported");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_OUTFILE, true, "output file oe-supported");
    opt.setRequired(false);
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        exitWithHelp(options);
    }
    args = cmd.getArgs();

    if (cmd.hasOption("d")) {
        System.err.println("Start debugger and press return:");
        new BufferedReader(new InputStreamReader(System.in)).readLine();
    }

    String inFile = cmd.getOptionValue(OPT_INFILE);
    String outFile = cmd.getOptionValue(OPT_OUTFILE);
    SDFRingSystemExtractor extractor = new SDFRingSystemExtractor(outFile);
    extractor.run(inFile);
    extractor.close();
}

From source file:com.genentech.chemistry.openEye.apps.SDFMolSeparator.java

/**
 * @param args//w w  w  . ja v a  2 s .c o m
 */
public static void main(String... args) throws IOException { // create command line Options object
    Options options = new Options();
    Option opt = new Option(OPT_INFILE, true,
            "input file oe-supported Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_OUTFILE, true, "output file oe-supported. Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        exitWithHelp(options);
    }
    args = cmd.getArgs();

    if (cmd.hasOption("d")) {
        System.err.println("Start debugger and press return:");
        new BufferedReader(new InputStreamReader(System.in)).readLine();
    }

    String inFile = cmd.getOptionValue(OPT_INFILE);
    String outFile = cmd.getOptionValue(OPT_OUTFILE);
    SDFMolSeparator separator = new SDFMolSeparator(outFile);

    try {
        separator.run(inFile);

    } catch (IndexOutOfBoundsException iie) {
        System.err.println(iie.toString());
        exitWithHelp(options);
    } finally {
        separator.close();
    }

}

From source file:cross.io.PropertyFileGenerator.java

/**
 *
 * @param args//from  w w  w  .  j a v  a 2 s  .  co m
 */
public static void main(String[] args) {
    Options options = new Options();
    options.addOption("f", true, "base directory for output of files");
    Option provOptions = new Option("p", true,
            "Comma separated list of provider classes to create Properties for");
    provOptions.setRequired(true);
    provOptions.setValueSeparator(',');
    options.addOption(provOptions);
    CommandLineParser parser = new PosixParser();
    HelpFormatter hf = new HelpFormatter();
    try {
        File basedir = null;
        List<String> providers = Collections.emptyList();
        CommandLine cmd = parser.parse(options, args);
        if (cmd.hasOption("f")) {
            basedir = new File(cmd.getOptionValue("f"));
        } else {
            hf.printHelp("java -cp maltcms.jar " + PropertyFileGenerator.class, options);
        }
        if (cmd.hasOption("p")) {
            String[] str = cmd.getOptionValues("p");
            providers = Arrays.asList(str);
        } else {
            hf.printHelp("java -cp maltcms.jar " + PropertyFileGenerator.class, options);
        }
        for (String provider : providers) {
            createProperties(provider, basedir);
        }
    } catch (ParseException ex) {
        Logger.getLogger(PropertyFileGenerator.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:it.unipd.dei.ims.falcon.CmdLine.java

public static void main(String[] args) {

    // last argument is always index path
    Options options = new Options();
    // one of these actions has to be specified
    OptionGroup actionGroup = new OptionGroup();
    actionGroup.addOption(new Option("i", true, "perform indexing")); // if dir, all files, else only one file
    actionGroup.addOption(new Option("q", true, "perform a single query"));
    actionGroup.addOption(new Option("b", false, "perform a query batch (read from stdin)"));
    actionGroup.setRequired(true);/*from  w  ww . java  2 s.  c om*/
    options.addOptionGroup(actionGroup);

    // other options
    options.addOption(new Option("l", "segment-length", true, "length of a segment (# of chroma vectors)"));
    options.addOption(
            new Option("o", "segment-overlap", true, "overlap portion of a segment (# of chroma vectors)"));
    options.addOption(new Option("Q", "quantization-level", true, "quantization level for chroma vectors"));
    options.addOption(new Option("k", "min-kurtosis", true, "minimum kurtosis for indexing chroma vectors"));
    options.addOption(new Option("s", "sub-sampling", true, "sub-sampling of chroma features"));
    options.addOption(new Option("v", "verbose", false, "verbose output (including timing info)"));
    options.addOption(new Option("T", "transposition-estimator-strategy", true,
            "parametrization for the transposition estimator strategy"));
    options.addOption(new Option("t", "n-transp", true,
            "number of transposition; if not specified, no transposition is performed"));
    options.addOption(new Option("f", "force-transp", true, "force transposition by an amount of semitones"));
    options.addOption(new Option("p", "pruning", false,
            "enable query pruning; if -P is unspecified, use default strategy"));
    options.addOption(new Option("P", "pruning-custom", true, "custom query pruning strategy"));

    // parse
    HelpFormatter formatter = new HelpFormatter();
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
        if (cmd.getArgs().length != 1)
            throw new ParseException("no index path was specified");
    } catch (ParseException ex) {
        System.err.println("ERROR - parsing command line:");
        System.err.println(ex.getMessage());
        formatter.printHelp("falcon -{i,q,b} [options] index_path", options);
        return;
    }

    // default values
    final float[] DEFAULT_TRANSPOSITION_ESTIMATOR_STRATEGY = new float[] { 0.65192807f, 0.0f, 0.0f, 0.0f,
            0.3532628f, 0.4997167f, 0.0f, 0.41703504f, 0.0f, 0.16297342f, 0.0f, 0.0f };
    final String DEFAULT_QUERY_PRUNING_STRATEGY = "ntf:0.340765*[0.001694,0.995720];ndf:0.344143*[0.007224,0.997113];"
            + "ncf:0.338766*[0.001601,0.995038];nmf:0.331577*[0.002352,0.997884];"; // TODO not the final one

    int hashes_per_segment = Integer.parseInt(cmd.getOptionValue("l", "150"));
    int overlap_per_segment = Integer.parseInt(cmd.getOptionValue("o", "50"));
    int nranks = Integer.parseInt(cmd.getOptionValue("Q", "3"));
    int subsampling = Integer.parseInt(cmd.getOptionValue("s", "1"));
    double minkurtosis = Float.parseFloat(cmd.getOptionValue("k", "-100."));
    boolean verbose = cmd.hasOption("v");
    int ntransp = Integer.parseInt(cmd.getOptionValue("t", "1"));
    TranspositionEstimator tpe = null;
    if (cmd.hasOption("t")) {
        if (cmd.hasOption("T")) {
            // TODO this if branch is yet to test
            Pattern p = Pattern.compile("\\d\\.\\d*");
            LinkedList<Double> tokens = new LinkedList<Double>();
            Matcher m = p.matcher(cmd.getOptionValue("T"));
            while (m.find())
                tokens.addLast(new Double(cmd.getOptionValue("T").substring(m.start(), m.end())));
            float[] strategy = new float[tokens.size()];
            if (strategy.length != 12) {
                System.err.println("invalid transposition estimator strategy");
                System.exit(1);
            }
            for (int i = 0; i < strategy.length; i++)
                strategy[i] = new Float(tokens.pollFirst());
        } else {
            tpe = new TranspositionEstimator(DEFAULT_TRANSPOSITION_ESTIMATOR_STRATEGY);
        }
    } else if (cmd.hasOption("f")) {
        int[] transps = parseIntArray(cmd.getOptionValue("f"));
        tpe = new ForcedTranspositionEstimator(transps);
        ntransp = transps.length;
    }
    QueryPruningStrategy qpe = null;
    if (cmd.hasOption("p")) {
        if (cmd.hasOption("P")) {
            qpe = new StaticQueryPruningStrategy(cmd.getOptionValue("P"));
        } else {
            qpe = new StaticQueryPruningStrategy(DEFAULT_QUERY_PRUNING_STRATEGY);
        }
    }

    // action
    if (cmd.hasOption("i")) {
        try {
            Indexing.index(new File(cmd.getOptionValue("i")), new File(cmd.getArgs()[0]), hashes_per_segment,
                    overlap_per_segment, subsampling, nranks, minkurtosis, tpe, verbose);
        } catch (IndexingException ex) {
            Logger.getLogger(CmdLine.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(CmdLine.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    if (cmd.hasOption("q")) {
        String queryfilepath = cmd.getOptionValue("q");
        doQuery(cmd, queryfilepath, hashes_per_segment, overlap_per_segment, nranks, subsampling, tpe, ntransp,
                minkurtosis, qpe, verbose);
    }
    if (cmd.hasOption("b")) {
        try {
            long starttime = System.currentTimeMillis();
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            String line = null;
            while ((line = in.readLine()) != null && !line.trim().isEmpty())
                doQuery(cmd, line, hashes_per_segment, overlap_per_segment, nranks, subsampling, tpe, ntransp,
                        minkurtosis, qpe, verbose);
            in.close();
            long endtime = System.currentTimeMillis();
            System.out.println(String.format("total time: %ds", (endtime - starttime) / 1000));
        } catch (IOException ex) {
            Logger.getLogger(CmdLine.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.genentech.chemistry.openEye.apps.SDFALogP.java

/**
 * @param args//from  ww  w.  j  ava2s  . co  m
 */
public static void main(String... args) throws IOException { // create command line Options object
    Options options = new Options();
    Option opt = new Option(OPT_INFILE, true,
            "input file oe-supported Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_OUTFILE, true, "output file oe-supported. Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_SMARTS_FILE, true, "Optional: to overwrite atom type definition file.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_PRINT_COUNTS, false,
            "If set the count of each atom type is added to the output file.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_VALIDATE_ASSIGNMENT, false,
            "Print warning if no atomtype matches an atom in a candidte molecule.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_SUPRESS_ZERO, false, "If given atom type counts with count=0 will not be added.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_NEUTRALIZE, true, "y|n to neutralize molecule if possible (default=y)");
    opt.setRequired(false);
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        exitWithHelp(options);
    }
    args = cmd.getArgs();

    if (cmd.hasOption("d")) {
        System.err.println("Start debugger and press return:");
        new BufferedReader(new InputStreamReader(System.in)).readLine();
    }

    String inFile = cmd.getOptionValue(OPT_INFILE);
    String outFile = cmd.getOptionValue(OPT_OUTFILE);
    String smartsFile = cmd.getOptionValue(OPT_SMARTS_FILE);
    boolean outputCount = cmd.hasOption(OPT_PRINT_COUNTS);
    boolean outputZero = !cmd.hasOption(OPT_SUPRESS_ZERO);
    boolean neutralize = !"n".equalsIgnoreCase(cmd.getOptionValue(OPT_NEUTRALIZE));
    boolean ValidateAssignment = cmd.hasOption(OPT_VALIDATE_ASSIGNMENT);

    SDFALogP sdfALogP = new SDFALogP(smartsFile, outFile, outputZero, neutralize, ValidateAssignment);

    sdfALogP.run(inFile, outputCount);
    sdfALogP.close();
}