List of usage examples for org.apache.commons.cli Option Option
public Option(String opt, boolean hasArg, String description) throws IllegalArgumentException
From source file:com.genentech.chemistry.openEye.apps.SDFSubRMSD.java
public static void main(String... args) throws IOException { // create command line Options object Options options = new Options(); Option opt = new Option("in", true, "input file oe-supported"); opt.setRequired(true);/*from w w w .ja va 2 s. com*/ options.addOption(opt); opt = new Option("out", true, "output file oe-supported"); opt.setRequired(false); options.addOption(opt); opt = new Option("fragFile", true, "file with single 3d substructure query"); opt.setRequired(false); options.addOption(opt); opt = new Option("isMDL", false, "if given the fragFile is suposed to be an mdl query file, query features are 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("in"); String outFile = cmd.getOptionValue("out"); String fragFile = cmd.getOptionValue("fragFile"); // read fragment OESubSearch ss; oemolistream ifs = new oemolistream(fragFile); OEMolBase mol; if (!cmd.hasOption("isMDL")) { mol = new OEGraphMol(); oechem.OEReadMolecule(ifs, mol); ss = new OESubSearch(mol, OEExprOpts.AtomicNumber, OEExprOpts.BondOrder); } else { int aromodel = OEIFlavor.Generic.OEAroModelOpenEye; int qflavor = ifs.GetFlavor(ifs.GetFormat()); ifs.SetFlavor(ifs.GetFormat(), (qflavor | aromodel)); int opts = OEMDLQueryOpts.Default | OEMDLQueryOpts.SuppressExplicitH; OEQMol qmol = new OEQMol(); oechem.OEReadMDLQueryFile(ifs, qmol, opts); ss = new OESubSearch(qmol); mol = qmol; } double nSSatoms = mol.NumAtoms(); double sssCoords[] = new double[mol.GetMaxAtomIdx() * 3]; mol.GetCoords(sssCoords); mol.Clear(); ifs.close(); if (!ss.IsValid()) throw new Error("Invalid query " + args[0]); ifs = new oemolistream(inFile); oemolostream ofs = new oemolostream(outFile); int count = 0; while (oechem.OEReadMolecule(ifs, mol)) { count++; double rmsd = Double.MAX_VALUE; double molCoords[] = new double[mol.GetMaxAtomIdx() * 3]; mol.GetCoords(molCoords); for (OEMatchBase mb : ss.Match(mol, false)) { double r = 0; for (OEMatchPairAtom mp : mb.GetAtoms()) { OEAtomBase asss = mp.getPattern(); double sx = sssCoords[asss.GetIdx() * 3]; double sy = sssCoords[asss.GetIdx() * 3]; double sz = sssCoords[asss.GetIdx() * 3]; OEAtomBase amol = mp.getTarget(); double mx = molCoords[amol.GetIdx() * 3]; double my = molCoords[amol.GetIdx() * 3]; double mz = molCoords[amol.GetIdx() * 3]; r += Math.sqrt((sx - mx) * (sx - mx) + (sy - my) * (sy - my) + (sz - mz) * (sz - mz)); } r /= nSSatoms; rmsd = Math.min(rmsd, r); } if (rmsd != Double.MAX_VALUE) oechem.OESetSDData(mol, "SSSrmsd", String.format("%.3f", rmsd)); oechem.OEWriteMolecule(ofs, mol); mol.Clear(); } ifs.close(); ofs.close(); mol.delete(); ss.delete(); }
From source file:com.dasasian.chok.tool.ZkTool.java
public static void main(String[] args) { final Options options = new Options(); Option lsOption = new Option("ls", true, "list zp path contents"); lsOption.setArgName("path"); Option readOption = new Option("read", true, "read and print zp path contents"); readOption.setArgName("path"); Option rmOption = new Option("rm", true, "remove zk files"); rmOption.setArgName("path"); Option rmrOption = new Option("rmr", true, "remove zk directories"); rmrOption.setArgName("path"); OptionGroup actionGroup = new OptionGroup(); actionGroup.setRequired(true);//from www.j a va 2 s . co m actionGroup.addOption(lsOption); actionGroup.addOption(readOption); actionGroup.addOption(rmOption); actionGroup.addOption(rmrOption); options.addOptionGroup(actionGroup); final CommandLineParser parser = new GnuParser(); HelpFormatter formatter = new HelpFormatter(); try { final CommandLine line = parser.parse(options, args); ZkTool zkTool = new ZkTool(); if (line.hasOption(lsOption.getOpt())) { String path = line.getOptionValue(lsOption.getOpt()); zkTool.ls(path); } else if (line.hasOption(readOption.getOpt())) { String path = line.getOptionValue(readOption.getOpt()); zkTool.read(path); } else if (line.hasOption(rmOption.getOpt())) { String path = line.getOptionValue(rmOption.getOpt()); zkTool.rm(path, false); } else if (line.hasOption(rmrOption.getOpt())) { String path = line.getOptionValue(rmrOption.getOpt()); zkTool.rm(path, true); } zkTool.close(); } catch (ParseException e) { System.out.println(e.getClass().getSimpleName() + ": " + e.getMessage()); formatter.printHelp(ZkTool.class.getSimpleName(), options); } }
From source file:com.aestel.chemistry.openEye.fp.FPDictionarySorter.java
public static void main(String... args) throws IOException { long start = System.currentTimeMillis(); int iCounter = 0; int fpCounter = 0; // create command line Options object Options options = new Options(); Option opt = new Option("i", true, "input file [.ism,.sdf,...]"); opt.setRequired(true);/*from w w w .j a v a 2 s. c o m*/ options.addOption(opt); opt = new Option("fpType", true, "fingerPrintType: maccs|linear7|linear7*4"); opt.setRequired(true); options.addOption(opt); opt = new Option("sampleFract", true, "fraction of input molecules to use (Default=1)"); 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 type = cmd.getOptionValue("fpType"); boolean updateDictionaryFile = false; boolean hashUnknownFrag = false; Fingerprinter fprinter = Fingerprinter.createFingerprinter(type, updateDictionaryFile, hashUnknownFrag); OEMolBase mol = new OEGraphMol(); String inFile = cmd.getOptionValue("i"); oemolistream ifs = new oemolistream(inFile); double fract = 2D; String tmp = cmd.getOptionValue("sampleFract"); if (tmp != null) fract = Double.parseDouble(tmp); Random rnd = new Random(); LearningStrcutureCodeMapper mapper = (LearningStrcutureCodeMapper) fprinter.getMapper(); int dictSize = mapper.getMaxIdx() + 1; int[] freq = new int[dictSize]; while (oechem.OEReadMolecule(ifs, mol)) { iCounter++; if (rnd.nextDouble() < fract) { fpCounter++; Fingerprint fp = fprinter.getFingerprint(mol); for (int bit : fp.getBits()) freq[bit]++; } if (iCounter % 100 == 0) System.err.print("."); if (iCounter % 4000 == 0) { System.err.printf(" %d %d %dsec\n", iCounter, fpCounter, (System.currentTimeMillis() - start) / 1000); } } System.err.printf("FPDictionarySorter: Read %d structures calculated %d fprints in %d sec\n", iCounter, fpCounter, (System.currentTimeMillis() - start) / 1000); mapper.reSortDictionary(freq); mapper.writeDictionary(); fprinter.close(); }
From source file:msuresh.raftdistdb.AtomixDB.java
/** * Main Method which runs a Apache CLI which takes 3 different options for the 3 operations <br> * @param args <br>//from w w w.j a v a 2 s. co m * Options : <br> * -setup numberOfReplicas numberOfPartitions -- which sets the system given thenumber of partitions number of replicas per partition<br> * -set key Value -- adds a key value pair to the DB<br> * -get key -- returns a value for the key if it exists<br> * @throws InterruptedException */ public static void main(String[] args) throws InterruptedException, ExecutionException, FileNotFoundException { Options options = new Options(); Option opt = new Option("setup", true, "Sets up the replica that run the Raft Consensus Algorithm."); opt.setArgs(3); options.addOption(opt); opt = new Option("set", true, " Add a key-value pair into the Distributed Database."); opt.setArgs(3); options.addOption(opt); opt = new Option("get", true, "Given a key gets the value from the DB"); opt.setArgs(2); options.addOption(opt); opt = new Option("clean", false, "Cleans the state information."); options.addOption(opt); opt = new Option("test", true, "Cleans the state information."); opt.setArgs(2); options.addOption(opt); try { CommandLineParser parser = new BasicParser(); CommandLine line = null; line = parser.parse(options, args); if (line.hasOption("setup")) { String[] vals = line.getOptionValues("setup"); System.out.println(vals[0]); RaftCluster.createCluster(vals[0], Integer.parseInt(vals[1]), Integer.parseInt(vals[2])); } else if (line.hasOption("set")) { String[] vals = line.getOptionValues("set"); addKey(vals[0], vals[1], vals[2]); } else if (line.hasOption("get")) { String[] vals = line.getOptionValues("get"); getKey(vals[0], vals[1]); } else if (line.hasOption("clean")) { cleanState(); } else if (line.hasOption("test")) { String[] vals = line.getOptionValues("test"); TestAtomix.createCluster(vals[0], Integer.parseInt(vals[1])); } } catch (ParseException exp) { System.out.println("Unexpected exception:" + exp.getMessage()); } }
From source file:com.genentech.chemistry.tool.align.SDFAlign.java
public static void main(String... args) { Options options = new Options(); Option opt = new Option("in", true, "input sd file"); opt.setRequired(true);// w w w . j a v a2 s. c om options.addOption(opt); opt = new Option("out", true, "output file"); opt.setRequired(true); options.addOption(opt); opt = new Option("method", true, "fss|sss|MCS|clique (default mcs)."); options.addOption(opt); opt = new Option("ref", true, "reference molecule if not given first in file is used. If multiple ref molecules are read the min RMSD is reported"); options.addOption(opt); opt = new Option("mirror", false, "If given and the molecule is not chiral, return best mirror image."); options.addOption(opt); opt = new Option("rmsdTag", true, "Tagname for output of rmsd, default: no output."); options.addOption(opt); opt = new Option("atomMatch", true, "Sequence of none|default|hcount|noAromatic specifing how atoms are matched cf. oe document.\n" + "noAromatic can be used to make terminal atoms match aliphatic and aromatic atoms.\n" + "Queryfeatures are considered only if default is used."); options.addOption(opt); opt = new Option("bondMatch", true, "Sequence of none|default specifing how bonds are matched cf. oe document."); options.addOption(opt); opt = new Option("keepCoreHydrogens", false, "If not specified the hydrigen atoms are removed from the core."); options.addOption(opt); opt = new Option("outputMol", true, "aligned|original (def: aligned) use original to just compute rmsd."); options.addOption(opt); opt = new Option("doNotOptimize", false, "If specified the RMSD is computed without moving optimizing the overlay."); options.addOption(opt); opt = new Option("quiet", false, "Reduced warining messages"); options.addOption(opt); CommandLineParser parser = new BasicParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { exitWithHelp(e.getMessage(), options); } if (cmd.getArgs().length > 0) exitWithHelp("To many arguments", options); // do not check aromaticity on atoms so that a terminal atom matches aromatic and non aromatic atoms int atomExpr = OEExprOpts.DefaultAtoms; int bondExpr = OEExprOpts.DefaultBonds; String atomMatch = cmd.getOptionValue("atomMatch"); if (atomMatch == null) atomMatch = ""; atomMatch = '|' + atomMatch.toLowerCase() + '|'; String bondMatch = cmd.getOptionValue("bondMatch"); if (bondMatch == null) bondMatch = ""; bondMatch = '|' + bondMatch.toLowerCase() + '|'; String inFile = cmd.getOptionValue("in"); String outFile = cmd.getOptionValue("out"); String refFile = cmd.getOptionValue("ref"); String method = cmd.getOptionValue("method"); String rmsdTag = cmd.getOptionValue("rmsdTag"); String oMol = cmd.getOptionValue("outputMol"); boolean doMirror = cmd.hasOption("mirror"); boolean doOptimize = !cmd.hasOption("doNotOptimize"); boolean quiet = cmd.hasOption("quiet"); OUTType outputMol = oMol == null ? OUTType.ALIGNED : OUTType.valueOf(oMol.toUpperCase()); if (atomMatch.startsWith("|none")) atomExpr = 0; if (atomMatch.contains("|hcount|")) atomExpr |= OEExprOpts.HCount; if (atomMatch.contains("|noAromatic|")) atomExpr &= (~OEExprOpts.Aromaticity); if (bondMatch.startsWith("|none")) bondExpr = 0; ArrayList<OEMol> refmols = new ArrayList<OEMol>(); if (refFile != null) { oemolistream reffs = new oemolistream(refFile); if (!is3DFormat(reffs.GetFormat())) oechem.OEThrow.Fatal("Invalid input format: need 3D coordinates"); reffs.SetFormat(OEFormat.MDL); int aromodel = OEIFlavor.Generic.OEAroModelOpenEye; int qflavor = reffs.GetFlavor(reffs.GetFormat()); reffs.SetFlavor(reffs.GetFormat(), (qflavor | aromodel)); OEMol rmol = new OEMol(); while (oechem.OEReadMDLQueryFile(reffs, rmol)) { if (!cmd.hasOption("keepCoreHydrogens")) oechem.OESuppressHydrogens(rmol); refmols.add(rmol); rmol = new OEMol(); } rmol.delete(); if (refmols.size() == 0) throw new Error("reference file had no entries"); reffs.close(); } oemolistream fitfs = new oemolistream(inFile); if (!is3DFormat(fitfs.GetFormat())) oechem.OEThrow.Fatal("Invalid input format: need 3D coordinates"); oemolostream ofs = new oemolostream(outFile); if (!is3DFormat(ofs.GetFormat())) oechem.OEThrow.Fatal("Invalid output format: need 3D coordinates"); AlignInterface aligner = null; OEGraphMol fitmol = new OEGraphMol(); if (oechem.OEReadMolecule(fitfs, fitmol)) { if (refmols.size() == 0) { OEMol rmol = new OEMol(fitmol); if (!cmd.hasOption("keepCoreHydrogens")) oechem.OESuppressHydrogens(rmol); refmols.add(rmol); } if ("sss".equalsIgnoreCase(method)) { aligner = new SSSAlign(refmols, outputMol, rmsdTag, doOptimize, doMirror, atomExpr, bondExpr, quiet); } else if ("clique".equalsIgnoreCase(method)) { aligner = new CliqueAlign(refmols, outputMol, rmsdTag, doOptimize, doMirror, atomExpr, bondExpr, quiet); } else if ("fss".equalsIgnoreCase(method)) { if (cmd.hasOption("atomMatch") || cmd.hasOption("bondMatch")) exitWithHelp("method fss does not support '-atomMatch' or '-bondMatch'", options); aligner = new FSSAlign(refmols, outputMol, rmsdTag, doOptimize, doMirror); } else { aligner = new McsAlign(refmols, outputMol, rmsdTag, doOptimize, doMirror, atomExpr, bondExpr, quiet); } do { aligner.align(fitmol); oechem.OEWriteMolecule(ofs, fitmol); } while (oechem.OEReadMolecule(fitfs, fitmol)); } fitmol.delete(); if (aligner != null) aligner.close(); for (OEMolBase mol : refmols) mol.delete(); fitfs.close(); ofs.close(); }
From source file:GossipP2PServer.java
public static void main(String args[]) { // Arguments that should be passed in int port = -1; String databasePath = ""; // Set up arg options Options options = new Options(); Option p = new Option("p", true, "Port for server to listen on."); options.addOption(p);//from w w w . j a v a 2 s.c o m Option d = new Option("d", true, "Path to database."); options.addOption(d); CommandLineParser clp = new DefaultParser(); try { CommandLine cl = clp.parse(options, args); if (cl.hasOption("p")) { port = Integer.parseInt(cl.getOptionValue("p")); } if (cl.hasOption("d")) { databasePath = cl.getOptionValue("d"); } // If we have all we need start the server and setup database. if (port != -1 && !databasePath.isEmpty() && databasePath != null) { Database.getInstance().initializeDatabase(databasePath); runConcurrentServer(port); } else { showArgMenu(options); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.genentech.struchk.sdfNormalizer.java
public static void main(String[] args) { long start = System.currentTimeMillis(); int nMessages = 0; int nErrors = 0; int nStruct = 0; // create command line Options object Options options = new Options(); Option opt = new Option("in", true, "input file [.ism,.sdf,...]"); opt.setRequired(true);/* ww w .ja va 2s.c o m*/ options.addOption(opt); opt = new Option("out", true, "output file"); opt.setRequired(true); options.addOption(opt); opt = new Option("mol", true, "molFile used for output: ORIGINAL(def)|NORMALIZED|TAUTOMERIC"); opt.setRequired(false); options.addOption(opt); opt = new Option("shortMessage", false, "Limit message to first 80 characters to conform with sdf file specs."); opt.setRequired(false); options.addOption(opt); CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(options, args); } catch (ParseException e) { exitWithHelp(options, e.getMessage()); throw new Error(e); // avoid compiler errors } args = cmd.getArgs(); if (args.length != 0) { System.err.print("Unknown options: " + args + "\n\n"); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("sdfNormalizer", options); System.exit(1); } String molOpt = cmd.getOptionValue("mol"); OUTMolFormat outMol = OUTMolFormat.ORIGINAL; if (molOpt == null || "original".equalsIgnoreCase(molOpt)) outMol = OUTMolFormat.ORIGINAL; else if ("NORMALIZED".equalsIgnoreCase(molOpt)) outMol = OUTMolFormat.NORMALIZED; else if ("TAUTOMERIC".equalsIgnoreCase(molOpt)) outMol = OUTMolFormat.TAUTOMERIC; else { System.err.printf("Unkown option for -mol: %s\n", molOpt); System.exit(1); } String inFile = cmd.getOptionValue("in"); String outFile = cmd.getOptionValue("out"); boolean limitMessage = cmd.hasOption("shortMessage"); try { oemolistream ifs = new oemolistream(inFile); oemolostream ofs = new oemolostream(outFile); URL cFile = OEStruchk.getResourceURL(OEStruchk.class, "Struchk.xml"); // create OEStruchk from config file OEStruchk strchk = new OEStruchk(cFile, CHECKConfig.ASSIGNStructFlag, false); OEGraphMol mol = new OEGraphMol(); StringBuilder sb = new StringBuilder(2000); while (oechem.OEReadMolecule(ifs, mol)) { if (!strchk.applyRules(mol, null)) nErrors++; switch (outMol) { case NORMALIZED: mol.Clear(); oechem.OEAddMols(mol, strchk.getTransformedMol("parent")); break; case TAUTOMERIC: mol.Clear(); oechem.OEAddMols(mol, strchk.getTransformedMol(null)); break; case ORIGINAL: break; } oechem.OESetSDData(mol, "CTISMILES", strchk.getTransformedIsoSmiles(null)); oechem.OESetSDData(mol, "CTSMILES", strchk.getTransformedSmiles(null)); oechem.OESetSDData(mol, "CISMILES", strchk.getTransformedIsoSmiles("parent")); oechem.OESetSDData(mol, "Strutct_Flag", strchk.getStructureFlag().getName()); List<Message> msgs = strchk.getStructureMessages(null); nMessages += msgs.size(); for (Message msg : msgs) sb.append(String.format("\t%s:%s", msg.getLevel(), msg.getText())); if (limitMessage) sb.setLength(Math.min(sb.length(), 80)); oechem.OESetSDData(mol, "NORM_MESSAGE", sb.toString()); oechem.OEWriteMolecule(ofs, mol); sb.setLength(0); nStruct++; } strchk.delete(); mol.delete(); ifs.close(); ifs.delete(); ofs.close(); ofs.delete(); } catch (Exception e) { throw new Error(e); } finally { System.err.printf("sdfNormalizer: Checked %d structures %d errors, %d messages in %dsec\n", nStruct, nErrors, nMessages, (System.currentTimeMillis() - start) / 1000); } }
From source file:com.aestel.chemistry.openEye.fp.DistMatrix.java
public static void main(String... args) throws IOException { long start = System.currentTimeMillis(); // create command line Options object Options options = new Options(); Option opt = new Option("i", true, "input file [.tsv from FingerPrinter]"); opt.setRequired(true);/*from ww w . j ava 2 s. co m*/ options.addOption(opt); opt = new Option("o", true, "outpur file [.tsv "); 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) exitWithHelp(options); String file = cmd.getOptionValue("i"); BufferedReader in = new BufferedReader(new FileReader(file)); file = cmd.getOptionValue("o"); PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file))); ArrayList<Fingerprint> fps = new ArrayList<Fingerprint>(); ArrayList<String> ids = new ArrayList<String>(); String line; while ((line = in.readLine()) != null) { String[] parts = line.split("\t"); if (parts.length == 3) { ids.add(parts[0]); fps.add(new ByteFingerprint(parts[2])); } } in.close(); out.print("ID"); for (int i = 0; i < ids.size(); i++) { out.print('\t'); out.print(ids.get(i)); } out.println(); for (int i = 0; i < ids.size(); i++) { out.print(ids.get(i)); Fingerprint fp1 = fps.get(i); for (int j = 0; j <= i; j++) { out.printf("\t%.4g", fp1.tanimoto(fps.get(j))); } out.println(); } out.close(); System.err.printf("Done %d fingerprints in %.2gsec\n", fps.size(), (System.currentTimeMillis() - start) / 1000D); }
From source file:de.burlov.amazon.s3.S3Utils.java
public static void main(String[] args) { Options opts = new Options(); OptionGroup gr = new OptionGroup(); gr.setRequired(true);//from w w w . j av a 2 s.c o m gr.addOption(new Option(LIST, false, "")); gr.addOption(new Option(DELETE, false, "")); opts.addOptionGroup(gr); opts.addOption(new Option("k", true, "Access key for AWS account")); opts.addOption(new Option("s", true, "Secret key for AWS account")); opts.addOption(new Option("b", true, "Bucket")); CommandLine cmd = null; try { cmd = new PosixParser().parse(opts, args); String accessKey = cmd.getOptionValue("k"); if (StringUtils.isBlank(accessKey)) { System.out.println("Missing amazon access key"); return; } String secretKey = cmd.getOptionValue("s"); if (StringUtils.isBlank(secretKey)) { System.out.println("Missing secret key"); return; } String bucket = cmd.getOptionValue("b"); if (cmd.hasOption(LIST)) { if (StringUtils.isBlank(bucket)) { printBuckets(accessKey, secretKey); } else { printBucket(accessKey, secretKey, bucket); } } else if (cmd.hasOption(DELETE)) { if (StringUtils.isBlank(bucket)) { System.out.println("Bucket name required"); return; } int count = deleteBucket(accessKey, secretKey, bucket); System.out.println("Deleted objects in bucket: " + count); } } catch (ParseException e) { System.out.println(e.getMessage()); printUsage(opts); return; } catch (Exception e) { e.printStackTrace(System.err); } }
From source file:com.aestel.chemistry.openEye.fp.apps.SDFFPSphereExclusion.java
public static void main(String... args) throws IOException { // create command line Options object Options options = new Options(); Option opt = new Option("in", true, "input file [.sdf,...]"); opt.setRequired(true);//w w w . j a v a2s. c o m options.addOption(opt); opt = new Option("out", true, "output file oe-supported"); opt.setRequired(false); options.addOption(opt); opt = new Option("ref", true, "refrence file to be loaded before starting"); opt.setRequired(false); options.addOption(opt); opt = new Option("fpTag", true, "field containing fingerpPrint"); opt.setRequired(true); options.addOption(opt); opt = new Option("maxTanimoto", false, "If given the modified maxTanimoto will be used = common/(2*Max(na,nb)-common)."); opt.setRequired(false); options.addOption(opt); opt = new Option("radius", true, "radius of exclusion sphere, exclude anything with similarity >= radius."); opt.setRequired(true); options.addOption(opt); opt = new Option("printSphereMatchCount", false, "check and print membership of candidates not " + " only to the first centroid which has sim >= radius but to all centroids" + " found up to that input. This will output a candidate multiple times." + " Implies checkSpheresInOrder."); options.addOption(opt); opt = new Option("checkSpheresInOrder", false, "For each candiate: compare to centroids from first to last (default is last to first)"); options.addOption(opt); opt = new Option("printAll", false, "print all molecule, check includeIdx tag"); 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(); } // the only reason not to match centroids in reverse order id if // a non-centroid is to be assigned to multiple centroids boolean printSphereMatchCount = cmd.hasOption("printSphereMatchCount"); boolean reverseMatch = !cmd.hasOption("checkSpheresInOrder") && !printSphereMatchCount; boolean printAll = cmd.hasOption("printAll") || printSphereMatchCount; boolean doMaxTanimoto = cmd.hasOption("maxTanimoto"); String fpTag = cmd.getOptionValue("fpTag"); double radius = Double.parseDouble(cmd.getOptionValue("radius")); String inFile = cmd.getOptionValue("in"); String outFile = cmd.getOptionValue("out"); String refFile = cmd.getOptionValue("ref"); SimComparatorFactory<OEMolBase, FPComparator, FPComparator> compFact = new FPComparatorFact(doMaxTanimoto, fpTag); SphereExclusion<FPComparator, FPComparator> alg = new SphereExclusion<FPComparator, FPComparator>(compFact, refFile, outFile, radius, reverseMatch, printSphereMatchCount, printAll); alg.run(inFile); alg.close(); }