DiffPharm: Pharmacophore model guided 3D molecular generation through diffusion model
- cudatoolkit == 11.8.0
- pytorch == 2.0.1
- rdkit == 2023.03.2
- scipy == 1.11.1
- hydra-core ==1.3.2
- imageio==2.31.1
- matplotlib==3.7.0
- numpy == 1.25.0
- omegaconf == 2.3.0
- pandas == 2.0.2
- Pillow==9.5.0
- pytorch_lightning == 2.0.6
- scikit_learn == 1.2.2
- setuptools==68.0.0
- torch_geometric == 2.3.1
- torchmetrics == 0.11.4
- tqdm == 4.65.0
- wandb == 0.15.4
You can create the environment with the following dependencies:
conda create -n diffpharm python=3.9 rdkit=2023.03.2
conda activate diffpharm
# Core dependencies
conda install -c "nvidia/label/cuda-11.8.0" cuda
pip3 install torch==2.0.1 --index-url https://download.pytorch.org/whl/cu118
pip install -r requirements.txtWe use the same datasets as the MiDi model.
Download and place them under ./data/geom/raw/:
You can also use other datasets you want to use, such as CHEMBL, ZINC, or others.
We use MiDi's checkpoint geom-with-h-adaptive model as the pre-trained model. (We have also trained a new version of MiDi, link is here.)
Place it in:
./checkpoints/pre-trained/Then run training, when we use the linker-free pharmacophore strategy. (removeHs=True)
cd ./midi
python main.py +experiment=linker_free_trainingWhen we use the linker-align pharmacophore strategy. (removeHs=False)
cd ./midi
python main.py +experiment=linker_align_trainingYou can use:
- A model you trained in the previous step
- Or our trained model: Download
Place it in:
./checkpoints/diffpharm/Then run:
cd ./midi
python main.py +experiment=linker_free_training general.test_only='ABS_PATH'
or
python main.py +experiment=linker_align_training general.test_only='ABS_PATH'Replace ABS_PATH with the absolute path of the model checkpoint.
This method is recommended for more lightweight or customized sampling scenarios. It directly invokes the dedicated sampling script diffpharm_sampling.py.py.
cd midi
python diffpharm_sampling.py +experiment=samplingMake sure to set the correct statistics_path in your sampling.yaml.
Inpainting allows you to design novel molecules around fixed substructures and pharmacophore-constraint, supporting tasks such as scaffold hopping, fragment linking, and fragment elaboration. You can either use your own trained model from the training step, or download our pre-trained model from the following link:
You can either use your own trained model from the training step, or download our pre-trained model:
📁 Pretrained Model on Google Drive
After downloading, place the model files into the
./checkpoints/diffpharm/directory.
The inpainting workflow could refer to /inpainting_use/README.md


