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.aestel.chemistry.openEye.fp.Fingerprinter.java

public static void main(String... args) throws IOException {
    long start = System.currentTimeMillis();
    long iCounter = 0;

    // create command line Options object
    Options options = new Options();
    Option opt = new Option("in", true, "input file [.ism,.sdf,...]");
    opt.setRequired(true);//from w  ww  .  j av a2s  . c  o  m
    options.addOption(opt);

    opt = new Option("out", true, "output file .tsv or oe-supported");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("idTag", true, "field with ID (default title)");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("fpType", true, "fingerPrintType: maccs|linear7|linear7*4|HashLinear7*4\n"
            + "   maccs: generate maccs keys\n"
            + "   linear7 generate 7 bonds long linear fingerprints (210k known rest hashed)\n"
            + "   linear7*4 linear 7 bonds if more than 4 atoms code atoms as * (5.1k known rest hashed)\n"
            + "   HashLinear7*4: as linear7*4 but hashed to 16k");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("format", true,
            "folded512|folded2048|bitList|fragList|none\n" + "   folded512/2048: hex encoded 512/2048 bits\n"
                    + "   bitList: list of bitpositions\n" + "   none: no fp output for use with writeCodeMap");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("writeCodeMap", false, "Overwrite the codeMap file at the end of processing");
    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 idTag = null;
    if (cmd.hasOption("idTag"))
        idTag = cmd.getOptionValue("idTag");

    String outformat = cmd.getOptionValue("format").toLowerCase().intern();
    if (args.length != 0) {
        exitWithHelp(options);
    }

    String type = cmd.getOptionValue("fpType");
    boolean updateDictionaryFile = cmd.hasOption("writeCodeMap");
    boolean hashUnknownFrag = true;
    if (type.equals("HashLinear7*4"))
        hashUnknownFrag = false;
    if (type.equals("maccs"))
        hashUnknownFrag = false;
    if (updateDictionaryFile)
        hashUnknownFrag = false;
    Fingerprinter fprinter = createFingerprinter(type, updateDictionaryFile, hashUnknownFrag);
    OEMolBase mol = new OEGraphMol();

    String inFile = cmd.getOptionValue("in");
    String outFile = cmd.getOptionValue("out");
    oemolistream ifs = new oemolistream(inFile);

    Runtime rt = Runtime.getRuntime();
    Outputter out;
    if (outFile.endsWith(".txt") || outFile.endsWith(".tab"))
        out = new TabOutputter(fprinter.getMapper(), outFile, outformat);
    else
        out = new OEOutputter(fprinter.getMapper(), outFile, type, outformat);

    while (oechem.OEReadMolecule(ifs, mol)) {
        iCounter++;
        Fingerprint fp = fprinter.getFingerprint(mol);

        String id;
        if (idTag == null)
            id = mol.GetTitle();
        else
            id = oechem.OEGetSDData(mol, idTag);

        if (iCounter % 100 == 0)
            System.err.print(".");
        if (iCounter % 4000 == 0) {
            System.err.printf(" %d %dsec\tt=%d f=%d u=%d m=%d tf=%d\n", iCounter,
                    (System.currentTimeMillis() - start) / 1000, rt.totalMemory() / 1024,
                    rt.freeMemory() / 1024, (rt.totalMemory() - rt.freeMemory()) / 1024, rt.maxMemory() / 1024,
                    (rt.freeMemory() + (rt.maxMemory() - rt.totalMemory())) / 1024);
        }

        out.output(id, mol, fp);
    }

    System.err.printf("Fingerprinter: Read %d structures in %d sec\n", iCounter,
            (System.currentTimeMillis() - start) / 1000);

    if (updateDictionaryFile)
        fprinter.writeDictionary();
    out.close();
    fprinter.close();
}

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

/**
 * @param args//w w w.j  av a2  s. c  om
 */
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 filename.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_STARTTorsion, true,
            "The torsion in your inMol will be rotated by this value for the first job");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_TORSIONIncrement, true, "Incremnt each subsequent conformation by this step size");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_NSTEPS, true, "Number of conformations to create");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_BONDFILE, true, "The file containing the bond atoms that define the torsion.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_MINIMIZE, false,
            "Minimize conformer at each step using MMFFs.  If maxConfsPerStep is > 1, "
                    + "all confs will be mimimized and the lowest E will be output.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_CONSTRIANT, true,
            "One of strong (90), medium (45), weak(20), none or a floating point number"
                    + " to specify the tethered constraint strength for -minimize (def=strong)");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_MAXCONFS_PER_STEP, true,
            "While holding the torsion fixed, maximum number of conformations of free atoms to generat.  default=1");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_COREFILE, true, "Outputfile to store guessed core.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_TORSIONS_ATOM_TAG, true,
            "Name of sdf tag which will contain the indices of atoms that define the torsion.");
    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 (args.length != 0) {
        System.err.println("Unknown arguments" + args);
        exitWithHelp(options);
    }

    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 bondFile = cmd.getOptionValue(OPT_BONDFILE);
    String coreFilename = cmd.getOptionValue(OPT_COREFILE);
    String torsionAtomsTag = cmd.getOptionValue(OPT_TORSIONS_ATOM_TAG);

    int nSteps = Integer.parseInt(cmd.getOptionValue(OPT_NSTEPS));
    int nStartTor = Integer.parseInt(cmd.getOptionValue(OPT_STARTTorsion));
    int nTorIncr = Integer.parseInt(cmd.getOptionValue(OPT_TORSIONIncrement));

    int nMaxConfsPerStep = 1;
    if (cmd.hasOption(OPT_MAXCONFS_PER_STEP)) {
        nMaxConfsPerStep = Integer.parseInt(cmd.getOptionValue(OPT_MAXCONFS_PER_STEP));
    }

    String constraintStrength = cmd.getOptionValue(OPT_CONSTRIANT);

    boolean doMinimize = cmd.hasOption(OPT_MINIMIZE);

    SDFTorsionScanner torGenerator = new SDFTorsionScanner(bondFile, coreFilename, torsionAtomsTag, nSteps,
            nStartTor, nTorIncr, nMaxConfsPerStep, doMinimize, constraintStrength);

    torGenerator.run(inFile, outFile, coreFilename);
}

From source file:com.genentech.chemistry.tool.sdf2DAlign.java

public static void main(String[] args) throws IOException {

    final String OPT_INFILE = "in";
    final String OPT_OUTFILE = "out";
    final String OPT_TEMPLATEFILE = "templates";
    final String OPT_RESETCOORDS = "reset";
    final String OPT_DEBUG = "debug";

    Options options = new Options();

    Option opt = new Option(OPT_INFILE, true, "Input file (oe-supported). Use .sdf to specify the file type.");
    opt.setRequired(true);/*from   w  ww . java 2  s.c o  m*/
    options.addOption(opt);

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

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

    opt = new Option(OPT_RESETCOORDS, false,
            "Reset coordinates in input file when aligning. This will delete original 2D coords and create new ones.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_DEBUG, false, "Print debug statements.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("h", false, "print usage statement");
    opt.setRequired(false);
    options.addOption(opt);

    PosixParser parser = new PosixParser();
    CommandLine cl = null;

    try {
        cl = parser.parse(options, args);
    } catch (Exception exp) {
        System.err.println(exp.getMessage());
        exitWithHelp(options);
    }

    //get command line parameters
    String inFile = cl.getOptionValue(OPT_INFILE);
    String outFile = cl.getOptionValue(OPT_OUTFILE);
    String templateFile = cl.getOptionValue(OPT_TEMPLATEFILE);
    boolean resetCoords = cl.hasOption(OPT_RESETCOORDS);
    boolean debug = cl.hasOption(OPT_DEBUG);

    sdf2DAlign myAlign = new sdf2DAlign(inFile, outFile, templateFile, resetCoords);
    myAlign.setDebug(debug);

    //get templates as subsearches
    List<OESubSearch> templates = myAlign.getTemplates();

    //apply template to input molecules
    myAlign.applyTemplates(templates);

    for (OESubSearch ss : templates)
        ss.delete();
}

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

/**
 * @param args/* w ww. java2 s  . com*/
 */
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);
    opt.setArgName("fn");
    options.addOption(opt);

    opt = new Option(OPT_OUTFILE, true, "output file oe-supported. Use .sdf|.smi to specify the file type.");
    opt.setRequired(true);
    opt.setArgName("fn");
    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) {
        System.err.println("Specify at least one index type");
        exitWithHelp(options);
    }

    String inFile = cmd.getOptionValue(OPT_INFILE);
    String outFile = cmd.getOptionValue(OPT_OUTFILE);
    Set<String> selectedIndexes = new HashSet<String>(args.length);
    if (args.length == 1 && "all".equalsIgnoreCase(args[0]))
        selectedIndexes = AVAILIndexes;
    else
        selectedIndexes.addAll(Arrays.asList(args));

    if (!AVAILIndexes.containsAll(selectedIndexes)) {
        selectedIndexes.removeAll(AVAILIndexes);
        StringBuilder err = new StringBuilder("Unknown Index types: ");
        for (String it : selectedIndexes)
            err.append(it).append(" ");
        System.err.println(err);
        exitWithHelp(options);
    }

    SDFTopologicalIndexer sdfIndexer = new SDFTopologicalIndexer(outFile, selectedIndexes);

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

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

/**
 * @param args//from w w w.ja v a2s.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_REFFILE, true,
            "Reference file of molecules which define pre-existign exclusion spheres.");
    options.addOption(opt);

    opt = new Option(OPT_RADIUS, true, "Radius of exclusion spehre in A2.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_GROUPBY, true,
            "Group by fieldname, run sphere exclusion for consecutive groups of records with same value for this field.");
    options.addOption(opt);

    opt = new Option(OPT_DONotOpt, false,
            "If specified the RMSD is computed without trying to optimize the alignment.");
    options.addOption(opt);

    opt = new Option(OPT_PRINT_All, false, "print all molecule, check includeIdx tag");
    options.addOption(opt);

    opt = new Option(OPT_MIRROR, false, "For non-chiral molecules also try mirror image");
    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 refFile = cmd.getOptionValue(OPT_REFFILE);
    String groupBy = cmd.getOptionValue(OPT_GROUPBY);
    boolean doOptimize = !cmd.hasOption(OPT_DONotOpt);
    double radius = Double.parseDouble(cmd.getOptionValue(OPT_RADIUS));
    boolean printAll = cmd.hasOption(OPT_PRINT_All);
    boolean doMirror = cmd.hasOption(OPT_MIRROR);

    SdfRMSDSphereExclusion sphereExclusion = new SdfRMSDSphereExclusion(refFile, outFile, radius, printAll,
            doMirror, doOptimize, groupBy);

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

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

/**
 * @param args//from  w ww. jav 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_ESTATE_COUNT, false, "Output the the counts (occurrence) for each E-state atom group."
            + " E-state counts will be output if no output option is specified");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_ESTATE_SUM, false, "Output the sum of the E-state indices for each E-state atom group"
            + " in addition to the output of the" + " E-state atom groups.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_ESTATE_SYMBOL, false, "Output the E-state atom group symbol");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_UNASSIGNED_ATOMS, false,
            "Output atoms in the given molecules that" + " could not be assigned to an E-state atom group");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_UNASSIGNED_COUNT, false, "Output the number of atoms in the given molecules that"
            + " could not be assigned to an E-state atom group");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_ESTATE_INDICE, false,
            "Output the E-state indice of all atoms in the given molecule" + " in one field.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_SMARTS, true, "Description of the group of interest. If specified, the"
            + " E-state indice of atoms matching the SMARTS are output" + " in separated fields.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_PRINT_DETAILS, false, "Output the details of the calculation to stderr");
    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 smarts = cmd.getOptionValue(OPT_SMARTS);
    boolean outputESIndex = cmd.hasOption(OPT_ESTATE_INDICE);
    boolean outputESCount = cmd.hasOption(OPT_ESTATE_COUNT);
    boolean outputESSum = cmd.hasOption(OPT_ESTATE_SUM);
    boolean outputESSymbol = cmd.hasOption(OPT_ESTATE_SYMBOL);
    boolean outputUnkCount = cmd.hasOption(OPT_UNASSIGNED_COUNT);
    boolean outputUnkAtoms = cmd.hasOption(OPT_UNASSIGNED_ATOMS);
    boolean printDetails = cmd.hasOption(OPT_PRINT_DETAILS);
    SDFEStateCalculator calculator = new SDFEStateCalculator(outFile);

    if (!outputESCount && !outputESSum && !outputUnkCount && !outputESSymbol && !outputESIndex
            && (smarts == null || smarts.length() == 0))
        outputESCount = true;

    try {
        calculator.prepare(outputESCount, outputESSum, outputESSymbol, outputUnkCount, outputUnkAtoms,
                outputESIndex, smarts, printDetails);
        calculator.run(inFile);
    } finally {
        calculator.close();
    }
}

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

public static void main(String[] args) throws IOException {
    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);/*from w  w w. j av a 2s.c om*/
    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_REFFILE, true, "Reference file containing poses from reference docking run. " + "If "
            + OPT_REFFILE + " not specified, program uses the input file " + "(internal NN analysis)");
    options.addOption(opt);

    opt = new Option(OPT_MOLIdTag, true, "Name of the field containing the molecule identifier. "
            + " Assumption: Ref file uses the same field name.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_DONotOpt, false,
            "If specified the RMSD is computed without trying to optimize the alignment.");
    options.addOption(opt);

    opt = new Option(OPT_MIRROR, false, "For non-chiral molecules also try mirror image");
    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 (args.length != 0) {
        ; //error message
    }

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

    String refFile = cmd.getOptionValue(OPT_REFFILE);
    boolean noRefFile = false;
    if (refFile == null) {
        if (inFile.startsWith("."))
            inFile = writeRefMolPosesToTempFile(inFile);
        refFile = inFile;
        noRefFile = true;
    }

    String molIdTag = cmd.getOptionValue(OPT_MOLIdTag);
    boolean doOptimize = !cmd.hasOption(OPT_DONotOpt);
    boolean doMirror = cmd.hasOption(OPT_MIRROR);

    SdfRMSDNNFinder nnFinder = new SdfRMSDNNFinder(refFile, outFile, molIdTag, doMirror, doOptimize, noRefFile);

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

From source file:com.genentech.chemistry.tool.SDFSelectivityCalculator.java

/**
 * @param args//from w  w  w.  j  a v a2  s.c om
 */
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_NUMERATOR, true, "Name of the field containing the numerator value.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_NUMERATOR_OP, true,
            "Name of the field containing the numerator operator."
                    + " If this option is not set it is assumed that the operator" + " is included in the "
                    + OPT_NUMERATOR + " field.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_DENOMINATOR, true, "Name of the field containing the denominator value.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_DENOMINATOR_OP, true,
            "Name of the field containing the denominator operator."
                    + " If this option is not set it is assumed that the operator" + " is included in the "
                    + OPT_DENOMINATOR + " field.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_SELECTIVITY, true, "Name of the field containing the output selectivity value."
            + " If this option is not set, the field name of the denominator" + " is used.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_SELECTIVITY_OP, true,
            "Name of the field containing the output selectivity operator."
                    + " If this option is not set it is assumed that the operator" + " is included in the "
                    + OPT_SELECTIVITY + " field.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_OUTPUT_MODE, true,
            "Valid: separate, combine, combine+op;" + " If not specified, default is combine+op."
                    + " (separate=operator and value in separate fields;"
                    + " combine=operator and value in one field;"
                    + " combine+op=one field with the operator and value and"
                    + " plus one field with only the operator)");
    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 outputMode = cmd.getOptionValue(OPT_OUTPUT_MODE);
    String numeratorTag = cmd.getOptionValue(OPT_NUMERATOR);
    String numeratorOPTag = cmd.getOptionValue(OPT_NUMERATOR_OP);
    String denominatorTag = cmd.getOptionValue(OPT_DENOMINATOR);
    String denominatorOPTag = cmd.getOptionValue(OPT_DENOMINATOR_OP);
    String selectivityTag = cmd.getOptionValue(OPT_SELECTIVITY);
    String selectivityOPTag = cmd.getOptionValue(OPT_SELECTIVITY_OP);

    SDFSelectivityCalculator calculator = new SDFSelectivityCalculator(outFile);
    try {
        calculator.setParameters(outputMode, numeratorTag, numeratorOPTag, denominatorTag, denominatorOPTag,
                selectivityTag, selectivityOPTag);
        calculator.run(inFile);
    } catch (IncorrectInputException e) {
        System.err.println(e.getMessage());
        exitWithHelp(options);
    } finally {
        calculator.close();
    }
}

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

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);//from  ww  w.j a v  a  2  s. c  o  m
    options.addOption(opt);

    opt = new Option(OPT_SDFFILE, true,
            "file to write onformers for debugging (oe-supported Use .sdf|.smi to specify the file type).");
    options.addOption(opt);

    opt = new Option(OPT_WORKDIR, true, "Write files into this directory!");
    opt.setRequired(false);
    options.addOption(opt);

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

    opt = new Option(OPT_OUTNAMETAG, true,
            "TagName of field containing outFilePrefix. (Use TITLE for mol title).");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_TEMPLATE, true,
            "Template file for quantum program containing #XYZ# place holder line. A #FName# placeholder can be used fro chk files and the like.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_SPIN_MULTIPLICITY, true, "Spin Multiplicity of the input molecules (default 1)");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_NCPU, true, "Overwrite nprocshared parameter in guassian input file if given");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_MEM, true, "Memory for gaussian default='10GB' replaces #mem# in tempalte");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_MINIMIZE, false, "minimize conformer at each step using MMFFs");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_CONSTRIANT, true,
            "one of strong (90),medium (45), weak(20), none or a floating point number"
                    + " specifying the strength of tethered constrains for -doMinimize (def=strong)");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_BONDFILE, true, "Structure file containing 4 atoms defining the torsion. "
            + "In each input molecule the atoms colses these atoms are used to define the torsion.");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_STARTTorsion, true,
            "The torsion in your inMol will be rotated by this value for the first job");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_TORSIONIncrement, true, "Incremnt each subsequent conformation by this step size");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_NSTEPS, true, "Number of conformations to create");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option(OPT_MAXCONFS_PER_STEP, true,
            "While holding the torsion fixed, maximum number of conformations of free atoms to generate.  default=1");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_COREFILE, true, "Outputfile to store guessed core.");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option(OPT_DEBUG, false, "Produce more debug output.");
    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 (args.length != 0) {
        System.err.println("Unknown arguments" + args);
        exitWithHelp(options);
    }

    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 sdfFile = cmd.getOptionValue(OPT_SDFFILE);
    String outPrefix = cmd.getOptionValue(OPT_OUTPREFIX);
    String outNameTag = cmd.getOptionValue(OPT_OUTNAMETAG);
    String workDir = cmd.getOptionValue(OPT_WORKDIR);
    String coreFile = cmd.getOptionValue(OPT_COREFILE);
    String tempalte = cmd.getOptionValue(OPT_TEMPLATE);
    String bondFile = cmd.getOptionValue(OPT_BONDFILE);
    String nCPU = cmd.getOptionValue(OPT_NCPU);
    String memStr = cmd.getOptionValue(OPT_MEM);
    String maxConfsStr = cmd.getOptionValue(OPT_MAXCONFS_PER_STEP);
    String spinMult = cmd.getOptionValue(OPT_SPIN_MULTIPLICITY);

    boolean doMinimize = cmd.hasOption(OPT_MINIMIZE);
    String constraintStrength = cmd.getOptionValue(OPT_CONSTRIANT);
    int nStep = Integer.parseInt(cmd.getOptionValue(OPT_NSTEPS));

    if (memStr == null || memStr.length() == 0)
        memStr = "10GB";

    if (spinMult == null || spinMult.length() == 0)
        spinMult = "1";

    if ((outPrefix == null && outNameTag == null) || (outPrefix != null && outNameTag != null)) {
        System.err.println("Exactly one of -outPrefix or outNameTag must be given!");
        exitWithHelp(options);
    }

    if (workDir == null || workDir.trim().length() == 0)
        workDir = ".";

    double startTorsion = Double.NaN;
    if (cmd.hasOption(OPT_STARTTorsion))
        startTorsion = Double.parseDouble(cmd.getOptionValue(OPT_STARTTorsion));

    double torInc = Double.parseDouble(cmd.getOptionValue(OPT_TORSIONIncrement));
    int maxStepConfs = maxConfsStr == null ? 1 : Integer.parseInt(maxConfsStr);

    QTorsionProfileGenerator calculator = new QTorsionProfileGenerator(tempalte, workDir, outPrefix, outNameTag,
            bondFile, spinMult, startTorsion, torInc, nStep, maxStepConfs, doMinimize, constraintStrength,
            cmd.hasOption(OPT_DEBUG));

    calculator.run(inFile, sdfFile, coreFile, nCPU, memStr);
}

From source file:com.laex.cg2d.render.MyGdxGameDesktop.java

/**
 * Construct.//  w w  w.j  ava  2 s.  c  o m
 * 
 * @return the options
 */
public static Options construct() {
    final Options gnuOptions = new Options();

    Option cardWidth = new Option("cw", true, "Card Width");
    Option cardHeight = new Option("ch", true, "Card Height");
    Option cardNoX = new Option("cx", true, "Card No X");
    Option cardNoY = new Option("cy", true, "Card No Y");

    Option drawBodies = new Option("body", "Draw Bodies");
    Option drawJoint = new Option("joint", "Draw Joints");
    Option drawAABB = new Option("aabb", "Draw AABB");
    Option drawInactiveBodies = new Option("inactive", "Draw Inactive Bodieds");
    Option drawDebugData = new Option("debugData", "Draw Debug Data");
    Option drawEntities = new Option("entities", "Draw Entities");
    Option mouseJoint = new Option("mouseJoint", "Install Mouse Joint");

    Option ptmRatio = new Option("ptmRatio", true, "PIXELS TO METERS (PTM) Ratio");
    Option gravityX = new Option("gravityX", true, "Gravity X. Can be negative.");
    Option gravityY = new Option("gravityY", true, "Gravity Y. Can be negative.");
    Option timestep = new Option("timeStep", true, "TimeStep");
    Option velocityItr = new Option("velItr", true, "Velocity Iterations");
    Option positionItr = new Option("posItr", true, "Position Iterations");

    Option screenFile = new Option("screenFile", true, "Screen File");
    Option screenController = new Option("screenController", true, "Screen Controller File");

    gnuOptions.addOption(cardWidth);
    gnuOptions.addOption(cardHeight);
    gnuOptions.addOption(cardNoX);
    gnuOptions.addOption(cardNoY);
    gnuOptions.addOption(drawBodies);
    gnuOptions.addOption(drawJoint);
    gnuOptions.addOption(drawAABB);
    gnuOptions.addOption(drawInactiveBodies);
    gnuOptions.addOption(drawDebugData);
    gnuOptions.addOption(drawEntities);
    gnuOptions.addOption(mouseJoint);

    gnuOptions.addOption(ptmRatio);
    gnuOptions.addOption(gravityX);
    gnuOptions.addOption(gravityY);
    gnuOptions.addOption(timestep);
    gnuOptions.addOption(velocityItr);
    gnuOptions.addOption(positionItr);

    gnuOptions.addOption(screenFile);
    gnuOptions.addOption(screenController);

    return gnuOptions;
}