Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Residence time #43

Open
wants to merge 55 commits into
base: release-2024
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
8ec98e6
add python code example
BerndDoser Feb 7, 2024
0e40da6
Merge branch 'release-2024' into stop-criterion
BerndDoser Feb 8, 2024
86adec1
Merge branch 'release-2024' into stop-criterion
BerndDoser Feb 8, 2024
3797eb1
Add binding residues to RAMD group
BerndDoser Feb 9, 2024
3ae6555
Add 4water RAMD tests for binding residues
BerndDoser Feb 9, 2024
2b672da
read binding residues from mdp
BerndDoser Feb 19, 2024
f1c0031
Change RAMD binding_residues from index to atom numbers
BerndDoser Feb 19, 2024
62d9664
Test topology resinfo
BerndDoser Feb 21, 2024
022ed97
Update RAMD constructor to include mtop parameter
BerndDoser Feb 22, 2024
c339aad
add new pull group for testing
BerndDoser Feb 27, 2024
53a47f8
calculate COM of extra groups
BerndDoser Feb 27, 2024
4f6e0e2
add extra groups only for RAMD
BerndDoser Feb 28, 2024
9bb5b0d
set pbcatom for extra groups
BerndDoser Feb 28, 2024
46fa2d6
check COM distance against standard ramd group
BerndDoser Feb 28, 2024
2d3754c
add residence_distance parameter and write residence time notice into…
BerndDoser Feb 28, 2024
d927062
Check if output file is defined for logging
BerndDoser Feb 28, 2024
83f21cf
change pull geometry from direction to distance for extra groups
BerndDoser Feb 28, 2024
3362a67
write distances of extra groups to ramd output file
BerndDoser Feb 28, 2024
91f86a9
separate function add_residence_time_groups
BerndDoser Feb 29, 2024
d184a04
read binding index groups
BerndDoser Feb 29, 2024
20cf0ce
serialization of binding index groups
BerndDoser Mar 1, 2024
dd3451a
build tpr file in unit test CalculateForces1WDHI
BerndDoser Mar 1, 2024
dd93ae3
Check if binding group is defined
BerndDoser Mar 1, 2024
29cb3ef
read residence distance and
BerndDoser Mar 1, 2024
af83d4b
Add new mdp option ramd-residence-distance
BerndDoser Mar 4, 2024
0475e9b
Move 4water test data into own directory
BerndDoser Mar 4, 2024
2837415
add ramd-use-residence-dist as new mdp option
BerndDoser Mar 4, 2024
96d1654
remove interaction group sulfur and
BerndDoser Mar 4, 2024
03339f1
add all residence interaction groups to pull groups
BerndDoser Mar 4, 2024
9cfd553
fix launch 4water grompp ramd
BerndDoser Mar 4, 2024
1aebaaf
define residence time interactions
BerndDoser Mar 5, 2024
2146a0b
Instead of defining a pull coord with zero force constant, the flag n…
BerndDoser Mar 5, 2024
377d39c
calculate COM only for non empty pull groups
BerndDoser Mar 5, 2024
f016e25
use default pbc atom for extra pull groups
BerndDoser Mar 5, 2024
730ed54
Merge branch 'release-2024' into stop-criterion
BerndDoser Mar 6, 2024
ce911b5
Loop over residence interactions to calculate the COM distances
BerndDoser Mar 11, 2024
966a989
only calculate residence_contacts if use_residence_dist = true
BerndDoser Mar 11, 2024
cc8797b
add extra groups only if they are available in the index file
BerndDoser Mar 11, 2024
92b81bc
fix empty residence contacts
BerndDoser Mar 13, 2024
1d875bb
Comment out external data volume for debugging purposes
BerndDoser Jul 8, 2024
e627d94
Replace explicit chemical binding groups
BerndDoser Jul 8, 2024
22741f5
remove chemical interaction pairs
BerndDoser Jul 9, 2024
84699d7
Revert "Update RAMD constructor to include mtop parameter"
BerndDoser Jul 9, 2024
c267312
use extra pull groups pairwise as residence contacts
BerndDoser Jul 9, 2024
aeafe22
add 4water as RAMD_residence_time module test
BerndDoser Jul 9, 2024
70e582e
fix extra pull groups for residence time
BerndDoser Jul 10, 2024
8f3f0b5
add all extra residence time pull groups to inputrecStrings->pullGrou…
BerndDoser Jul 10, 2024
3b01cf0
test jenkins trigger
BerndDoser Jul 10, 2024
91d3dff
fix wrong offset to extra residence time pull groups
BerndDoser Jul 10, 2024
83631f6
Add residence_dist_reached, to print notification only once and to av…
BerndDoser Jul 11, 2024
4cd6145
remove deprecated mdp options and docu
BerndDoser Jul 11, 2024
90cb338
add GPUs to devcontainer
BerndDoser Jul 19, 2024
6440a31
change devcontainer from microsoft-vscode-cpp into nvidia-cuda and ad…
BerndDoser Jul 19, 2024
c434319
cmake: add cuda support
BerndDoser Jul 19, 2024
a9dc01a
preparePrevStepPullCom for residence time groups
BerndDoser Jul 19, 2024
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
37 changes: 35 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,52 @@
ARG VARIANT=ubuntu-22.04
FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT}
ARG CUDA_VERSION=12.3.2
ARG OS_VERSION=ubuntu22.04

FROM nvcr.io/nvidia/cuda:${CUDA_VERSION}-devel-${OS_VERSION}

LABEL maintainer="Bernd Doser <[email protected]>"

RUN apt-get update \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
clang \
gdb \
git \
libomp-14-dev \
python3 \
python3-dev \
python3-pip \
python3-pip \
python3-venv \
sudo \
vim \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade pip \
&& hash -r pip3

RUN pip install \
cmake \
dash \
pandas

ARG USERNAME=vscode
ARG USER_UID=15005
ARG USER_GID=15000

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

# ********************************************************
# * Anything else you want to do like clean up goes here *
# ********************************************************

# [Optional] Set the default user. Omit if you want to keep the default as root.
USER $USERNAME
9 changes: 6 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"dockerfile": "Dockerfile"
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt", "seccomp=unconfined"
"--gpus=all",
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],

// Add the IDs of extensions you want installed when the container is created.
Expand All @@ -30,7 +32,8 @@
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",

// Mount external data volume for debugging purposes
"mounts": [
"source=${localEnv:HOME}/data/gromacs-ramd,target=/data,type=bind,consistency=cached"
"source=/home/doserbd/data/gromacs-ramd,target=/data,type=bind,consistency=cached"
]
}
27 changes: 26 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,30 @@
}
]
},
{
"name": "(gdb) 4water grompp ramd",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/gmx",
"args": ["grompp",
"-f", "${workspaceFolder}/src/gromacs/ramd/tests/data/4water/4water.mdp",
"-c", "${workspaceFolder}/src/gromacs/ramd/tests/data/4water/4water.gro",
"-p", "${workspaceFolder}/src/gromacs/ramd/tests/data/4water/4water.top",
"-n", "${workspaceFolder}/src/gromacs/ramd/tests/data/4water/4water2.ndx",
"-o", "topol.tpr"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build/tests",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "(gdb) mdrun",
"type": "cppdbg",
Expand Down Expand Up @@ -377,7 +401,8 @@
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/ramd-test",
"args": [],
// "args": ["--gtest_filter=RAMDTest.CalculateForces1WDHI"],
// "args": ["--gtest_filter=RAMDTest.binding_residues"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build/tests",
"environment": [],
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cmake.configureSettings": {
"GMX_BUILD_OWN_FFTW": "ON"
"GMX_BUILD_OWN_FFTW": "ON",
"GMX_GPU": "CUDA"
},
"cmake.generator": "Unix Makefiles",
"clang-format.executable": "/usr/bin/clang-format-7",
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Please use following mdp options:

This parameter affect absolute dissociation time but have less
effect on the relative dissociation times of different compounds. It is
recommended to use default value.
recommended to use default value. Default value is 0.0025 nm.

* ramd-group1-max-dist

Expand All @@ -72,7 +72,7 @@ Please use following mdp options:
upper limit of this parameter since motion of the free ligand due to the
external force is very fast (i.e. the last part of the trajectory, where the
ligand does not interact with the protein, usually has a negligible contribution
to the observed dissociation time).
to the observed dissociation time). Default value is 4 nm.

* ramd-group1-receptor

Expand Down Expand Up @@ -105,3 +105,13 @@ Please use following mdp options:
Each ligand is subject to a RAMD force until the individual ligand has left the
dissociation radius. The simulation stops when all ligands have left the
dissociation radius. Default value is 'yes'.

* ramd-use-residence-dist

If 'yes', the residence time will be printed to the log file.
Default value is 'no'.

* ramd-residence-dist

Residence distance in nm. If the ligand is within this distance from the receptor, it is considered to be bound.
Default value is 0.55 nm.
7 changes: 6 additions & 1 deletion src/gromacs/fileio/tpxio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1518,18 +1518,23 @@ static void do_inputrec(gmx::ISerializer* serializer, t_inputrec* ir, int file_v
serializer->doInt(&ir->ramdParams->ngroup);
if (serializer->reading())
{
snew(ir->ramdParams->group, ir->ramdParams->ngroup);
ir->ramdParams->group.resize(ir->ramdParams->ngroup);
}
for (int g = 0; g < ir->ramdParams->ngroup; g++)
{
serializer->doReal(&ir->ramdParams->group[g].force);
serializer->doReal(&ir->ramdParams->group[g].max_dist);
serializer->doReal(&ir->ramdParams->group[g].r_min_dist);
serializer->doString(&ir->ramdParams->group[g].bind_res_receptor);
serializer->doString(&ir->ramdParams->group[g].bind_res_ligand);

}
serializer->doInt(&ir->ramdParams->eval_freq);
serializer->doInt(&ir->ramdParams->force_out_freq);
serializer->doBool(&ir->ramdParams->old_angle_dist);
serializer->doBool(&ir->ramdParams->connected_ligands);
serializer->doBool(&ir->ramdParams->use_residence_dist);
serializer->doReal(&ir->ramdParams->residence_dist);
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/gromacs/gmxpreprocess/readir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3127,6 +3127,18 @@ void get_ir(const char* mdparin,
sfree(dumstr[1]);
}

bool groupExists(const std::string& s, gmx::ArrayRef<const IndexGroup> indexGroups)
{
for (int i = 0; i < gmx::ssize(indexGroups); i++)
{
if (gmx_strcasecmp(s.c_str(), indexGroups[i].name.c_str()) == 0)
{
return true;
}
}
return false;
}

int getGroupIndex(const std::string& s, gmx::ArrayRef<const IndexGroup> indexGroups)
{
for (int i = 0; i < gmx::ssize(indexGroups); i++)
Expand Down Expand Up @@ -4267,6 +4279,11 @@ void do_index(const char* mdparin,
}
}

if (ir->bRAMD && ir->ramdParams->use_residence_dist)
{
add_residence_time_groups(ir, defaultIndexGroups, inputrecStrings->pullGroupNames);
}

if (ir->bPull || ir->bRAMD)
{
for (int i = 1; i < ir->pull->ngroup; i++)
Expand Down
6 changes: 6 additions & 0 deletions src/gromacs/gmxpreprocess/readir.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ void check_ir(const char* mdparin,
t_gromppopts* opts,
WarningHandler* wi);

//! Returns true if string \p s is in \p indexGroups
bool groupExists(const std::string& s, gmx::ArrayRef<const IndexGroup> indexGroups);

//! Returns the index of string \p s in \p indexGroups or exit with a verbose fatal error when not found
int getGroupIndex(const std::string& s, gmx::ArrayRef<const IndexGroup> indexGroups);

Expand Down Expand Up @@ -181,6 +184,9 @@ pull_t* set_pull_init(t_inputrec* ir,
void read_ramdparams(std::vector<t_inpfile>* inp, gmx::RAMDParams* ramdparams, WarningHandler* wi);
/* Reads the ramd parameters, returns a list of the ramd group names */

void add_residence_time_groups(t_inputrec* ir, std::vector<IndexGroup> defaultIndexGroups,
std::vector<std::string>& pullGroupNames);

std::vector<std::string> read_rotparams(std::vector<t_inpfile>* inp, t_rot* rot, WarningHandler* wi);
/* Reads enforced rotation parameters, returns a list of the rot group names */

Expand Down
66 changes: 61 additions & 5 deletions src/gromacs/gmxpreprocess/readramd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#include "gromacs/gmxpreprocess/readir.h"
#include "gromacs/mdtypes/inputrec.h"
#include "gromacs/mdtypes/ramd_params.h"
#include "gromacs/mdtypes/pull_params.h"
#include "gromacs/topology/index.h"
#include "gromacs/topology/topology.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/smalloc.h"
Expand All @@ -46,11 +48,10 @@ void read_ramdparams(std::vector<t_inpfile>* inp, gmx::RAMDParams* ramdparams, W
{
ramdparams->seed = get_eint(inp, "ramd-seed", 1234, wi);
ramdparams->ngroup = get_eint(inp, "ramd-ngroups", 1, wi);
snew(ramdparams->group, ramdparams->ngroup);

for (int i = 0; i < ramdparams->ngroup; i++)
{
auto ramdgrp = &ramdparams->group[i];
gmx::RAMDGroup ramdgrp;
auto ramd_prefix = std::string("ramd-group") + std::to_string(i + 1);
auto pull1_prefix = std::string("pull-group") + std::to_string(i * 2 + 1);
auto pull2_prefix = std::string("pull-group") + std::to_string(i * 2 + 2);
Expand All @@ -65,9 +66,13 @@ void read_ramdparams(std::vector<t_inpfile>* inp, gmx::RAMDParams* ramdparams, W
inp->emplace_back(0, 1, false, false, false, pull2_prefix + "-pbcatom",
get_estr(inp, ramd_prefix + "-ligand-pbcatom", "0"));

ramdgrp->force = get_ereal(inp, ramd_prefix + "-force", 600, wi);
ramdgrp->r_min_dist = get_ereal(inp, ramd_prefix + "-r-min-dist", 0.0025, wi);
ramdgrp->max_dist = get_ereal(inp, ramd_prefix + "-max-dist", 4.0, wi);
ramdgrp.force = get_ereal(inp, ramd_prefix + "-force", 600, wi);
ramdgrp.r_min_dist = get_ereal(inp, ramd_prefix + "-r-min-dist", 0.0025, wi);
ramdgrp.max_dist = get_ereal(inp, ramd_prefix + "-max-dist", 4.0, wi);
ramdgrp.bind_res_receptor = get_estr(inp, ramd_prefix + "-receptor-res", "receptor");
ramdgrp.bind_res_ligand = get_estr(inp, ramd_prefix + "-ligand-res", "ligand");

ramdparams->group.emplace_back(ramdgrp);
}

inp->emplace_back(0, 1, false, false, false, "pull-pbc-ref-prev-step-com",
Expand Down Expand Up @@ -106,4 +111,55 @@ void read_ramdparams(std::vector<t_inpfile>* inp, gmx::RAMDParams* ramdparams, W
}

ramdparams->connected_ligands = getEnum<Boolean>(inp, "ramd-connected-ligands", wi) != Boolean::No;
ramdparams->use_residence_dist = getEnum<Boolean>(inp, "ramd-use-residence-dist", wi) != Boolean::No;
ramdparams->residence_dist = get_ereal(inp, "ramd-residence-dist", 0.55, wi);
}


void add_residence_time_groups(t_inputrec* ir, std::vector<IndexGroup> indexGroups,
std::vector<std::string>& pullGroupNames)
{
std::string receptor = ir->ramdParams->group[0].bind_res_receptor;
std::string ligand = ir->ramdParams->group[0].bind_res_ligand;

int nb_bind_res_receptor = 0;
int nb_bind_res_ligand = 0;
for (int i = 0; i < gmx::ssize(indexGroups); i++)
{
if (gmx_wcmatch((receptor + "_group*").c_str(), indexGroups[i].name.c_str()) == 0)
{
++nb_bind_res_receptor;
}
if (gmx_wcmatch((ligand + "_group*").c_str(), indexGroups[i].name.c_str()) == 0)
{
++nb_bind_res_ligand;
}
}

GMX_ASSERT(nb_bind_res_receptor == nb_bind_res_ligand, "Number of receptor binding groups must be equal to number of ligand binding groups.");

for (int i = 0; i < nb_bind_res_receptor; ++i)
{
std::string receptor_group_string = receptor + "_group_" + std::to_string(i + 1);
pullGroupNames.push_back(receptor_group_string);
if (groupExists(receptor_group_string, indexGroups)) {
const int receptor_gid = getGroupIndex(receptor_group_string.c_str(), indexGroups);
t_pull_group receptor_group;
receptor_group.ind = indexGroups[receptor_gid].particleIndices;
receptor_group.pbcatom = 0;
ir->pull->group.push_back(receptor_group);
ir->pull->ngroup++;
}

std::string ligand_group_string = ligand + "_group_" + std::to_string(i + 1);
pullGroupNames.push_back(ligand_group_string);
if (groupExists(ligand_group_string, indexGroups)) {
const int ligand_gid = getGroupIndex(ligand_group_string.c_str(), indexGroups);
t_pull_group ligand_group;
ligand_group.ind = indexGroups[ligand_gid].particleIndices;
ligand_group.pbcatom = 0;
ir->pull->group.push_back(ligand_group);
ir->pull->ngroup++;
}
}
}
16 changes: 8 additions & 8 deletions src/gromacs/mdrun/md.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,14 @@ void gmx::LegacySimulator::do_md()
{
EnergyData::initializeEnergyHistory(startingBehavior_, observablesHistory_, &energyOutput);
}

/* RAMD */
std::unique_ptr<RAMD> ramd = nullptr;
if (ir->bRAMD)
{
ramd = std::make_unique<RAMD>(*ir->ramdParams, pullWork_, startingBehavior_, cr_, nFile_, fnm_, oenv_, fpLog_);
fr_->forceProviders->addForceProvider(ramd.get());
}

preparePrevStepPullCom(
ir, pullWork_, md->massT, state_, stateGlobal_, cr_, startingBehavior_ != StartingBehavior::NewSimulation);
Expand Down Expand Up @@ -626,14 +634,6 @@ void gmx::LegacySimulator::do_md()
int64_t step = ir->init_step;
int64_t step_rel = 0;

/* RAMD */
std::unique_ptr<RAMD> ramd = nullptr;
if (ir->bRAMD)
{
ramd = std::make_unique<RAMD>(*ir->ramdParams, pullWork_, startingBehavior_, cr_, nFile_, fnm_, oenv_, fpLog_);
fr_->forceProviders->addForceProvider(ramd.get());
}

/* To minimize communication, compute_globals computes the COM velocity
* and the kinetic energy for the velocities without COM motion removed.
* Thus to get the kinetic energy without the COM contribution, we need
Expand Down
4 changes: 4 additions & 0 deletions src/gromacs/mdtypes/inputrec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,8 @@ static void pr_ramd_group(FILE* fp, int indent, int g, const gmx::RAMDGroup grp)
PR("force", grp.force);
PR("max_dist", grp.max_dist);
PR("r_min_dist", grp.r_min_dist);
PS("bind_res_receptor", grp.bind_res_receptor.c_str());
PS("bind_res_ligand", grp.bind_res_ligand.c_str());
}

static void pr_ramd(FILE* fp, int indent, const gmx::RAMDParams ramd)
Expand All @@ -654,6 +656,8 @@ static void pr_ramd(FILE* fp, int indent, const gmx::RAMDParams ramd)
PI("ramd-force-out-freq", ramd.force_out_freq);
PS("ramd-old-angle-dist", EBOOL(ramd.old_angle_dist));
PS("ramd-connected-ligands", EBOOL(ramd.connected_ligands));
PS("ramd-use-residence-dist", EBOOL(ramd.use_residence_dist));
PR("ramd-residence-dist", ramd.residence_dist);
}

static void pr_awh_bias_dim(FILE* fp, int indent, const gmx::AwhDimParams& awhDimParams, const char* prefix)
Expand Down
Loading