Options setupOptions(int theArgc, char * theArgv[]){ Options opt; OptionParser OP; OP.setRequired(opt.required); OP.setAllowed(opt.optional); OP.readArgv(theArgc, theArgv); if (OP.countOptions() == 0){ cout << "Usage:" << endl; cout << endl; cout << "calcSasaAll --list LIST\n"; exit(0); } opt.list= OP.getString("list"); if (OP.fail()){ cerr << "ERROR 1111 list not specified.\n"; exit(1111); } opt.fasta = OP.getString("fasta"); if (OP.fail()){ cerr << "ERROR 1111 fasta not specified.\n"; exit(1111); } opt.refSeqName = OP.getString("refSeqName"); if (OP.fail()){ cerr << "ERROR 1111 refSeqName not specified.\n"; exit(1111); } return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ // Create the options Options opt; // Parse the options OptionParser OP; OP.readArgv(theArgc, theArgv); OP.setRequired(opt.required); OP.setDefaultArguments(opt.defaultArgs); // the default argument is the --configfile option if (OP.countOptions() == 0){ cout << "Usage: getSphericalCoordinates conf" << endl; cout << endl; cout << "\n"; cout << "pdb PDB\n"; cout << endl; exit(0); } opt.configFile = OP.getString("configfile"); if (opt.configFile != "") { OP.readFile(opt.configFile); if (OP.fail()) { string errorMessages = "Cannot read configuration file " + opt.configFile + "\n"; cerr << "ERROR 1111 "<<errorMessages<<endl; } } opt.pdb = OP.getString("pdb"); if (OP.fail()){ cerr << "ERROR 1111 no pdb specified."<<endl; exit(1111); } opt.resnum = OP.getInt("resnum"); if (OP.fail()){ cerr << "ERRROR 1111 no resnum\n"; exit(1111); } opt.chain = OP.getString("chain"); if (OP.fail()){ cerr << "ERRROR 1111 no chain\n"; exit(1111); } opt.negativeRes = OP.getBool("neg"); if (OP.fail()){ opt.negativeRes = false; } if (opt.negativeRes) { opt.resnum = -1*opt.resnum; } opt.printFrames = OP.getBool("printFrames"); return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ // Create the options Options opt; // Parse the options OptionParser OP; OP.setRequired(opt.required); OP.setDefaultArguments(opt.defaultArgs); // the default argument is the --configfile option OP.readArgv(theArgc, theArgv); if (OP.countOptions() == 0){ cout << "Usage: splitIntoChains " << endl; cout << endl; cout << "\n"; cout << "pdblist PDB\n"; cout << endl; exit(0); } opt.pdblist = OP.getString("pdblist"); if (OP.fail()){ cerr << "ERROR 1111 no pdblist specified."<<endl; exit(1111); } return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ // Create the options Options opt; // Parse the options OptionParser OP; OP.setRequired(opt.required); OP.setDefaultArguments(opt.defaultArgs); // the default argument is the --configfile option OP.readArgv(theArgc, theArgv); if (OP.countOptions() == 0){ cout << "Usage: getConsecutivePhiPsi " << endl; cout << endl; cout << "\n"; cout << "pdblist PDB\n"; cout << "SSE L # L = Loop, S = Strand, H = Helix\n" cout << endl; exit(0); } opt.pdblist = OP.getString("pdblist"); if (OP.fail()){ cerr << "ERROR 1111 no pdblist specified."<<endl; exit(1111); } opt.SSE = OP.getString("sse"); if (OP.fail()){ opt.SSE = ""; } return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ // Create the options Options opt; // Parse the options OptionParser OP; OP.setRequired(opt.required); OP.setDefaultArguments(opt.defaultArgs); // the default argument is the --configfile option OP.readArgv(theArgc, theArgv); if (OP.countOptions() == 0){ cout << "Usage: getTripletCaMeasurements " << endl; cout << endl; cout << "\n"; cout << "pdblist PDB\n"; cout << endl; exit(0); } opt.pdblist = OP.getString("pdblist"); if (OP.fail()){ cerr << "ERROR 1111 no pdblist specified."<<endl; exit(1111); } opt.numSamples = OP.getInt("numSamples"); if (OP.fail()){ opt.numSamples = 10000; cerr << "WARNING numSamples set to "<<opt.numSamples<<endl; } return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ Options opt; OptionParser OP; OP.setRequired(opt.required); OP.setAllowed(opt.optional); OP.readArgv(theArgc, theArgv); if (OP.countOptions() == 0){ cout << "Usage:" << endl; cout << endl; cout << "createVectorHash --list pdb.list --outfile foo.vh\n"; exit(0); } opt.list = OP.getString("list"); if (OP.fail()){ cerr << "ERROR 1111 pdb not specified.\n"; exit(1111); } opt.outfile = OP.getString("outfile"); if (OP.fail()){ cerr << "WARNING outfile not specified. Using: '"<<opt.list<<".vh'"<<endl; opt.outfile = opt.list+".vh"; } return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ Options opt; OptionParser OP; OP.readArgv(theArgc, theArgv); OP.setRequired(opt.required); OP.setAllowed(opt.optional); if (OP.countOptions() == 0) { cout << "Usage:" << endl; cout << endl; cout << "moveProteinCenter --pdb PDB [--x X --y Y --z Z --sele SELE --outfile OUTFILE]\n"; exit(0); } opt.pdb = OP.getString("pdb"); if (OP.fail()){ cerr << "Pdb not specified, failing.\n"; exit(1111); } opt.x = OP.getDouble("x"); if (OP.fail()){ cerr << "Warning, x coordinate set to 0.0\n"; opt.x = 0.0; } opt.y = OP.getDouble("y"); if (OP.fail()){ cerr << "Warning, y coordinate set to 0.0\n"; opt.y = 0.0; } opt.z = OP.getDouble("z"); if (OP.fail()){ cerr << "Warning, z coordinate set to 0.0\n"; opt.z = 0.0; } opt.sele = OP.getString("sele"); if (OP.fail()){ opt.sele = ""; } opt.outfile = OP.getString("outfile"); if (OP.fail()){ cerr << "Warning, outfile set to test.pdb" << endl; opt.outfile = "test.pdb"; } return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ // Create the options Options opt; // Parse the options OptionParser OP; OP.readArgv(theArgc, theArgv); OP.setRequired(opt.required); OP.setAllowed(opt.optional); // OP.setShortOptionEquivalent(opt.equivalent); OP.setDefaultArguments(opt.defaultArgs); // the default argument is the --configfile option OP.autoExtendOptions(); // if you give option "solvat" it will be autocompleted to "solvationfile" if (OP.countOptions() == 0){ cout << "Usage:" << endl; cout << endl; cout << "pdb PDB"<<endl; exit(0); } opt.pdb = OP.getString("pdb"); if (OP.fail()){ cerr << "ERROR 1111 no pdb file"<<endl; } opt.tol = OP.getDouble("tol"); if (OP.fail()){ opt.tol = 1.88; cerr << "WARNING tol set to default: "<<opt.tol<<endl; } opt.interfaceOnly = OP.getBool("interfaceOnly"); if (OP.fail()){ opt.interfaceOnly = false; } opt.atomPair = OP.getString("atomPair"); if (OP.fail()){ opt.atomPair = ""; } opt.elementPair = OP.getString("elementPair"); if (OP.fail()){ opt.elementPair = ""; } opt.printAll = OP.getBool("printAll"); if (OP.fail()){ opt.printAll = false; } return opt; }
int main(int argc, char *argv[]){ vector<string> required; required.push_back("flatfile"); vector<string> optional; optional.push_back("reread"); optional.push_back("outfile"); OptionParser OP; OP.readArgv(argc,argv); OP.setRequired(required); OP.setAllowed(optional); string flatfile = OP.getString("flatfile"); if (OP.fail()){ cout << "Usage: ./testMolecularInterfaceDatabase --flatfile FLAT.mid [ --outfile mid.ckpt --reread --archive text ]\n"; exit(0); } string outfile = OP.getString("outfile"); if (OP.fail()){ outfile = "mid.ckpt"; } string archive = OP.getString("archive"); if (OP.fail()){ archive = "text"; } // Create from flat file MIDReader mread; mread.open(flatfile); mread.read(archive); MoleculeInterfaceDatabase &mid = mread.getMoleculeInterfaceDatabase(); cout << "MID size: "<<mid.size()<<endl; // Write out to binary mid.setArchiveType(archive); mid.save_checkpoint(outfile); // Re-read if option set.. bool reread = OP.getBool("reread"); if (!OP.fail() && reread){ cout << "Re-reading binary MolecularInterfaceDatabase.\n"; Timer t; double start = t.getWallTime(); MoleculeInterfaceDatabase mid2; mid2.setArchiveType(archive); mid2.load_checkpoint(outfile); cout << "MID2 size: "<<mid2.size()<<" read in "<<(t.getWallTime() - start)<<" seconds."<<endl; } }
Options setupOptions(int theArgc, char * theArgv[]){ Options opt; OptionParser OP; OP.readArgv(theArgc, theArgv); OP.setRequired(opt.required); OP.setAllowed(opt.optional); if (OP.countOptions() == 0){ cout << "Usage:" << endl; cout << endl; cout << "testQuench --pdb PDB\n"; exit(0); } opt.pdb = OP.getString("pdb"); if (OP.fail()){ cerr << "ERROR 1111 pdb not specified.\n"; exit(1111); } opt.topfile = OP.getString("topfile"); if (OP.fail()){ cerr << "WARNING no topfile specified, using default "<<SYSENV.getEnv("MSL_CHARMM_TOP")<<endl; opt.topfile = SYSENV.getEnv("MSL_CHARMM_TOP"); } opt.parfile = OP.getString("parfile"); if (OP.fail()){ cerr << "WARNING no parfile specified, using default "<<SYSENV.getEnv("MSL_CHARMM_PAR")<<endl; opt.parfile = SYSENV.getEnv("MSL_CHARMM_PAR"); } opt.rotlib = OP.getString("rotlib"); if (OP.fail()){ cerr << "WARNING no rotlib specified, using default "<<SYSENV.getEnv("MSL_ROTLIB")<<endl; opt.rotlib = SYSENV.getEnv("MSL_ROTLIB"); } return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ Options opt; OptionParser OP; OP.setRequired(opt.required); OP.setAllowed(opt.optional); OP.readArgv(theArgc, theArgv); if (OP.countOptions() == 0){ cout << "Usage:" << endl; cout << endl; cout << "patchAnalysis --pdb foo.pdb --patch1 \"chain A and resi 5-150\" --patch2 \"chain B and resi 5-150\" \n"; exit(0); } opt.list= OP.getString("list"); if (OP.fail()){ opt.list = ""; } opt.pdb= OP.getString("pdb"); if (OP.fail() && opt.list == ""){ cerr << "ERROR 1111 pdb or list not specified.\n"; exit(1111); } opt.patch1 = OP.getString("patch1"); if (OP.fail()){ cerr << "ERROR 1111 patch1 not specified.\n"; exit(1111); } opt.patch2 = OP.getString("patch2"); if (OP.fail()){ cerr << "ERROR 1111 patch2 not specified.\n"; exit(1111); } return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ // Create the options Options opt; // Parse the options OptionParser OP; OP.readArgv(theArgc, theArgv); OP.setRequired(opt.required); OP.setAllowed(opt.optional); // OP.setShortOptionEquivalent(opt.equivalent); OP.setDefaultArguments(opt.defaultArgs); // the default argument is the --configfile option OP.autoExtendOptions(); // if you give option "solvat" it will be autocompleted to "solvationfile" if (OP.countOptions() == 0){ cout << "Usage:" << endl; cout << endl; cout << "fillInSideChains CONF\n"; exit(0); } opt.configfile = OP.getString("configfile"); if (opt.configfile != "") { OP.readFile(opt.configfile); if (OP.fail()) { string errorMessages = "Cannot read configuration file " + opt.configfile + "\n"; cerr << "ERROR 1111 "<<errorMessages<<endl; } } if (OP.getBool("help")){ cout << "# PDB "<<endl; cout << "pdb foo.pdb"<<endl<<endl; cout << "# Output pdb" <<endl; cout << "outpdb /tmp/out.pdb"<<endl<<endl; cout << "# Rotamer library"<<endl; cout << "rotlib /library/rotlib/balanced/rotlib-balanced-200.txt"<<endl<<endl; cout << "# CHARMM Topology"<<endl; cout << "topfile /library/charmmTopPar/top_all27_prot_lipid.inp"<<endl<<endl; cout << "# CHARMM Parameter"<<endl; cout << "parfile /library/charmmTopPar/par_all27_prot_lipid.inp"<<endl<<endl; exit(1); } opt.pdb = OP.getString("pdb"); if (OP.fail()){ cerr << "ERROR 1111 no pdb file"<<endl; } opt.rotlib = OP.getString("rotlib"); if (OP.fail()){ cerr << "ERROR 1111 no rotlib file"<<endl; } opt.topfile = OP.getString("topfile"); if (OP.fail()){ cerr << "ERROR 1111 no topfile file"<<endl; } opt.parfile = OP.getString("parfile"); if (OP.fail()){ cerr << "ERROR 1111 no parfile file"<<endl; } opt.outpdb = OP.getString("outpdb"); if (OP.fail()){ opt.outpdb = "/tmp/out.pdb"; cerr << "WARNING no outpdb file specifed will write to: "<<opt.outpdb<<endl; } opt.debug = OP.getBool("debug"); if (OP.fail()){ opt.debug = false; } return opt; }
Options parseOptions(int _argc, char * _argv[], Options defaults) { /****************************************** * Pass the array of argument and the name of * a configuration file to the ArgumentParser * object. Then ask for the value of the argument * and collect error and warnings. * * This function returns a Options structure * defined at the head of this file ******************************************/ Options opt; /****************************************** * Set the allowed and required options: * * Example of configuartion file: * ******************************************/ vector<string> required; vector<string> allowed; opt.required.push_back("sequence"); opt.required.push_back("startPos"); opt.required.push_back("startRegPos"); opt.required.push_back("r0_start"); opt.required.push_back("r0_end"); opt.required.push_back("r0_step"); opt.required.push_back("r1_start"); opt.required.push_back("r1_end"); opt.required.push_back("r1_step"); opt.required.push_back("w1_start"); opt.required.push_back("w1_end"); opt.required.push_back("w1_step"); opt.required.push_back("phi1_start"); opt.required.push_back("phi1_end"); opt.required.push_back("phi1_step"); opt.required.push_back("rpr_start"); opt.required.push_back("rpr_end"); opt.required.push_back("rpr_step"); opt.required.push_back("pitch_start"); opt.required.push_back("pitch_end"); opt.required.push_back("pitch_step"); opt.required.push_back("nRes"); opt.required.push_back("symmetry"); opt.required.push_back("N"); //opt.required.push_back("testNo"); opt.allowed.push_back("setState"); opt.allowed.push_back("rotamerStates"); opt.allowed.push_back("rotamerSamplingSize"); opt.allowed.push_back("seed"); opt.required.push_back("rotamerLibrary"); //filename of rotamer library file opt.allowed.push_back("outputdir"); opt.allowed.push_back("outputfile"); //filename of output file opt.allowed.push_back("version"); // --version opt.allowed.push_back("v"); // -v is equivalent to --version opt.allowed.push_back("help"); // --help opt.allowed.push_back("h"); // -h is equivalent to --help opt.allowed.push_back("configfile"); opt.allowed.push_back("runDEE"); opt.allowed.push_back("runEnum"); opt.allowed.push_back("runSCMF"); opt.allowed.push_back("runMCO"); opt.equivalent.push_back(vector<string>()); opt.equivalent.back().push_back("v"); opt.equivalent.back().push_back("version"); opt.equivalent.push_back(vector<string>()); opt.equivalent.back().push_back("h"); opt.equivalent.back().push_back("help"); opt.defaultArgs.push_back("configfile"); //OptionParser OP(_argc, _argv); OptionParser OP; OP.setShortOptionEquivalent(opt.equivalent); OP.readArgv(_argc, _argv); OP.setDefaultArguments(opt.defaultArgs); // a pdb file value can be given as a default argument without the --pdbfile option OP.setRequired(opt.required); OP.setAllowed(opt.allowed); OP.autoExtendOptions(); // if you give option "solvat" it will be autocompleted to "solvationfile" if (OP.countOptions() == 0) { usage(); exit(0); } opt.configfile = OP.getString("configfile"); if (opt.configfile != "") { OP.readFile(opt.configfile); if (OP.fail()) { opt.errorFlag = true; opt.errorMessages += "Cannot read configuration file " + opt.configfile + "\n"; exit(1); } } /***************************************** * VERSION AND HELP * * --version or -v arguments print the version number * --help prints the usage and help *****************************************/ opt.version = OP.getBool("version"); //if (OP.fail()) { // opt.version = OP.getBool("v"); //} if (opt.version) { version(); exit(0); } opt.help = OP.getBool("help"); // if (OP.fail()) { // opt.help = OP.getBool("h"); // } if (opt.help) { help(defaults); exit(0); } /***************************************** * CHECK THE GIVEN OPTIONS *****************************************/ if (!OP.checkOptions()) { opt.errorFlag = true; opt.OPerrors = OP.getErrors(); return opt; } opt.errorFlag = false; opt.warningFlag = false; /***************************************** * OUTPUT DIR AND FILES *****************************************/ opt.outputdir = OP.getString("outputdir"); if (OP.fail() || opt.outputdir == "") { opt.outputdir = defaults.outputdir; } opt.outputfile = OP.getString("outputfile"); if (OP.fail()) { opt.outputfile = defaults.outputfile; } if (opt.outputfile != "" && opt.outputfile != "STDOUT") { opt.coutRedirected = true; opt.cout_fs = new ofstream(); opt.cerr_fs = new ofstream(); } else { opt.coutRedirected = false; opt.cout_fs = NULL; opt.cerr_fs = NULL; } /***************************************** * CHECK THE GIVEN OPTIONS *****************************************/ //opt.commandName = OP.getCommandName(); //if (!OP.checkOptions()) { // opt.errorFlag = true; // opt.disallowed = OP.getDisallowedOptions(); // opt.missing = OP.getMissingOptions(); // opt.ambiguous = OP.getAmbiguousOptions(); // return opt; //} opt.errorFlag = false; opt.warningFlag = false; opt.sequence= OP.getString("sequence"); if (OP.fail()) { opt.errorMessages = "sequence not specified"; opt.errorFlag = true; } opt.startPos = OP.getStringVector("startPos"); if (OP.fail()) { opt.errorMessages = "startPos not specified"; opt.errorFlag = true; } opt.startRegPos = OP.getString("startRegPos"); if (OP.fail()) { opt.errorMessages = "startRegPos not specified"; opt.errorFlag = true; } opt.r0_start = OP.getDouble("r0_start"); if (OP.fail()) { opt.errorMessages = "r0 not specified"; opt.errorFlag = true; } opt.r0_end = OP.getDouble("r0_end"); if (OP.fail()) { opt.errorMessages = "r0 not specified"; opt.errorFlag = true; } opt.r0_step = OP.getDouble("r0_step"); if (OP.fail()) { opt.errorMessages = "r0 not specified"; opt.errorFlag = true; } opt.r1_start = OP.getDouble("r1_start"); if (OP.fail()) { opt.errorMessages = "r1 not specified"; opt.errorFlag = true; } opt.r1_end = OP.getDouble("r1_end"); if (OP.fail()) { opt.errorMessages = "r1 not specified"; opt.errorFlag = true; } opt.r1_step = OP.getDouble("r1_step"); if (OP.fail()) { opt.errorMessages = "r1 not specified"; opt.errorFlag = true; } opt.w1_start = OP.getDouble("w1_start"); if (OP.fail()) { opt.errorMessages = "w1 not specified"; opt.errorFlag = true; } opt.w1_end = OP.getDouble("w1_end"); if (OP.fail()) { opt.errorMessages = "w1 not specified"; opt.errorFlag = true; } opt.w1_step = OP.getDouble("w1_step"); if (OP.fail()) { opt.errorMessages = "w1 not specified"; opt.errorFlag = true; } opt.phi1_start = OP.getDouble("phi1_start"); if (OP.fail()) { opt.errorMessages = "phi1 not specified"; opt.errorFlag = true; } opt.phi1_end = OP.getDouble("phi1_end"); if (OP.fail()) { opt.errorMessages = "phi1 not specified"; opt.errorFlag = true; } opt.phi1_step = OP.getDouble("phi1_step"); if (OP.fail()) { opt.errorMessages = "phi1 not specified"; opt.errorFlag = true; } opt.rpr_start = OP.getDouble("rpr_start"); if (OP.fail()) { opt.errorMessages = "rpr not specified"; opt.errorFlag = true; } opt.rpr_end = OP.getDouble("rpr_end"); if (OP.fail()) { opt.errorMessages = "rpr not specified"; opt.errorFlag = true; } opt.rpr_step = OP.getDouble("rpr_step"); if (OP.fail()) { opt.errorMessages = "rpr not specified"; opt.errorFlag = true; } opt.pitch_start = OP.getDouble("pitch_start"); if (OP.fail()) { opt.errorMessages = "pitch not specified"; opt.errorFlag = true; } opt.pitch_end = OP.getDouble("pitch_end"); if (OP.fail()) { opt.errorMessages = "pitch not specified"; opt.errorFlag = true; } opt.pitch_step = OP.getDouble("pitch_step"); if (OP.fail()) { opt.errorMessages = "pitch not specified"; opt.errorFlag = true; } opt.nRes = OP.getInt("nRes"); if (OP.fail()) { opt.errorMessages = "number of residues not specified"; opt.errorFlag = true; } opt.symmetry = OP.getString("symmetry"); if (OP.fail()) { opt.errorMessages = "symmetry not specified"; opt.errorFlag = true; } opt.N = OP.getInt("N"); if (OP.fail()) { opt.errorMessages = "N not specified"; opt.errorFlag = true; } opt.rotamerLibrary = OP.getString("rotamerLibrary"); if (OP.fail()) { opt.errorMessages = "rotamerLibrary not specified"; opt.errorFlag = true; } opt.outputfile = OP.getString("outputfile"); if (OP.fail()) { opt.errorMessages = "outputfile not specified"; opt.errorFlag = true; } /* opt.testNo = OP.getInt("testNo"); if (OP.fail()) { opt.errorMessages = "testNo not specified"; opt.errorFlag = true; } */ opt.rotamerSamplingSize = OP.getString("rotamerSamplingSize"); opt.seed = OP.getInt("seed"); opt.runDEE = OP.getBool("runDEE"); opt.runEnum = OP.getBool("runEnum"); opt.runSCMF = OP.getBool("runSCMF"); opt.runMCO = OP.getBool("runMCO"); opt.setState = OP.getBool("setState"); opt.rotamerStates = OP.getUnsignedIntVector("rotamerStates"); opt.rerunConf = "########################################################\n"; opt.rerunConf += "# This configuration file was automatically generated,\n"; opt.rerunConf += "# it will rerun this job with the same options. Run as:\n"; opt.rerunConf += "#\n"; opt.rerunConf += "# Run as:\n"; opt.rerunConf += "#\n"; opt.rerunConf += "# % " + programName + " --configfile " + opt.rerunConfFile + "\n"; opt.rerunConf += "#\n"; opt.rerunConf += "# Job started on " + (string)ctime(&start_time); opt.rerunConf += "# on host " + opt.host + ", path " + opt.pwd + "\n"; if (opt.seed == 0) { opt.rerunConf += "# seed " + MslTools::intToString(opt.seed) + " (time based)\n"; } else { opt.rerunConf += "# seed " + MslTools::intToString(opt.seed) + "\n"; } opt.rerunConf += "########################################################\n"; opt.rerunConf += "\n"; opt.rerunConf += OP.getConfFile(); // return the Options structure return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ Options opt; OptionParser OP; OP.readArgv(theArgc, theArgv); OP.setRequired(opt.required); OP.setAllowed(opt.optional); if (OP.countOptions() == 0){ cout << "Usage:" << endl; cout << endl; cout << "generateCoiledBundles --symmetry SYM --superHelicalRadius LOW HIGH STEP --alphaHelicalPhaseAngle LOW HIGH STEP --superHelicalPitchAngle LOW HIGH STEP --numberOfResidues NUM [ --d2zTranslation LOW HIGH STEP --superHelicalPhaseAngle LOW HIGH STEP --name OUTFILE]\n"; cout << "Recommended parameters:" << endl; cout << "--symmetry: C2, C3, D2, D3, etc." << endl; cout << "--superHelicalRadius: radius from center in Angstroms" << endl; cout << "--alphaHelicalPhaseAngle: phase angle of the helices (0-360 degrees)" << endl; cout << "--superHelicalPitchAngle: often 5-20 degrees, but depends on the coil (average around 12)" << endl; cout << "--d2zTranslation: z offset between D_N symmetric coils, usually small" << endl; cout << "--superHelicalPhaseAngle: angle in degrees. Value of 90/N for D_N typically works well, but larger and smaller values are possible" << endl; exit(0); } opt.symmetry = OP.getString("symmetry"); if (OP.fail()){ cerr << "ERROR 1111 symmetry not specified.\n"; exit(1111); } opt.superHelicalRadius = OP.getDoubleVector("superHelicalRadius"); if (OP.fail()){ cerr << "ERROR 1111 superHelicalRadius not specified.\n"; exit(1111); } opt.alphaHelicalPhaseAngle = OP.getDoubleVector("alphaHelicalPhaseAngle"); if (OP.fail()){ cerr << "ERROR 1111 alphaHelicalPhaseAngle not specified.\n"; exit(1111); } opt.superHelicalPitchAngle = OP.getDoubleVector("superHelicalPitchAngle"); if (OP.fail()){ cerr << "ERROR 1111 superHelicalPitchAngle not specified.\n"; exit(1111); } opt.numberOfResidues = OP.getInt("numberOfResidues"); if (OP.fail()){ cerr << "ERROR 1111 numberOfResidues not specified.\n"; exit(1111); } opt.d2zTranslation = OP.getDoubleVector("d2zTranslation"); opt.superHelicalPhaseAngle = OP.getDoubleVector("superHelicalPhaseAngle"); if (opt.d2zTranslation.size() == 0) { vector<double> tmp; tmp.push_back(0.0); tmp.push_back(1.0); tmp.push_back(100.0); opt.d2zTranslation = tmp; cerr << "Warning, d2zTranslation not defined (required for D2, D3)" << endl; } if (opt.superHelicalPhaseAngle.size() == 0) { int _N = atoi(opt.symmetry.substr(1,(opt.symmetry.length()-1)).c_str()); double recommendedValue = 90./double(_N); vector<double> tmp; tmp.push_back(recommendedValue); tmp.push_back((recommendedValue + 1.)); tmp.push_back(100.0); opt.superHelicalPhaseAngle = tmp; cerr << "Warning, superHelicalPhaseAngle not defined (required for D2, D3)" << endl; } opt.name = OP.getString("name"); if (OP.fail()){ opt.name = "CoiledBundle"; } return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ Options opt; OptionParser OP; OP.setRequired(opt.required); OP.setAllowed(opt.optional); OP.setDefaultArguments(opt.defaultArgs); // a pdb file value can be given as a default argument without the --pdbfile option OP.autoExtendOptions(); // if you give option "solvat" it will be autocompleted to "solvationfile" OP.readArgv(theArgc, theArgv); if (OP.countOptions() == 0){ cout << "Usage:" << endl; cout << endl; cout << "querySeqCons--fasta FASTA_FILE --seq 'NAME,STARTPOS,ENDPOS' \n"; exit(0); } opt.configfile = OP.getString("configfile"); if (opt.configfile != "") { OP.readFile(opt.configfile); if (OP.fail()) { cerr << "ERROR couldn't read : "<<opt.configfile<<endl; exit(1); } } opt.fasta = OP.getString("fasta"); if (OP.fail()){ cerr << "ERROR 1111 fasta not specified.\n"; exit(1111); } opt.refAACounts = OP.getString("refAACounts"); if (OP.fail()){ opt.refAACounts = ""; } opt.logodds = OP.getBool("logodds"); if (OP.fail()){ opt.logodds = false; } opt.seq = OP.getString("seq"); if (OP.fail()){ opt.seq = ""; } if (opt.seq == ""){ opt.refSeqName = OP.getString("refSeqName"); if (OP.fail()){ cerr << "WARNING 1111 refSeqName not specified.\n"; opt.refSeqName = ""; } opt.pdb = OP.getString("pdb"); if (OP.fail()){ cerr << "ERROR 1111 pdb not specified.\n"; exit(1111); } opt.sel = OP.getString("sel"); if (OP.fail()){ cerr << "ERROR 1111 sel not specified.\n"; exit(1111); } opt.refSeqOffset = OP.getInt("refSeqOffset"); if (OP.fail()){ cerr << "WARNING 1111 refSeqOffset not specified.\n"; opt.refSeqOffset = 0; } opt.applyToAllChains = OP.getBool("applyToAllChains"); if (OP.fail()){ opt.applyToAllChains = false; } opt.regexForFasta = OP.getString("regexForFasta"); if (OP.fail()){ opt.regexForFasta = ""; } opt.outPdb = OP.getString("outPdb"); if (OP.fail()){ opt.outPdb = MslTools::stringf("%s_seqcons.pdb",MslTools::getFileName(opt.pdb).c_str()); cerr << "WARNING --outPdb is set to : "<<opt.outPdb<<endl; } string type = OP.getString("type"); if (OP.fail()){ cerr << "WARNING type set to default: freq"<<endl; opt.valueType = Options::freq; } else { map<string,int>::iterator it = opt.valueMap.find(type); if (it == opt.valueMap.end()){ cerr << "ERROR 1111 type '"<<type<<"' not found."<<endl; exit(1111); } else { opt.valueType = opt.valueMap[type]; } } } return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ // Create the options Options opt; // Parse the options OptionParser OP; OP.readArgv(theArgc, theArgv); OP.setRequired(opt.required); OP.setAllowed(opt.optional); // OP.setShortOptionEquivalent(opt.equivalent); OP.setDefaultArguments(opt.defaultArgs); // the default argument is the --configfile option OP.autoExtendOptions(); // if you give option "solvat" it will be autocompleted to "solvationfile" if (OP.countOptions() == 0){ cout << "Usage:" << endl; cout << endl; cout << "mutate CONF\n"; exit(0); } opt.configfile = OP.getString("configfile"); if (opt.configfile != "") { OP.readFile(opt.configfile); if (OP.fail()) { string errorMessages = "Cannot read configuration file " + opt.configfile + "\n"; cerr << "ERROR 1111 "<<errorMessages<<endl; } } if (OP.getBool("help")){ cout << "# PDB "<<endl; cout << "pdb foo.pdb"<<endl<<endl; cout << "# Output pdb" <<endl; cout << "outpdb /tmp/out"<<endl<<endl; cout << "# Rotamer library"<<endl; cout << "rotlib /library/rotlib/balanced/rotlib-balanced-200.txt"<<endl<<endl; cout << "# Position"<<endl; cout << "position B,2"<<endl; cout << "# New residue"<<endl; cout << "newRes PHE"<<endl<<endl; cout << "# Number of rotamers"<<endl; cout << "numRot 10"<<endl<<endl; exit(1); } opt.pdb = OP.getString("pdb"); if (OP.fail()){ cerr << "ERROR 1111 no pdb file"<<endl; } opt.rotlib = OP.getString("rotlib"); if (OP.fail()){ cerr << "ERROR 1111 no rotlib file"<<endl; exit(1111); } opt.position = OP.getString("position"); if (OP.fail()){ cerr << "ERROR 1111 no position"<<endl; exit(1111); } opt.newRes = OP.getString("newRes"); if (OP.fail()){ cerr << "ERROR 1111 no new residue (newRes)"<<endl; exit(1111); } opt.outpdb = OP.getString("outpdb"); if (OP.fail()){ opt.outpdb = "/tmp/out"; cerr << "WARNING no outpdb file specifed will write to: "<<opt.outpdb<<endl; } opt.numRot = OP.getInt("numRot"); if (OP.fail()){ cerr << "numRot defaults to 10"<<endl; opt.numRot = 10; } opt.debug = OP.getBool("debug"); if (OP.fail()){ opt.debug = false; } return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ // Create the options Options opt; // Parse the options OptionParser OP; OP.readArgv(theArgc, theArgv); OP.setRequired(opt.required); OP.setDefaultArguments(opt.defaultArgs); // the default argument is the --configfile option if (OP.countOptions() == 0){ cout << "Usage: designCheck " << endl; cout << endl; cout << "\n"; cout << "pdb PDB\n"; cout << endl; exit(0); } opt.pdb = OP.getString("pdb"); if (OP.fail()){ cerr << "ERROR 1111 no pdb specified."<<endl; exit(1111); } opt.prosite = OP.getString("prosite"); if (OP.fail()){ opt.prosite = SYSENV.getEnv("MSL_PROSITE"); if (opt.prosite == "UNDEF"){ cerr << "ERROR 1111 prosite undefined"<<endl; exit(1111); } else { cerr << "WARNING prosite defaulted to: "<<opt.prosite<<endl; } } opt.ref = OP.getString("ref"); opt.topfile = OP.getString("topfile"); if (OP.fail()){ opt.topfile = SYSENV.getEnv("MSL_CHARMM_TOP"); if (opt.topfile == "UNDEF"){ cerr << "ERROR 1111 topfile not defined\n"; exit(1111); } else { cerr << "WARNING topfile defaulted to: "<<opt.topfile<<endl; } } opt.parfile = OP.getString("parfile"); if (OP.fail()){ opt.parfile = SYSENV.getEnv("MSL_CHARMM_PAR"); if (opt.parfile == "UNDEF"){ cerr << "ERROR 1111 parfile not defined\n"; exit(1111); }else { cerr << "WARNING parfile defaulted to: "<<opt.parfile<<endl; } } opt.hbondfile = OP.getString("hbondfile"); if (OP.fail()){ opt.hbondfile = SYSENV.getEnv("MSL_HBOND_PAR"); if (opt.hbondfile == "UNDEF"){ cerr << "WARNING 1111 hbondfile not defined - not building hydrogen bond interactions\n"; opt.hbondfile = ""; }else { cerr << "WARNING hbondfile defaulted to: "<<opt.hbondfile<<endl; } } opt.baselinefile = OP.getString("baselinefile"); if (OP.fail()){ opt.baselinefile = ""; cerr << "WARNING no baselinefile specified " <<endl; } opt.dielectric = OP.getDouble("dielectric"); if (OP.fail()){ opt.dielectric = 80; } opt.distanceDependentElectrostatics = OP.getBool("distanceDependentElectrostatics"); if (OP.fail()){ opt.distanceDependentElectrostatics = false; } opt.vdwScale = OP.getDouble("vdwScale"); if (OP.fail()){ opt.vdwScale = 1.0; } opt.cuton = OP.getDouble("cuton"); if (OP.fail()){ opt.cuton = 9.0; } opt.cutoff = OP.getDouble("cutoff"); if (OP.fail()){ opt.cutoff = 15.0; } return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ Options opt; OptionParser OP; OP.setRequired(opt.required); OP.setAllowed(opt.optional); OP.setDefaultArguments(opt.defaultArgs); // a pdb file value can be given as a default argument without the --pdbfile option OP.autoExtendOptions(); // if you give option "solvat" it will be autocompleted to "solvationfile" OP.readArgv(theArgc, theArgv); if (OP.countOptions() == 0){ cout << "Usage:" << endl; cout << endl; cout << "resurfaceSaltBridges --pdb PDB\n"; cout << "\nprogram options: "<<endl; for (uint i = 0; i < opt.required.size();i++){ cout <<"R --"<<opt.required[i]<<" "<<endl; } cout <<endl; for (uint i = 0; i < opt.optional.size();i++){ cout <<"O --"<<opt.optional[i]<<" "<<endl; } cout << endl; exit(0); } opt.pdb = OP.getString("pdb"); if (OP.fail()){ cerr << "ERROR 1111 pdb not specified.\n"; exit(1111); } opt.sb_prop_table = OP.getString("sb_prop_table"); if (OP.fail()){ opt.sb_prop_table = SYSENV.getEnv("MSL_SB_PROP_TABLE"); cout << "SB_PROP_TABLE: "<<opt.sb_prop_table<<endl; if (opt.sb_prop_table == "UNDEF"){ std::cerr << "ERROR 1111 no sb_prop_table specified."<<std::endl; exit(1111); } else { if (MslTools::fileExists(opt.sb_prop_table)){ cerr << "WARNING sb_prop_table defaulted to: "<<opt.sb_prop_table<<endl; } else { std::cerr << "ERROR 1111 no sb_prop_table specified and couldn't find default one: "<<opt.sb_prop_table<<std::endl; exit(1111); } } } opt.topfile = OP.getString("topfile"); if (OP.fail()){ opt.topfile = SYSENV.getEnv("MSL_CHARMM_TOP"); cerr << "WARNING: charmmtopfile not specified, using " << opt.topfile << "\n"; } if (!MslTools::fileExists(opt.topfile)){ cerr << "ERROR 1111 CHARMM TOPFILE DOESN'T EXIST: "<<opt.topfile<<endl; exit(1111); } opt.parfile = OP.getString("parfile"); if (OP.fail()){ opt.parfile = SYSENV.getEnv("MSL_CHARMM_PAR"); cerr <<"WARNING charmmparfile not specified, using " << opt.parfile << "\n"; } if (!MslTools::fileExists(opt.parfile)){ cerr << "ERROR 1111 CHARMM parFILE DOESN'T EXIST: "<<opt.parfile<<endl; exit(1111); } opt.rotlib = OP.getString("rotlib"); if (OP.fail()){ opt.rotlib = SYSENV.getEnv("MSL_ROTLIB"); cerr << "WARNING rotlib not specified, using " << opt.rotlib << "\n"; } if (!MslTools::fileExists(opt.rotlib)){ cerr << "ERROR 1111 rotamer library DOESN'T EXIST: "<<opt.rotlib<<endl; exit(1111); } opt.numStructuralModels = OP.getInt("numStructuralModels"); if (OP.fail()){ opt.numStructuralModels = 10; } opt.numSequenceModels = OP.getInt("numSequenceModels"); if (OP.fail()){ opt.numSequenceModels = 30; } opt.numMCcycles = OP.getInt("numMCcycles"); if (OP.fail()){ opt.numMCcycles = 100; } opt.startMCtemp = OP.getDouble("startMCtemp"); if (OP.fail()){ opt.startMCtemp = 100.0; } opt.endMCtemp = OP.getDouble("endMCtemp"); if (OP.fail()){ opt.endMCtemp = 1.0; } opt.scoreOnly = OP.getBool("scoreOnly"); opt.selectPositions = OP.getString("selectPositions"); if (OP.fail()){ opt.selectPositions = ""; } opt.percentSasa = OP.getDouble("percentSasa"); if (OP.fail()){ opt.percentSasa = 0.4; } MSLOUT.stream() << "Options:\n"<<OP<<endl; return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ Options opt; OptionParser OP; OP.readArgv(theArgc, theArgv); OP.setRequired(opt.required); OP.setAllowed(opt.optional); if (OP.countOptions() == 0){ cout << "Usage:" << endl; cout << endl; cout << "multiSearchDM --inputPDB PDB --pdbList LIST --searchCriteria SEARCH_STRING --windowSize NUM [ --numberOfIterations NUM --allowIntraChainCompare --likenessTolernace TOL --alignPdbs --debug ]\n"; cout << endl<<"\tsearchCriteria can be:\n"; cout << "\tstandard - sum of the diff. for every item between two MatrixWindows.\n"; cout << "\tdiagnol - sum of the diff. for the diagnol (top left-bottom right) between two MatrixWindows.\n"; cout << "\tdoubleDiagnol - sum of the diff. for both diagnols between two MatrixWindows.\n"; cout << "\tminDistance - sum of the diff. between the minimal distance for each row,col of the given MatrixWindows.\n"; cout << "\tminDistanceRow - sum of the diff. between the minimal distance for each row of the given MatrixWindows.\n"; exit(0); } opt.inputPDB = OP.getString("inputPDB"); if (OP.fail()){ cerr << "ERROR 1111 inputPDB not specified.\n"; exit(1111); } opt.pdbList = OP.getString("pdbList"); if (OP.fail()){ cerr << "ERROR 1111 pdbList not specified.\n"; exit(1111); } opt.searchCriteria = OP.getString("searchCriteria"); if (OP.fail()){ cerr <<"ERROR 1111 searchCriteria not specified."<<endl; exit(1111); } opt.windowSize = OP.getInt("windowSize"); if (OP.fail()){ cerr << "ERROR 1111 windowSize not specified."<<endl; exit(1111); } opt.numberOfIterations = OP.getInt("numberOfIterations"); if (OP.fail()){ opt.numberOfIterations = 1; } opt.intraChainCompare = OP.getBool("allowIntraChainCompare"); if (OP.fail()){ opt.intraChainCompare = false; } opt.likenessTolerance = OP.getDouble("likenessTolerance"); if (OP.fail()){ opt.likenessTolerance = MslTools::doubleMax; } opt.alignPdbs = OP.getBool("alignPdbs"); if (OP.fail()){ opt.alignPdbs = false; } opt.rmsdTol = OP.getDouble("rmsdTol"); if (OP.fail()) { opt.rmsdTol = 2.0; } opt.debug = OP.getBool("debug"); if (OP.fail()){ opt.debug = false; } return opt; }
Options setupOptions(int theArgc, char * theArgv[]){ Options opt; OptionParser OP; OP.setRequired(opt.required); OP.setAllowed(opt.optional); OP.setDefaultArguments(opt.defaultArgs); // a pdb file value can be given as a default argument without the --pdbfile option OP.autoExtendOptions(); // if you give option "solvat" it will be autocompleted to "solvationfile" OP.readArgv(theArgc, theArgv); if (OP.countOptions() == 0){ cout << "Usage:" << endl; cout << endl; cout << "addSequenceConservation --pdb PDB --fasta FASTA_FILE --refCounts REF_COUNTS_FILE\n"; exit(0); } opt.configfile = OP.getString("configfile"); if (opt.configfile != "") { OP.readFile(opt.configfile); if (OP.fail()) { cerr << "ERROR couldn't read : "<<opt.configfile<<endl; exit(1); } } opt.fasta = OP.getString("fasta"); if (OP.fail()){ cerr << "ERROR 1111 fasta not specified.\n"; exit(1111); } opt.refSeqName = OP.getString("refSeqName"); if (OP.fail()){ cerr << "WARNING 1111 refSeqName not specified.\n"; opt.refSeqName = ""; } opt.seq = OP.getString("seq"); if (OP.fail()){ opt.seq = ""; } if (opt.seq == ""){ opt.pdb = OP.getString("pdb"); if (OP.fail()){ cerr << "ERROR 1111 pdb not specified.\n"; exit(1111); } opt.refAACounts = OP.getString("refAACounts"); if (OP.fail()){ cerr << "ERROR 1111 refAACounts not specified.\n"; exit(1111); } opt.sel = OP.getString("sel"); if (OP.fail()){ cerr << "ERROR 1111 sel not specified.\n"; exit(1111); } opt.refSeqOffset = OP.getInt("refSeqOffset"); if (OP.fail()){ cerr << "WARNING 1111 refSeqOffset not specified.\n"; opt.refSeqOffset = 0; } opt.freq = OP.getBool("freq"); if (OP.fail()){ opt.freq = false; } opt.applyToAllChains = OP.getBool("applyToAllChains"); if (OP.fail()){ opt.applyToAllChains = false; } opt.regexForFasta = OP.getString("regexForFasta"); if (OP.fail()){ opt.regexForFasta = ""; } opt.outPdb = OP.getString("outPdb"); if (OP.fail()){ opt.outPdb = MslTools::stringf("%s_seqcons.pdb",MslTools::getFileName(opt.pdb).c_str()); cerr << "WARNING --outPdb is set to : "<<opt.outPdb<<endl; } } return opt; }
Options parseOptions(int _argc, char * _argv[], Options defaults) { /****************************************** * Pass the array of argument and the name of * a configuration file to the ArgumentParser * object. Then ask for the value of the argument * and collect error and warnings. * * This function returns a Options structure * defined at the head of this file ******************************************/ Options opt; /****************************************** * Set the allowed and required options: * * Example of configuartion file: * ******************************************/ vector<string> required; vector<string> allowed; opt.required.push_back("pdbFile"); opt.required.push_back("helicalAxisPdbFile"); opt.required.push_back("output"); opt.required.push_back("xShiftStart"); opt.required.push_back("xShiftEnd"); opt.required.push_back("xShiftSteps"); opt.required.push_back("zShiftAStart"); opt.required.push_back("zShiftAEnd"); opt.required.push_back("zShiftASteps"); opt.required.push_back("zShiftBStart"); opt.required.push_back("zShiftBEnd"); opt.required.push_back("zShiftBSteps"); opt.required.push_back("axialRotAStart"); opt.required.push_back("axialRotAEnd"); opt.required.push_back("axialRotASteps"); opt.required.push_back("axialRotBStart"); opt.required.push_back("axialRotBEnd"); opt.required.push_back("axialRotBSteps"); opt.required.push_back("crossingAngleStart"); opt.required.push_back("crossingAngleEnd"); opt.required.push_back("crossingAngleSteps"); //opt.required.push_back("rotCount"); opt.required.push_back("topFile"); opt.required.push_back("parFile"); opt.required.push_back("solvFile"); opt.required.push_back("hBondFile"); //opt.equivalent.push_back(vector<string>()); //opt.equivalent.back().push_back("v"); //opt.equivalent.back().push_back("version"); //opt.equivalent.push_back(vector<string>()); //opt.equivalent.back().push_back("h"); //opt.equivalent.back().push_back("help"); //opt.defaultArgs.push_back("configfile"); //OptionParser OP(_argc, _argv); OptionParser OP; OP.setShortOptionEquivalent(opt.equivalent); OP.readArgv(_argc, _argv); OP.setDefaultArguments(opt.defaultArgs); // a pdb file value can be given as a default argument without the --pdbfile option OP.setRequired(opt.required); OP.setAllowed(opt.allowed); OP.autoExtendOptions(); // if you give option "solvat" it will be autocompleted to "solvationfile" if (OP.countOptions() == 0) { usage(); exit(0); } opt.configfile = OP.getString("configfile"); if (opt.configfile != "") { OP.readFile(opt.configfile); if (OP.fail()) { opt.errorFlag = true; opt.errorMessages += "Cannot read configuration file " + opt.configfile + "\n"; exit(1); } } /***************************************** * VERSION AND HELP * * --version or -v arguments print the version number * --help prints the usage and help *****************************************/ opt.version = OP.getBool("version"); //if (OP.fail()) { // opt.version = OP.getBool("v"); //} if (opt.version) { version(); exit(0); } opt.help = OP.getBool("help"); // if (OP.fail()) { // opt.help = OP.getBool("h"); // } if (opt.help) { help(defaults); exit(0); } /***************************************** * CHECK THE GIVEN OPTIONS *****************************************/ if (!OP.checkOptions()) { opt.errorFlag = true; opt.OPerrors = OP.getErrors(); return opt; } opt.errorFlag = false; opt.warningFlag = false; /***************************************** * OUTPUT DIR AND FILES *****************************************/ /***************************************** * CHECK THE GIVEN OPTIONS *****************************************/ opt.errorFlag = false; opt.warningFlag = false; opt.pdbFile = OP.getString("pdbFile"); if (OP.fail()) { opt.errorMessages = "pdb file not specified"; opt.errorFlag = true; } opt.helicalAxisPdbFile = OP.getString("helicalAxisPdbFile"); if (OP.fail()) { opt.errorMessages = "helicalAxisPdbFile file not specified"; opt.errorFlag = true; } opt.output = OP.getString("output"); if (OP.fail()) { opt.errorMessages = "output not specified"; opt.errorFlag = true; } opt.xShiftStart = OP.getDouble("xShiftStart"); if (OP.fail()) { opt.errorMessages = "xShiftStart not specified"; opt.errorFlag = true; } opt.xShiftEnd = OP.getDouble("xShiftEnd"); if (OP.fail()) { opt.errorMessages = "xShiftEnd not specified"; opt.errorFlag = true; } opt.xShiftSteps = OP.getDouble("xShiftSteps"); if (OP.fail()) { opt.errorMessages = "xShiftSteps not specified"; opt.errorFlag = true; } opt.zShiftAStart = OP.getDouble("zShiftAStart"); if (OP.fail()) { opt.errorMessages = "zShiftAStart not specified"; opt.errorFlag = true; } opt.zShiftAEnd = OP.getDouble("zShiftAEnd"); if (OP.fail()) { opt.errorMessages = "zShiftAEnd not specified"; opt.errorFlag = true; } opt.zShiftASteps = OP.getDouble("zShiftASteps"); if (OP.fail()) { opt.errorMessages = "zShiftASteps not specified"; opt.errorFlag = true; } opt.zShiftBStart = OP.getDouble("zShiftBStart"); if (OP.fail()) { opt.errorMessages = "zShiftBStart not specified"; opt.errorFlag = true; } opt.zShiftBEnd = OP.getDouble("zShiftBEnd"); if (OP.fail()) { opt.errorMessages = "zShiftBEnd not specified"; opt.errorFlag = true; } opt.zShiftBSteps = OP.getDouble("zShiftBSteps"); if (OP.fail()) { opt.errorMessages = "zShiftBSteps not specified"; opt.errorFlag = true; } opt.axialRotAStart = OP.getDouble("axialRotAStart"); if (OP.fail()) { opt.errorMessages = "axialRotAStart not specified"; opt.errorFlag = true; } opt.axialRotAEnd = OP.getDouble("axialRotAEnd"); if (OP.fail()) { opt.errorMessages = "axialRotAEnd not specified"; opt.errorFlag = true; } opt.axialRotASteps = OP.getDouble("axialRotASteps"); if (OP.fail()) { opt.errorMessages = "axialRotASteps not specified"; opt.errorFlag = true; } opt.axialRotBStart = OP.getDouble("axialRotBStart"); if (OP.fail()) { opt.errorMessages = "axialRotBStart not specified"; opt.errorFlag = true; } opt.axialRotBEnd = OP.getDouble("axialRotBEnd"); if (OP.fail()) { opt.errorMessages = "axialRotBEnd not specified"; opt.errorFlag = true; } opt.axialRotBSteps = OP.getDouble("axialRotBSteps"); if (OP.fail()) { opt.errorMessages = "axialRotBSteps not specified"; opt.errorFlag = true; } opt.crossingAngleStart = OP.getDouble("crossingAngleStart"); if (OP.fail()) { opt.errorMessages = "crossingAngleStart not specified"; opt.errorFlag = true; } opt.crossingAngleEnd = OP.getDouble("crossingAngleEnd"); if (OP.fail()) { opt.errorMessages = "crossingAngleEnd not specified"; opt.errorFlag = true; } opt.crossingAngleSteps = OP.getDouble("crossingAngleSteps"); if (OP.fail()) { opt.errorMessages = "crossingAngleSteps not specified"; opt.errorFlag = true; } opt.topFile = OP.getString("topFile"); if (OP.fail()) { opt.errorMessages = "topFile not specified"; opt.errorFlag = true; } opt.parFile = OP.getString("parFile"); if (OP.fail()) { opt.errorMessages = "parFile not specified"; opt.errorFlag = true; } opt.solvFile = OP.getString("solvFile"); if (OP.fail()) { opt.errorMessages = "solvFile not specified"; opt.errorFlag = true; } opt.hBondFile = OP.getString("hBondFile"); if (OP.fail()) { opt.errorMessages = "hBondFile not specified"; opt.errorFlag = true; } // return the Options structure return opt; }
Options parseOptions(int _argc, char * _argv[], Options defaults) { /****************************************** * Pass the array of argument and the name of * a configuration file to the ArgumentParser * object. Then ask for the value of the argument * and collect error and warnings. * * This function returns a Options structure * defined at the head of this file ******************************************/ Options opt; /****************************************** * Set the allowed and required options: * * Example of configuartion file: * ******************************************/ vector<string> required; vector<string> allowed; opt.required.push_back("pdb"); opt.required.push_back("type"); opt.required.push_back("atomNames"); opt.required.push_back("value"); opt.allowed.push_back("outputPdb"); //opt.allowed.push_back("outputdir"); opt.allowed.push_back("configfile"); opt.allowed.push_back("version"); // --version opt.allowed.push_back("v"); // -v is equivalent to --version opt.allowed.push_back("help"); // --help opt.allowed.push_back("h"); // -h is equivalent to --help opt.equivalent.push_back(vector<string>()); opt.equivalent.back().push_back("v"); opt.equivalent.back().push_back("version"); opt.equivalent.push_back(vector<string>()); opt.equivalent.back().push_back("h"); opt.equivalent.back().push_back("help"); opt.defaultArgs.push_back("configfile"); //OptionParser OP(_argc, _argv); OptionParser OP; OP.setShortOptionEquivalent(opt.equivalent); OP.readArgv(_argc, _argv); OP.setDefaultArguments(opt.defaultArgs); // a pdb file value can be given as a default argument without the --pdbfile option OP.setRequired(opt.required); OP.setAllowed(opt.allowed); OP.autoExtendOptions(); // if you give option "solvat" it will be autocompleted to "solvationfile" if (OP.countOptions() == 0) { usage(); exit(0); } opt.configfile = OP.getString("configfile"); if (opt.configfile != "") { OP.readFile(opt.configfile); if (OP.fail()) { opt.errorFlag = true; opt.errorMessages += "Cannot read configuration file " + opt.configfile + "\n"; exit(1); } } /***************************************** * VERSION AND HELP * * --version or -v arguments print the version number * --help prints the usage and help *****************************************/ opt.version = OP.getBool("version"); //if (OP.fail()) { // opt.version = OP.getBool("v"); //} if (opt.version) { version(); exit(0); } opt.help = OP.getBool("help"); // if (OP.fail()) { // opt.help = OP.getBool("h"); // } if (opt.help) { help(defaults); exit(0); } /***************************************** * CHECK THE GIVEN OPTIONS *****************************************/ if (!OP.checkOptions()) { opt.errorFlag = true; opt.OPerrors = OP.getErrors(); return opt; } opt.errorFlag = false; opt.warningFlag = false; /***************************************** * CHECK THE GIVEN OPTIONS *****************************************/ //opt.commandName = OP.getCommandName(); //if (!OP.checkOptions()) { // opt.errorFlag = true; // opt.disallowed = OP.getDisallowedOptions(); // opt.missing = OP.getMissingOptions(); // opt.ambiguous = OP.getAmbiguousOptions(); // return opt; //} opt.errorFlag = false; opt.warningFlag = false; opt.pdb = OP.getString("pdb"); if (OP.fail()) { opt.errorMessages = "Option name of first pdb file \"pdb\" not specified"; opt.errorFlag = true; } opt.outputPdb = OP.getString("outputPdb"); if (OP.fail()) { opt.warningMessages = "Option name of output edited pdb file \"outputPdb\" not specified"; opt.warningFlag = true; string base = MslTools::pathTail(opt.pdb); base = MslTools::pathRoot(base); opt.outputPdb = base + (string)"-edited.pdb"; } int index = 0; while (true) { DoF tmp; tmp.type = OP.getString("type", index); if (OP.fail()) { break; } tmp.atomNames = OP.getStringVector("atomNames", index); if (OP.fail()) { break; } tmp.value = OP.getDouble("value", index); if (OP.fail()) { break; } opt.edits.push_back(tmp); index++; } // return the Options structure return opt; }