本文整理汇总了C++中OptionParser::readFile方法的典型用法代码示例。如果您正苦于以下问题:C++ OptionParser::readFile方法的具体用法?C++ OptionParser::readFile怎么用?C++ OptionParser::readFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptionParser
的用法示例。
在下文中一共展示了OptionParser::readFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupOptions
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;
}
示例2: parseOptions
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);
}
//.........这里部分代码省略.........
示例3: setupOptions
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);
//.........这里部分代码省略.........
示例4: setupOptions
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;
}
示例5: setupOptions
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;
//.........这里部分代码省略.........
示例6: parseOptions
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;
//.........这里部分代码省略.........
示例7: parseOptions
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");
//}
//.........这里部分代码省略.........
示例8: setupOptions
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;
}