Commit c4a2d2f3 authored by Vedran Miletić's avatar Vedran Miletić

Use getopt() in place of popt and remove popt dependency

parent 93e70b03
......@@ -29,8 +29,6 @@ Make sure you have the following packages installed:
- gcc GNU C compiler (or your preferred C compiler)
- g++ GNU C++ compiler (or your preferred C++ compiler)
- make
- popt Command-line argument processing (run-time)
- popt-devel Command-line argument processing (compile-time)
- cppunit C++ unit testing framework (port of JUnit)
- cppunit-devel C++ unit testing framework (port of JUnit)
......
......@@ -29,8 +29,6 @@ Make sure you have the following packages installed:
- gcc GNU C compiler (or your preferred C compiler)
- g++ GNU C++ compiler (or your preferred C++ compiler)
- make
- popt Command-line argument processing (run-time)
- popt-devel Command-line argument processing (compile-time)
- cppunit C++ unit testing framework (port of JUnit)
- cppunit-devel C++ unit testing framework (port of JUnit)
......
......@@ -42,7 +42,6 @@ First of all, you will need to install several packages before compiling and run
* gcc and g++ compilers version > 3.3
* make
* cppunit and cppunit-devel
* popt and popt-devel
.. note::
......@@ -124,10 +123,6 @@ For full production use, you would typically compile rDock on a separate build m
+-------------+------------------------------------+------------+---------+
|g++ |GNU C++ compiler |Compile-time|>=3.3.4 |
+-------------+------------------------------------+------------+---------+
|popt |C++ command-line argument processing|Run-time |>=1.7-190|
+-------------+------------------------------------+------------+---------+
|popt-devel |Development files for popt library |Run-time |>=1.7-190|
+-------------+------------------------------------+------------+---------+
|cppunit |C++ unit test framework |Compile-time|>=1.10.2 |
+-------------+------------------------------------+------------+---------+
|cppunit-devel|Development files for cppunit |Compile-time|>=1.10.2 |
......@@ -200,12 +195,6 @@ where ``[CODELINE]``, and ``[TEST]`` will vary depending on the release and test
./data/pmf/smoothed
./data/scripts
./lib
./popt
./popt/intl
./popt/po
./popt/.deps
./popt/test3-data
./popt/autom4te.cache
./import
./import/tnt
./import/tnt/include
......
......@@ -80,14 +80,13 @@ libRbt = shared_library(
include_directories : incRbtAll
)
popt = dependency('popt')
executable(
'rbdock', 'src/exe/rbdock.cxx', dependencies : popt,
link_with : libRbt, include_directories : incRbt
'rbdock', 'src/exe/rbdock.cxx', link_with : libRbt,
include_directories : incRbt
)
executable(
'rbcavity', 'src/exe/rbcavity.cxx', dependencies : popt,
link_with : libRbt, include_directories : incRbt
'rbcavity', 'src/exe/rbcavity.cxx', link_with : libRbt,
include_directories : incRbt
)
executable(
'rbrms', 'src/exe/rbrms.cxx', link_with : libRbt, include_directories : incRbt
......
......@@ -16,7 +16,7 @@
using std::setw;
#include <algorithm>
#include <popt.h> // for popt command-line parsing
#include <unistd.h>
#include "RbtBiMolWorkSpace.h"
#include "RbtParameterFileSource.h"
......@@ -31,16 +31,16 @@ const RbtString EXEVERSION = " ($Id: //depot/dev/client3/rdock/2013.1/src/exe/rb
void PrintUsage(void)
{
cout << "rbcavity - calculate docking cavities" << endl;
cout << "Usage:\trbcavity -r<ReceptorPrmFile> [-was -ras -d -l<dist> -b<border>" << endl;
cout << "Usage:\trbcavity -r <ReceptorPrmFile> [-W] [-R] [-d] [-v] [-l <dist>] [-s] [-b <border> [-m]" << endl;
cout << "Options:"<<endl;
cout << "\t\t-r<PrmFile> - receptor param file (contains active site params)" << endl;
cout << "\t\t-was [-W] - write docking cavities (plus distance grid) to .as file" << endl;
cout << "\t\t-ras [-R] - read docking cavities (plus distance grid) from .as file" << endl;
cout << "\t\t-r <PrmFile> - receptor param file (contains active site params)" << endl;
cout << "\t\t-W - write docking cavities (plus distance grid) to .as file" << endl;
cout << "\t\t-R - read docking cavities (plus distance grid) from .as file" << endl;
cout << "\t\t-d - dump InsightII grids for each cavity for visualisation" << endl;
cout << "\t\t-v - dump target PSF/CRD files for rDock Viewer" << endl;
cout << "\t\t-l<dist> - list receptor atoms with <dist> A of any cavity" << endl;
cout << "\t\t-l <dist> - list receptor atoms with <dist> A of any cavity" << endl;
cout << "\t\t-s - print SITE descriptors (counts of exposed atoms)" << endl;
cout << "\t\t-b<border> - set the border around the cavities for the distance grid (default=8A)" << endl;
cout << "\t\t-b <border> - set the border around the cavities for the distance grid (default=8A)" << endl;
cout << "\t\t-m - write active site into a MOE grid" << endl;
}
......@@ -48,33 +48,25 @@ void PrintUsage(void)
// MAIN PROGRAM STARTS HERE
/////////////////////////////////////////////////////////////////////
int main(int argc,const char* argv[])
int main(int argc, char* argv[])
{
char c; // for argument parsing
poptContext optCon; // ditto
char *prmFile=NULL; // will be strReceptorPrmFile
char *listDist=NULL; // will be 'dist'
char *borderDist=NULL; // will be 'border'
struct poptOption optionsTable[] = { // command line options
{"receptor", 'r',POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,&prmFile , 0, "receptor file"},
{"was", 'W',POPT_ARG_NONE |POPT_ARGFLAG_ONEDASH,0, 'W',"write active site"},
{"ras", 'R',POPT_ARG_NONE |POPT_ARGFLAG_ONEDASH,0, 'R',"read active site"},
{"dump-insight",'d',POPT_ARG_NONE |POPT_ARGFLAG_ONEDASH,0, 'd',"dump InsightII/PyMol grids"},
//{"dump-moe", 'm',POPT_ARG_NONE |POPT_ARGFLAG_ONEDASH,0, 'm',"dump MOE grids"}, //not working right now so commenting it
{"viewer", 'v',POPT_ARG_NONE |POPT_ARGFLAG_ONEDASH,0, 'v',"dump Viewer PSF/CRD files"},
{"list", 'l',POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,&listDist, 'l',"list receptor atoms within <dist>"},
{"site", 's',POPT_ARG_NONE |POPT_ARGFLAG_ONEDASH,0, 's',"print site descriptors"},
{"border", 'b',POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,&borderDist,'b',"set the border around the cavities"},
POPT_AUTOHELP
{NULL,0,0,NULL,0}
};
//Display brief help message if no args
if (argc < 2) {
PrintUsage();
return 1;
}
//Handle obsolete arguments, if any
for (int i = 0; i < argc; i++)
{
RbtString opt = argv[i];
if(opt == "-was" || opt == "-ras")
{
cout << "Options -was and -ras are no longer supported; use -W and -R (respectively) instead." << endl;
return 2;
}
}
//Strip off the path to the executable, leaving just the file name
RbtString strExeName(argv[0]);
RbtString::size_type i = strExeName.rfind("/");
......@@ -93,19 +85,18 @@ int main(int argc,const char* argv[])
RbtBool bList(false); //If true, list atoms within 'distance' of cavity
RbtBool bSite(false); //If true, print out "SITE" descriptors (counts of exposed atoms)
RbtBool bMOEgrid(false); //If true, create a MOE grid file for AS visualisation
RbtBool bBorderArg(false); //If true, border was specified in the command line
RbtDouble border(8.0); //Border to allow around cavities for distance grid
RbtDouble dist(5.0);
optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
poptSetOtherOptionHelp(optCon, "-r<receptor.prm> [options]");
if(argc < 2) {
poptPrintUsage(optCon, stderr, 0);
exit(1);
}
while ( (c=poptGetNextOpt(optCon))>= 0) {
char c;
while ((c=getopt(argc, argv, "r:b:RWdvl:ms")) != -1) {
switch(c) {
case 'r':
strReceptorPrmFile = optarg;
case 'b':
border = atof(borderDist);
bBorderArg = true;
border = atof(optarg);
break;
case 'R': // also for -ras
bReadAS = true;
......@@ -121,7 +112,7 @@ int main(int argc,const char* argv[])
break;
case 'l':
bList = true;
dist = atof(listDist);
dist = atof(optarg);
break;
case 'm':
bMOEgrid = true;
......@@ -129,34 +120,34 @@ int main(int argc,const char* argv[])
case 's':
bSite = true;
break;
case '?':
break;
default:
cout << "WARNING: unknown argument: "<< c <<endl;;
break;
}
}
cout << endl;
poptFreeContext(optCon);
// check for parameter file name
if(prmFile) {
/*if(prmFile) {
strReceptorPrmFile = prmFile;
}
else {
}*/
if(strReceptorPrmFile.empty()) {
cout << "Missing receptor parameter file name"<<endl;
poptPrintUsage(optCon, stderr, 0);
exit(1);
}
// writing command line arguments
cout << "Command line arguments:" << endl;
cout << "-r "<< strReceptorPrmFile << endl;
if(listDist)
if(bList)
cout << "-l "<< dist << endl;
if(borderDist)
if(bBorderArg)
cout << "-b "<< border << endl;
if(bWriteAS)
cout << "-was"<< endl;
cout << "-W"<< endl;
if(bReadAS)
cout << "-ras"<< endl;
cout << "-R"<< endl;
if(bMOEgrid)
cout << "-m"<< endl;
if(bDump)
......
......@@ -14,7 +14,7 @@
#include <iomanip>
using std::setw;
#include <popt.h> // for command-line parsing
#include <unistd.h>
#include <errno.h>
#include "RbtBiMolWorkSpace.h"
......@@ -42,18 +42,18 @@ const RbtString _ROOT_TRANSFORM = "DOCK";
void PrintUsage(void)
{
cout << endl << "Usage:" << endl;
cout << "rbdock -i <sdFile> -o <outputRoot> -r <recepPrmFile> -p <protoPrmFile> [-n <nRuns>] [-ap] [-an] [-allH]" << endl;
cout << "rbdock -i <sdFile> -o <outputRoot> -r <recepPrmFile> -p <protoPrmFile> [-n <nRuns>] [-P] [-D] [-H]" << endl;
cout << " [-t <targetScore|targetFilterFile>] [-c] [-T <traceLevel>] [-s <rndSeed>]" << endl;
cout << endl << "Options:\t-i <sdFile> - input ligand SD file" << endl;
cout << "\t\t-o <outputRoot> - root name for output file(s)" << endl;
cout << "\t\t-r <recepPrmFile> - receptor parameter file " << endl;
cout << "\t\t-p <protoPrmFile> - docking protocol parameter file" << endl;
cout << "\t\t-n <nRuns> - number of runs/ligand (default=1)" << endl;
cout << "\t\t-ap - protonate all neutral amines, guanidines, imidazoles (default=disabled)" << endl;
cout << "\t\t-an - deprotonate all carboxylic, sulphur and phosphorous acid groups (default=disabled)" << endl;
cout << "\t\t-allH - read all hydrogens present (default=polar hydrogens only)" << endl;
cout << "\t\t-P - protonate all neutral amines, guanidines, imidazoles (default=disabled)" << endl;
cout << "\t\t-D - deprotonate all carboxylic, sulphur and phosphorous acid groups (default=disabled)" << endl;
cout << "\t\t-H - read all hydrogens present (default=polar hydrogens only)" << endl;
cout << "\t\t-t - score threshold OR filter file name" << endl;
cout << "\t\t-c - continue if score threshold is met (use with -t <targetScore>, default=terminate ligand)" << endl;
cout << "\t\t-C - continue if score threshold is met (use with -t <targetScore>, default=terminate ligand)" << endl;
cout << "\t\t-T <traceLevel> - controls output level for debugging (0 = minimal, >0 = more verbose)" << endl;
cout << "\t\t-s <rndSeed> - random number seed (default=from sys clock)" << endl;
}
......@@ -62,8 +62,25 @@ void PrintUsage(void)
// MAIN PROGRAM STARTS HERE
/////////////////////////////////////////////////////////////////////
int main(int argc, const char* argv[])
int main(int argc, char* argv[])
{
//Brief help message
if (argc < 2) {
PrintUsage();
return 1;
}
//Handle obsolete arguments, if any
for (int i = 0; i < argc; i++)
{
RbtString opt = argv[i];
if(opt == "-ap" || opt == "-an" || opt == "-allH" || opt == "-cont")
{
cout << "Options -ap, -an, -allH, and -cont are no longer supported; use -P, -D, -H, and -C (respectively) instead." << endl;
return 2;
}
}
cout.setf(ios_base::left,ios_base::adjustfield);
//Strip off the path to the executable, leaving just the file name
......@@ -99,42 +116,25 @@ int main(int argc, const char* argv[])
RbtBool bTrace(false);
RbtInt iTrace(0);//Trace level, for debugging
// variables for popt command-line parsing
char c; // for argument parsing
poptContext optCon; // ditto
char *inputFile=NULL; // will be 'strLigandMdlFile'
char *outputFile=NULL; // will be 'strRunName'
char *receptorFile=NULL; // will be 'strReceptorPrmFile'
char *protocolFile=NULL; // will be 'strParamFile'
char *strTargetScr=NULL; // will be 'dTargetScore'
struct poptOption optionsTable[] = { // command line options
{"input", 'i',POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,&inputFile, 'i',"input file"},
{"output", 'o',POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,&outputFile, 'o',"output file"},
{"receptor", 'r',POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,&receptorFile,'r',"receptor file"},
{"protocol", 'p',POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,&protocolFile,'p',"protocol file"},
{"runs", 'n',POPT_ARG_INT |POPT_ARGFLAG_ONEDASH,&nDockingRuns,'n',"number of runs"},
{"trace", 'T',POPT_ARG_INT |POPT_ARGFLAG_ONEDASH,&iTrace,'T',"trace level for debugging"},
{"seed", 's',POPT_ARG_INT |POPT_ARGFLAG_ONEDASH,&nSeed, 's',"random seed"},
{"ap", 'P',POPT_ARG_NONE |POPT_ARGFLAG_ONEDASH,0, 'P',"protonate groups"},
{"an", 'D',POPT_ARG_NONE |POPT_ARGFLAG_ONEDASH,0, 'D',"DEprotonate groups"},
{"allH", 'H',POPT_ARG_NONE |POPT_ARGFLAG_ONEDASH,0, 'H',"read all Hs"},
{"target", 't',POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH,&strTargetScr,'t',"target score"},
{"cont", 'C',POPT_ARG_NONE |POPT_ARGFLAG_ONEDASH,0, 'C',"continue even if target met"},
POPT_AUTOHELP
{NULL,0,0,NULL,0}
};
optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
poptSetOtherOptionHelp(optCon, "-r<receptor.prm> -p<protocol.prm> -i<infile> -o<outfile> [options]");
//Brief help message
if (argc < 2) {
PrintUsage();
return 1;
}
RbtDouble val(0.0);
while ( (c=poptGetNextOpt(optCon))>= 0) {
char c;
while ((c=getopt(argc, argv, "i:o:r:p:n:PDHtCT:s:")) != -1) {
switch(c) {
case 'i':
strLigandMdlFile = optarg;
break;
case 'o':
strRunName = optarg;
break;
case 'r':
strReceptorPrmFile = optarg;
break;
case 'p':
strParamFile = optarg;
break;
case 'n':
nDockingRuns = atoi(optarg);
break;
case 'P': // protonate
bPosIonise = true;
break;
......@@ -152,7 +152,7 @@ int main(int argc, const char* argv[])
// threshold. Otherwise, I assume is the filter file name
char *error;
errno = 0;
val = strtod(strTargetScr, &error);
val = strtod(optarg, &error);
if (!errno && !*error) // Is it a number?
{
dTargetScore = val;
......@@ -161,39 +161,35 @@ int main(int argc, const char* argv[])
else // Assume is the filter file name
{
bFilter = true;
strFilterFile = strTargetScr;
strFilterFile = optarg;
}
break;
case 's':
bSeed = true;
nSeed = atoi(optarg);
break;
case 'T':
bTrace = true;
iTrace = atoi(optarg);
break;
default:
break;
}
}
cout << endl;
poptFreeContext(optCon);
// print out arguments
// input ligand file, receptor and parameter is compulsory
cout << endl << "Command line args:" << endl;
if(!inputFile || !receptorFile || !protocolFile) { // if any of them is missing
poptPrintUsage(optCon, stderr, 0);
if(strLigandMdlFile.empty() || strReceptorPrmFile.empty() || strParamFile.empty()) { // if any of them is missing
cout << "Missing required parameter(s)" << endl;
exit(1);
} else {
strLigandMdlFile = inputFile;
strReceptorPrmFile = receptorFile;
strParamFile = protocolFile;
}
cout << " -i " << strLigandMdlFile << endl;
cout << " -r " << strReceptorPrmFile << endl;
cout << " -p " << strParamFile << endl;
}
// output is not that important but good to have
if(outputFile) {
strRunName = outputFile;
if(!strRunName.empty()) {
bOutput = true;
cout << " -o " << strRunName << endl;
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment