DiffDock使用推理-【DiffDock: Diffusion Steps, Twists, and Turns for Molecular Docking】

本文详细描述了如何在特定环境下下载、解压并配置DiffDock项目,包括创建conda环境、安装缺失依赖(如dllogger、openfold等)、完善代码以及运行推理过程中的注意事项,特别提到了GPU性能对推理时间的影响。
摘要由CSDN通过智能技术生成


前言

论文PDF:
DiffDock: Diffusion Steps, Twists, and Turns for Molecular Docking
在这里插入图片描述
论文代码:
https://github.com/gcorso/DiffDock


1 准备工作

1.1 下载仓库

在这里插入图片描述

1.2 解压

解压到自己的目录
在这里插入图片描述

1.3 配置conda环境

切换到当前解压目录

cd /d D:\Article\article\DiffDock\DiffDock-main

根据environment.yml创建conda环境

conda env create --file environment.yml

创建好后激活

conda activate diffdock

因为国内网的问题很多依赖并没有安装好,所以需要手动进行依赖安装
看一下他的requirements.txt

--extra-index-url https://download.pytorch.org/whl/cu117
--find-links https://pytorch-geometric.com/whl/torch-1.13.1+cu117.html
# Note: openfold build may fail if torch not installed first, so it should be installed separately.
# Here for reference.
torch==1.13.1+cu117
dllogger@git+https://github.com/NVIDIA/dllogger.git
e3nn==0.5.0
fair-esm[esmfold]==2.0.0
networkx==2.8.4
openfold@git+https://github.com/aqlaboratory/openfold.git@4b41059694619831a7db195b7e0988fc4ff3a307
pandas==1.5.1
prody==2.2.0
prody==2.2.0
pybind11==2.11.1
rdkit==2022.03.3
scikit-learn==1.1.0
scipy==1.12.0
torch==1.13.1+cu117
torch-cluster==1.6.0+pt113cu117
torch-geometric==2.2.0
torch-scatter==2.1.0+pt113cu117
torch-sparse==0.6.16+pt113cu117
torch-spline-conv==1.2.1+pt113cu117
torchmetrics==0.11.0

先改一下镜像源,改成清华的。

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

首先安装pytorch(torch==1.13.1+cu117)

pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu117

其他的包比较简单了。依次安装就好

pin install e3nn==0.5.0
......

这里说几个有问题的dllogger、openfold、torch-cluster、torch-scatter、torch-sparse、torch-spline-conv

1.3.1 dllogger、openfold

dllogger、openfold都需要git,如果没有科学上网的全局代理的话不好git,我们直接下载dllogger、openfold,本地安装
dllogger
在这里插入图片描述
openfold
在这里插入图片描述
下载好后放到服务器里
在这里插入图片描述
切换到dllogger目录里

cd dllogger-master/

源码安装

python setup.py install

返回

/home/shijiabao/.conda/envs/diffdock/lib/python3.9/site-packages/setuptools/_distutils/dist.py:266: UserWarning: Unknown distribution option: 'install_package_data'
  warnings.warn(msg)
running install
/home/shijiabao/.conda/envs/diffdock/lib/python3.9/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!
  self.initialize_options()
/home/shijiabao/.conda/envs/diffdock/lib/python3.9/site-packages/setuptools/_distutils/cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` and ``easy_install``.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://github.com/pypa/setuptools/issues/917 for details.
        ********************************************************************************

!!
  self.initialize_options()
running bdist_egg
running egg_info
writing DLLogger.egg-info/PKG-INFO
writing dependency_links to DLLogger.egg-info/dependency_links.txt
writing top-level names to DLLogger.egg-info/top_level.txt
reading manifest file 'DLLogger.egg-info/SOURCES.txt'
adding license file './LICENSE'
writing manifest file 'DLLogger.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
copying dllogger/logger.py -> build/lib/dllogger
copying dllogger/__init__.py -> build/lib/dllogger
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/dllogger
copying build/lib/dllogger/logger.py -> build/bdist.linux-x86_64/egg/dllogger
copying build/lib/dllogger/__init__.py -> build/bdist.linux-x86_64/egg/dllogger
byte-compiling build/bdist.linux-x86_64/egg/dllogger/logger.py to logger.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/dllogger/__init__.py to __init__.cpython-39.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying DLLogger.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying DLLogger.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying DLLogger.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying DLLogger.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/DLLogger-1.0.0-py3.9.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing DLLogger-1.0.0-py3.9.egg
Removing /home/shijiabao/.conda/envs/diffdock/lib/python3.9/site-packages/DLLogger-1.0.0-py3.9.egg
Copying DLLogger-1.0.0-py3.9.egg to /home/shijiabao/.conda/envs/diffdock/lib/python3.9/site-packages
Adding DLLogger 1.0.0 to easy-install.pth file

Installed /home/shijiabao/.conda/envs/diffdock/lib/python3.9/site-packages/DLLogger-1.0.0-py3.9.egg
Processing dependencies for DLLogger==1.0.0
Finished processing dependencies for DLLogger==1.0.0

看到Finished processing dependencies for DLLogger==1.0.0就代表安装好了
openfold同理
查看DLLogger版本

pip show dllogger

在这里插入图片描述
很完美

1.3.2 torch-cluster、torch-scatter、torch-sparse、torch-spline-conv

打开https://pytorch-geometric.com/whl/torch-1.13.1+cu117.html
依次下载,注意python版本

torch-cluster==1.6.0+pt113cu117
torch-scatter==2.1.0+pt113cu117
torch-sparse==0.6.16+pt113cu117
torch-spline-conv==1.2.1+pt113cu117

下载好后上传服务器
在这里插入图片描述
切换到当前目录,把这四个依次安装就好

pip install torch_cluster-1.6.0+pt113cu117-cp39-cp39-linux_x86_64.whl 

这下我们的环境配置好了。

2 完善代码

查看DiffDock-main/default_inference_args.yaml

actual_steps: 19
ckpt: best_ema_inference_epoch_model.pt
confidence_ckpt: best_model_epoch75.pt
confidence_model_dir: ./workdir/v1.1/confidence_model
different_schedules: false
inf_sched_alpha: 1
inf_sched_beta: 1
inference_steps: 20
initial_noise_std_proportion: 1.4601642460337794
limit_failures: 5
model_dir: ./workdir/v1.1/score_model
no_final_step_noise: true
no_model: false
no_random: false
no_random_pocket: false
ode: false
old_filtering_model: true
old_score_model: false
resample_rdkit: false
samples_per_complex: 10
sigma_schedule: expbeta
temp_psi_rot: 0.9022615585677628
temp_psi_tor: 0.5946212391366862
temp_psi_tr: 0.727287304570729
temp_sampling_rot: 2.06391612594481
temp_sampling_tor: 7.044261621607846
temp_sampling_tr: 1.170050527854316
temp_sigma_data_rot: 0.7464326999906034
temp_sigma_data_tor: 0.6943254174849822
temp_sigma_data_tr: 0.9299802531572672

发现评分模型和置信模型都没有需要下载
创建/workdir/v1.1/
打开https://github.com/gcorso/DiffDock/releases/download/v1.1/diffdock_models.zip
下载好后把这俩解压进去
在这里插入图片描述
工作完成。

3 运行推理

切换到主目录

cd /mnt/data/sjb/chem/DiffDock/DiffDock-main

运行gui

python app/main.py

访问7860端口
在这里插入图片描述
拿单复合物测试一下
在这里插入图片描述在这里插入图片描述
点击Run DiffDock,控制台显示

[2024-04-27 17:53:29 CST] [run_utils.py:126] INFO - Executing command: python3 inference.py --protein_path=/tmp/gradio/91e785aff143e89f8ac69b9fa79d954d8f9db1e9/6w70.pdb --ligand=/tmp/gradio/791e5fa3bf00a85ff5e9ad67106387c408ec2161/6w70_ligand.sdf --config=/mnt/data/sjb/chem/DiffDock/DiffDock-main/default_inference_args.yaml --no_final_step_noise --loglevel=INFO --samples_per_complex=10 --out_dir=/tmp/tmphqksb6pk

我的服务器是两张A6000,显卡和CPU的性能会影响推理时间
推理完成

[2024-04-27 17:55:32 CST] [run_utils.py:147] ERROR - Command error:
[2024-Apr-27 17:53:47 CST] [inference.py:153] INFO - DiffDock will run on cuda
[2024-Apr-27 17:54:01 CST] [inference.py:184] INFO - Confidence model uses different type of graphs than the score model. Loading (or creating if not existing) the data for the confidence model now.
[2024-Apr-27 17:54:13 CST] [inference.py:223] INFO - Size of test dataset: 1

0it [00:00, ?it/s]/mnt/data/sjb/chem/DiffDock/DiffDock-main/datasets/parse_chi.py:91: RuntimeWarning: invalid value encountered in cast
  Y = indices.astype(int)

1it [01:17, 77.80s/it]
1it [01:17, 77.80s/it]
[2024-Apr-27 17:55:31 CST] [inference.py:312] INFO - 
    Failed for 0 / 1 complexes.
    Skipped 0 / 1 complexes.

[2024-Apr-27 17:55:31 CST] [inference.py:313] INFO - Results saved in /tmp/tmphqksb6pk

在这里插入图片描述
选取十个rank
可视化
在这里插入图片描述

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

bblb

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值