> This page is for DiffDock, version 2.3.0 (Latest) (default).
> For other versions, use one of these documentation indexes:
> - 2.3.0 (Latest) (default): https://docs.nvidia.com/nim/bionemo/diffdock/2.3.0/llms.txt
> - 2.2.0: https://docs.nvidia.com/nim/bionemo/diffdock/2.2.0/llms.txt
> - 2.1.0: https://docs.nvidia.com/nim/bionemo/diffdock/2.1.0/llms.txt
> - 2.0.1: https://docs.nvidia.com/nim/bionemo/diffdock/2.0.1/llms.txt
> - 1.2.0: https://docs.nvidia.com/nim/bionemo/diffdock/1.2.0/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nim/bionemo/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nim/bionemo/_mcp/server.

# Advanced Usage

## Run Inference With a Bash Script

This example uses a `bash` script to run inference from two local files and write the generated poses to the `output` folder.

1. Create a file named `diffdock.sh` in the same folder and copy the content below into it.

```bash
#!/bin/bash

# Script: diffdock.sh - Run inference using local files as input
# Usage: ./diffdock.sh [receptor].pdb [ligand].sdf

protein_file=$1
ligand_file=$2

protein_bytes=`grep -E ^ATOM $protein_file | sed -z 's/\n/\\\n/g'`
ligand_bytes=`sed -z 's/\n/\\\n/g' $ligand_file`
ligand_format=`basename $ligand_file | awk -F. '{print $NF}'`

echo "{
   \"ligand\": \"${ligand_bytes}\",
   \"ligand_file_type\": \"${ligand_format}\",
   \"protein\": \"${protein_bytes}\",
   \"num_poses\": 10,
   \"time_divisions\": 20,
   \"steps\": 18,
   \"save_trajectory\": false,
   \"is_staged\": false
}" > diffdock.json

curl --header "Content-Type: application/json" \
   --request POST \
   --data @diffdock.json \
   --output output.json \
   http://localhost:8000/molecular-docking/diffdock/generate
```

2. Make the script executable.

```bash
chmod +x diffdock.sh
```

3. Download the input files from RCSB database and launch the inference.

```bash
curl -o 8G43.pdb https://files.rcsb.org/download/8G43.pdb
curl -o ZU6.sdf https://files.rcsb.org/ligands/download/ZU6_ideal.sdf
./diffdock.sh 8G43.pdb ZU6.sdf
```

4. Dump the output using the Python script created in [Getting Started](/nim/bionemo/diffdock/getting-started#dump-generated-poses).

```bash
python3 dump_output.py
ls output
```

5. Example of output

```
rank01_confidence_0.57.sdf  rank06_confidence_-0.25.sdf
rank02_confidence_0.57.sdf  rank07_confidence_-0.69.sdf
rank03_confidence_0.55.sdf  rank08_confidence_-1.31.sdf
rank04_confidence_0.41.sdf  rank09_confidence_-1.90.sdf
rank05_confidence_0.38.sdf  rank10_confidence_-2.07.sdf
```

## Run Inference for Batch Docking

DiffDock NIM supports batch docking, which docks a group of ligand molecules against the same protein receptor in one inference request when you submit a multi-molecule SDF file. Batch docking is more efficient than separate inference requests. The example docks one protein PDB file against five ligand SDF files from the [RCSB](https://www.rcsb.org/).

1.  Prepare the SDF input file with multiple ligand molecules. Create a new blank file, name it as `make-multiligand.sh`, and copy the content below into it.

```bash
#!/bin/bash

# Script: make-multiligand.sh
# Usage: ./make-multiligand.sh [Ligand1_CCD_ID] [Ligand2_CCD_ID] ...
# Example: ./make-multiligand.sh COM Q4H QPK R4W SIN

ligand_files=""

for lig in $*
do
    ligand_file=${lig}.sdf
    echo "Download ligand file: ${ligand_file}"
    curl -o $ligand_file "https://files.rcsb.org/ligands/download/${lig}_ideal.sdf"
    ligand_files="${ligand_files} ${ligand_file}"
done

# Combine ligand files into a single SDF file
cat $ligand_files > multi_ligands.sdf
```

2. Run the commands below to generate the `multi_ligands.sdf` for input.

```bash
chmod +x make-multiligand.sh
./make-multiligand.sh COM Q4H QPK R4W SIN
```

3. Download the protein PDB file and launch the inference.

```bash
curl -o 7RWO.pdb "https://files.rcsb.org/download/7RWO.pdb"
./diffdock.sh 7RWO.pdb multi_ligands.sdf
```

4. Dump the result and an example of output is below.

```bash
python3 dump_output.py
ls output/*

output/ligand0:
rank01_confidence_-0.74.sdf  rank05_confidence_-1.15.sdf  rank09_confidence_-1.55.sdf
rank02_confidence_-0.92.sdf  rank06_confidence_-1.25.sdf  rank10_confidence_-1.93.sdf
rank03_confidence_-0.93.sdf  rank07_confidence_-1.46.sdf
rank04_confidence_-1.04.sdf  rank08_confidence_-1.46.sdf

output/ligand1:
rank01_confidence_-0.25.sdf  rank05_confidence_-0.55.sdf  rank09_confidence_-0.72.sdf
rank02_confidence_-0.28.sdf  rank06_confidence_-0.55.sdf  rank10_confidence_-0.77.sdf
rank03_confidence_-0.34.sdf  rank07_confidence_-0.56.sdf
rank04_confidence_-0.49.sdf  rank08_confidence_-0.57.sdf

...
```

## Run Batch Docking With SMILES

Besides the SDF format for ligand molecules, DiffDock also supports
[SMILES](https://en.wikipedia.org/wiki/Simplified_molecular-input_line-entry_system) text strings as the input. DiffDock uses [RDKit](https://www.rdkit.org/) to generate random
molecular conformers from the SMILES information. A plain text file can
be used as the ligand input with multiple lines, each of which is a
SMILES formula representing a molecule, to run batch docking.

1. Create a new blank file, name it as `ligands.txt` and copy the content below into it.

```bash
Cc1cc(F)c(NC(=O)NCCC(C)(C)C)cc1Nc1ccc2ncn(C)c(=O)c2c1F
COc1cccc(NC(=O)c2ccc(C)c(Nc3nc(-c4cccnc4)nc4c3cnn4C)c2)c1
Cc1nn(C)c(C)c1CCOc1cc(F)ccc1-c1ccc2n[nH]c(CN(C)C)c2c1
Cc1c(C(=O)c2cccc3ccccc23)c2cccc3c2n1[C@H](CN1CCOCC1)CO3
```

2. Run the commands below to invoke the DiffDock model. The script generates an input JSON file and returns the inference result in JSON format in the file `output.json`.

```bash
./diffdock.sh 8G43.pdb ligands.txt
```

3. Dump the result and check the output folder.

```bash
$ python3 dump_output.py
$ ls output/*

output/ligand0:
rank01_confidence_-0.98.sdf  rank05_confidence_-1.30.sdf  rank09_confidence_-1.77.sdf
rank02_confidence_-1.00.sdf  rank06_confidence_-1.36.sdf  rank10_confidence_-2.27.sdf
rank03_confidence_-1.03.sdf  rank07_confidence_-1.58.sdf
rank04_confidence_-1.21.sdf  rank08_confidence_-1.61.sdf

output/ligand1:
rank01_confidence_-0.15.sdf  rank05_confidence_-1.25.sdf  rank09_confidence_-1.55.sdf
rank02_confidence_-0.54.sdf  rank06_confidence_-1.29.sdf  rank10_confidence_-1.66.sdf
rank03_confidence_-0.91.sdf  rank07_confidence_-1.38.sdf
rank04_confidence_-1.03.sdf  rank08_confidence_-1.39.sdf

...
```