如何使用docker安装gmx_MMPBSA
Introduction
此处的gmx_MMPBSA不是李继存老师的脚本,而是2021年发表在JCTC上gmx_MMPBSA: A New Tool to Perform End-State Free Energy Calculations with GROMACS新工具。
本文中使用的gmx_MMPBSA依赖于AmberTool和Gromacs,使用docker安装。镜像是这个。
Prerequisition
在安装前需要确定几件事情:
- NVIDIA driver
- NVIDIA-Docker(注意,NVIDA-Docker不支持Ubuntu24.04,所以在安装WSL2的时候需要看清楚版本)
- 自然地,需要Docker
Installation
安装命令:
docker pull lammfar/mmpbsa
或者
docker build -t gmx_mmpbsa .
Simple Usage
使用时最好挂载本地目录,将路径修改好就可以了:
docker run -it --gpus all -v /YOU/PATH:/DOCKER/PATH lammfar/mmpbsa:latest
docker run -it --gpus all gmx_mmpbsa
如果挂载了本地目录,那么挂载目录就会伴随该docker容器生命周期一直存在。并且容器中的文件也可以在本地终端中直接访问。
在容器中退出容器(不关闭容器):
CTRL+D
在容器中退出容器(关闭容器):
exit
<IMAGE NAME>
使用docker ps
或docker ps -a
查看- 退出容器之后不会关闭容器,使用
docker ps
可以看到后台还在运行着该容器 - 关闭容器:
docker stop <IMAGE NAME>
- 运行已经关闭的容器:
docker start -i <IMAGE NAME>
- 使用命令行的形式进入容器:
docker exec -it <IMAGE NAME> /bin/bash
- 删除容器:`docker rm
如何运行gmx_MMPBSA
首先查看感兴趣的部分所对应的索引(Index),这里对应于Protein和JZ4的索引:
gmx check -n index.ndx
输出:
:-) GROMACS - gmx check, 2023.5 (-:
Executable: /home/chain/gmx2023.5/bin/gmx
Data prefix: /home/chain/gmx2023.5
Working dir: /home/chain/gmx_work/complex
Command line:
gmx check -n index.ndx
Contents of index file index.ndx
--------------------------------------------------
Nr. Group #Entries First Last
0 System 33506 1 33506
1 Protein 2614 1 2614
2 Protein-H 1301 1 2614
3 C-alpha 163 5 2602
4 Backbone 489 1 2612
5 MainChain 651 1 2612
6 MainChain+Cb 803 1 2612
7 MainChain+H 813 1 2612
8 SideChain 1801 6 2614
9 SideChain-H 650 7 2614
10 Prot-Masses 2614 1 2614
11 non-Protein 30892 2615 33506
12 Other 22 2615 2636
13 JZ4 22 2615 2636
14 CL 6 33501 33506
15 Water 30864 2637 33500
16 SOL 30864 2637 33500
17 non-Water 2642 1 33506
18 Ion 6 33501 33506
19 Water_and_ions 30870 2637 33506
GROMACS reminds you: "Player Sleeps With the Fishes" (Ein Bekanntes Spiel Von ID Software)
所以索引是1和13.
运行
mpirun -np 8 --allow-run-as-root gmx_MMPBSA -O -i mmpbsa.in -cs md_0_10.tpr -ci index.ndx -cg 1 13 -ct md_95_100.xtc -cp topol.top -o FINAL_RESULTS_MMPBSA.dat -eo FINAL_RESULTS_MMPBSA.csv -nogui
mpirun-np 8使用时间:
[INFO ] Timing:
[INFO ] Total GROMACS setup time: 0.125 min.
[INFO ] Total AMBER setup time: 0.010 min.
[INFO ] Creating trajectories with cpptraj: 0.070 min.
[INFO ] Total calculation time: 33.283 min.
[INFO ] Total PB calculation time: 32.836 min.
[INFO ] Statistics calculation & output writing: 0.002 min.
[INFO ] Total time taken: 33.491 min.
gmx_MMPBSA -O -i mmpbsa.in -cs md_0_10.tpr -ci index.ndx -cg 1 13 -ct md_95_100.xtc -cp topol.top -o FINAL_RESULTS_MMPBSA.dat -eo FINAL_RESULTS_MMPBSA.csv -nogui
普通使用时间:
[INFO ] Timing:
[INFO ] Total GROMACS setup time: 0.002 hr.
[INFO ] Total AMBER setup time: 0.000 hr.
[INFO ] Creating trajectories with cpptraj: 0.001 hr.
[INFO ] Total calculation time: 3.344 hr.
[INFO ] Total PB calculation time: 3.341 hr.
[INFO ] Statistics calculation & output writing: 0.000 hr.
[INFO ] Total time taken: 3.347 hr.
测试使用Gromacs官方教程5中使用的配体与蛋白。机器CPU为i7 8核,GPU为3060 Laptop,RAM为16G。系统为win10,WSL2 Ubuntu 22.04中的docker Ubuntu 22.04 CUDA12.5镜像。
最终使用串行的运行时间是使用并行计算运算时间的6倍。
mmpbsa.in
Sample input file for PB calculation building the Amber topologies
from structures. Please refer to the section "How gmx_MMPBSA works"
&general
sys_name="Prot-Lig-CHARMM"
/
&pb
istrng=0.15, fillratio=4.0
/
Dockerfile
## Ubuntu 20.04 with CUDA 11.2 and GROMACS 2020.2
FROM nvcr.io/hpc/gromacs:2020.2
## System variables
ARG DEBIAN_FRONTEND=noninteractive
ENV MMPBSA_HOME=/home/mmpbsa
ENV PATH=/root/miniconda3/bin:$PATH
ENV AMBERHOME=/root/miniconda3/bin
## MMPBSA's main directory
RUN mkdir -p ${MMPBSA_HOME}
## Keep alive script
COPY keepalive.sh ${MMPBSA_HOME}
RUN chmod +x ${MMPBSA_HOME}/keepalive.sh
## APT packages and related configs
#RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
#RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get install -y apt-utils
RUN apt-get install -y build-essential
RUN apt-get install -y python3-dev python3-pip build-essential
RUN apt-get install -y software-properties-common
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10
RUN apt-get install -y git
RUN apt-get install -y cmake
RUN apt-get install -y wget
RUN apt-get install -y openmpi-bin libopenmpi-dev openssh-client
RUN apt-get install -y libgl1-mesa-glx
RUN apt-get install -y libfontconfig1 libfontconfig
RUN apt-get install -y libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xkb1 libxkbcommon-x11-0 libxcb-util1 libxcb-shm0 libxcb-render0 libxcb-randr0 libxcb-shape0 libxcb-xinerama0 libxcb-xfixes0 libxkbcommon0 libxkbcommon-x11-0
RUN apt-get install -y libarchive13
## Conda install_1
#WORKDIR ${MMPBSA_HOME}
#RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
#RUN bash miniconda.sh -b -p /root/miniconda3/bin/conda
#RUN rm miniconda.sh
#RUN conda update -y -n base -c defaults conda
## Conda install_2
WORKDIR ${MMPBSA_HOME}
RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
RUN bash miniconda.sh -b -p /root/miniconda3
RUN rm miniconda.sh
RUN /root/miniconda3/bin/conda update -y -n base -c defaults conda
##Caution_______1111
RUN /root/miniconda3/bin/conda init
#RUN conda create -y -n myenv python=3.8
RUN conda create -y -n myenv python=3.9
#RUN conda activate myenv
ENV PATH=/root/miniconda3/envs/myenv/bin:$PATH
## Ambertools21 install
#RUN /root/miniconda3/envs/myenv/bin/conda install -y -c conda-forge ambertools=21 compilers
RUN /root/miniconda3/bin/conda run -n myenv /bin/bash -c "conda install -y -c conda-forge ambertools=21 compilers"
## Ambertools21 install
#RUN conda install -y -c conda-forge ambertools=21 compilers
##Caution_____222
#RUN conda deactivate
#ENV PATH /root/miniconda3/envs/myenv/bin:$PATH
## gmx_MMPBSA install
RUN conda install -y pip
RUN python -m pip install PyQt5
RUN conda install -y -c conda-forge mpi4py
RUN python -m pip install gmx_MMPBSA
Dockerfile的修改
在使用的时候需要关注其中基础镜像的选择,根据gromacs的版本来选择对应的镜像。在NVIDIA NGC Catalog中选择对应版本,然后修改Dockerfile第一行FROM nvcr.io/hpc/gromacs:2020.2
即可。
keepalive.sh
#!/bin/bash
while true; do sleep 300; done
转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 1971945941@qq.com