Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.centos-stream9
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/centos/centos:stream9 AS base

# Install dependencies
RUN yum install -y popt-devel gcc-c++ make diffutils
RUN yum install -y gcc-c++ make diffutils
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.debian-10
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:10 AS base

# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends make g++ libpopt-dev libpopt0
RUN apt-get update && apt-get install -y --no-install-recommends make g++
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.debian-11
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:11 AS base

# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends make g++ libpopt-dev libpopt0
RUN apt-get update && apt-get install -y --no-install-recommends make g++
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.debian-12
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:12 AS base

# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends make g++ libpopt-dev libpopt0
RUN apt-get update && apt-get install -y --no-install-recommends make g++
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.ubuntu-20.04
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04 AS base

# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends make g++ libpopt-dev libpopt0
RUN apt-get update && apt-get install -y --no-install-recommends make g++
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.ubuntu-22.04
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:24.04 AS base

# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends make g++ libpopt-dev libpopt0
RUN apt-get update && apt-get install -y --no-install-recommends make g++
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.ubuntu-22.04-clang
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:22.04 AS base

# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends make clang libpopt-dev libpopt0
RUN apt-get update && apt-get install -y --no-install-recommends make clang
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.ubuntu-24.04
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:22.04 AS base

# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends make g++ libpopt-dev libpopt0
RUN apt-get update && apt-get install -y --no-install-recommends make g++
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ endif
DEFINES += -DRBT_VERSION=\"$(RBT_VERSION)\"
CXX_FLAGS := $(CXX_BASE_FLAGS) $(CXX_CONFIG_FLAGS) $(CXX_WARNING_FLAGS) $(CXX_EXTRA_FLAGS) $(DEFINES)
LINK_FLAGS := -shared
LIB_DEPENDENCIES = -lm -lpopt
LIB_DEPENDENCIES += -lm

# Modify library dependencies for macOS
ifeq ($(shell uname),Darwin)
LIB_DEPENDENCIES = -L$(BREW_PREFIX)/lib -lpopt -lm
LIB_DEPENDENCIES = -L$(BREW_PREFIX)/lib -lm
endif

LIBS += $(LIB_DEPENDENCIES) -lRbt
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ make sure the following requirements are installed and available:

- make
- a c++ compiler (g++ by default)
- popt and development headers (libpopt0 and libpopt-dev in ubuntu)
- git (optional if you download the code directly)

if you're running ubuntu, you can get all of them by running

```
sudo apt update && sudo apt install -y make git libpopt0 libpopt-dev g++
sudo apt update && sudo apt install -y make git g++
```

if you're running `macOS`, make sure to use gcc instead of clang. You can install gcc and popt using homebrew
Expand Down
7 changes: 7 additions & 0 deletions include/RbtArgParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _RBTARGPARSER_H_

#include <cxxopts.hpp>
#include <optional>
#include <string>
#include <vector>

Expand Down Expand Up @@ -61,6 +62,12 @@ class RbtOptionValue {
return *this;
}

template <typename T>
RbtOptionValue &operator>>(std::optional<T> &v) {
v = value.as<T>();
return *this;
}

inline bool is_present() { return value.count() > 0; }
};

Expand Down
16 changes: 16 additions & 0 deletions include/rbdock/rbdock_argparser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef _RBT_RBDOCK_ARGPARSER_H_
#define _RBT_RBDOCK_ARGPARSER_H_

#include "rbdock/rbdock_config.h"

#include "RbtArgParser.h"

namespace RBDock {

RbtArgParser::RbtArgParser get_options_parser();

RBDock::RBDockConfig parse_args(int argc, const char *argv[]);

} // namespace RBDock

#endif // _RBT_RBDOCK_ARGPARSER_H_
114 changes: 114 additions & 0 deletions include/rbdock/rbdock_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#ifndef _RBDOCK_CONFIG_H_
#define _RBDOCK_CONFIG_H_

#include <iostream>
#include <optional>
#include <sstream>
#include <string>

#include "RbtValidationError.h"

namespace RBDock {

struct RBDockConfig {
// mandatory parameters
std::string strLigandMdlFile;
std::string strReceptorPrmFile;
std::string strParamFile;

// optional parameters
std::optional<std::string> strOutputPrefix;
std::optional<std::string> strFilterFile;
std::optional<int> nDockingRuns;
std::optional<double> dTargetScore;
std::optional<int> nSeed;
std::optional<int> iTrace;

// flags
bool bContinue = false;
bool bPosIonise = false;
bool bNegIonise = false;
bool bAllH = false;

friend std::ostream &operator<<(std::ostream &os, const RBDockConfig &config) {
os << "Command line args:" << std::endl;
os << " -i " << config.strLigandMdlFile << std::endl;
os << " -r " << config.strReceptorPrmFile << std::endl;
os << " -p " << config.strParamFile << std::endl;
if (config.strOutputPrefix.has_value()) {
os << " -o " << config.strOutputPrefix.value() << std::endl;
} else {
os << "WARNING: output file name is missing." << std::endl;
}
auto def_aux = config.nDockingRuns.has_value() ? " (default) " : "";
os << " -n " << config.nDockingRuns.value_or(1) << def_aux << std::endl;
if (config.nSeed.has_value()) os << " -s " << config.nSeed.value() << std::endl;
if (config.iTrace.has_value()) os << " -T " << config.iTrace.value() << std::endl;
if (config.bPosIonise) os << " --ap " << std::endl;
if (config.bNegIonise) os << " --an " << std::endl;
if (!config.bAllH) os << " --allH " << std::endl;
if (config.dTargetScore.has_value()) os << " -t " << config.dTargetScore.value() << std::endl;
if (config.bContinue) os << " --cont " << std::endl;
if (config.bPosIonise)
os << "Automatically protonating positive ionisable groups (amines, imidazoles, guanidines)" << std::endl;
if (config.bNegIonise)
os << "Automatically deprotonating negative ionisable groups (carboxylic acids, phosphates, sulphates, "
"sulphonates)"
<< std::endl;
if (!config.bAllH)
os << "Reading polar hydrogens only from ligand SD file" << std::endl;
else
os << "Reading all hydrogens from ligand SD file" << std::endl;

if (config.dTargetScore.has_value()) {
os << std::endl << "Lower target intermolecular score = " << config.dTargetScore.value() << std::endl;
}
if (config.strFilterFile.has_value()) os << " -f " << config.strFilterFile.value() << std::endl;

return os;
}

void validate() {
if (strLigandMdlFile.empty()) throw Rbt::ValidationError("input ligand SD file is mandatory");
if (strReceptorPrmFile.empty()) throw Rbt::ValidationError("receptor parameter file is mandatory");
if (nDockingRuns.has_value() && nDockingRuns < 1)
throw Rbt::ValidationError("number of runs must be greater than 0");
}

bool operator==(const RBDockConfig &rhs) const {
return strLigandMdlFile == rhs.strLigandMdlFile && strOutputPrefix == rhs.strOutputPrefix
&& strReceptorPrmFile == rhs.strReceptorPrmFile && strParamFile == rhs.strParamFile
&& strFilterFile == rhs.strFilterFile && nDockingRuns == rhs.nDockingRuns && bContinue == rhs.bContinue
&& dTargetScore == rhs.dTargetScore && bPosIonise == rhs.bPosIonise && bNegIonise == rhs.bNegIonise
&& bAllH == rhs.bAllH && nSeed == rhs.nSeed && iTrace == rhs.iTrace;
}

std::string get_filter_string() const {
std::ostringstream strAuxFilter;
if (strFilterFile.has_value()) return "";
if (dTargetScore.has_value()) { // -t<TS>
if (!nDockingRuns.has_value()) { // -t<TS> only
strAuxFilter << "0 1 - SCORE.INTER " << dTargetScore.value() << std::endl;
} else // -t<TS> -n<N> need to check if -cont present
// for all other cases it doesn't matter
if (bContinue) { // -t<TS> -n<N> -cont
strAuxFilter << "1 if - SCORE.NRUNS " << (nDockingRuns.value() - 1)
<< " 0.0 -1.0,\n1 - SCORE.INTER " << dTargetScore.value() << std::endl;
} else { // -t<TS> -n<N>
strAuxFilter << "1 if - " << dTargetScore.value() << " SCORE.INTER 0.0 "
<< "if - SCORE.NRUNS " << (nDockingRuns.value() - 1) << " 0.0 -1.0,\n1 - SCORE.INTER "
<< dTargetScore.value() << std::endl;
}
} // no target score, no filter
else if (nDockingRuns.has_value()) { // -n<N>
strAuxFilter << "1 if - SCORE.NRUNS " << (nDockingRuns.value() - 1) << " 0.0 -1.0,\n0";
} else { // no -t no -n
strAuxFilter << "0 0\n";
}
return strAuxFilter.str();
}
};

} // namespace RBDock

#endif // _RBDOCK_CONFIG_H_
12 changes: 12 additions & 0 deletions include/rbdock/rbdock_main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef _RBT_RBDOCK_MAIN_H_
#define _RBT_RBDOCK_MAIN_H_

#include <string>

#include "rbdock/rbdock_config.h"

namespace RBDock {
void RBDock(const RBDockConfig &config, const std::string &strExeName);
} // namespace RBDock

#endif // _RBT_RBDOCK_MAIN_H_
Loading