# AlphaFold3

AlphaFold3 runs via Singularity/Apptainer container on GPU nodes with the `af3` GRES constraint.

## Loading the Module

```bash
module load alphafold3
```

This automatically loads Apptainer and sets the following environment variables:

<table id="bkmrk-variable-description"><thead><tr><th>Variable</th><th>Description</th></tr></thead><tbody><tr><td>`$AF3_CONTAINER`</td><td>Path to the Singularity container</td></tr><tr><td>`$AF3_MODELS`</td><td>Path to model parameters</td></tr><tr><td>`$AF3_DB`</td><td>Path to the database</td></tr><tr><td>`$AF3_SRC`</td><td>Path to AlphaFold3 source directory</td></tr></tbody></table>

## Bind Mounts

Singularity requires bind mounts to expose host directories inside the container:

```bash
--bind /path/on/host:/path/inside/container
```

Your input folder can be bound to any path inside the container — `/root/af_input` is not required, it's just an example.

## Running AlphaFold3

```bash
singularity exec --nv \
    --bind $AF3_SRC:/root/custom_folder \
    --bind /tmp:/root/af_output \
    --bind $AF3_MODELS:/root/models \
    --bind $AF3_DB:/root/public_databases \
    --bind /home/user/alphafold_inputs:/root/custom_folder \
    $AF3_CONTAINER \
    python /root/custom_folder/run_alphafold.py \
        --json_path=/root/custom_folder/fold_input.json \
        --model_dir=/root/models \
        --db_dir=/root/public_databases \
        --output_dir=/root/af_output
```

Replace `/home/user/alphafold_inputs` with the actual path to your input folder.

For input file format, see the [AlphaFold3 Input File Guide](https://github.com/google-deepmind/alphafold3/blob/main/docs/input.md).

## Listing All Available Flags

```bash
singularity exec --nv \
    --bind $AF3_SRC:/root/custom_folder \
    --bind /tmp:/root/af_output \
    --bind $AF3_MODELS:/root/models \
    --bind $AF3_DB:/root/public_databases \
    $AF3_CONTAINER \
    python /root/custom_folder/run_alphafold.py --helpfull
```

## Example Job Script

```bash
#!/bin/bash
#SBATCH --job-name=alphafold3
#SBATCH --partition=gpu-general
#SBATCH --gres=gpu:1,af3
#SBATCH --cpus-per-task=8
#SBATCH --mem=64G
#SBATCH --time=1-00:00:00
#SBATCH --output=alphafold3_%j.out
#SBATCH --error=alphafold3_%j.err

module load alphafold3

singularity exec --nv \
    --bind $AF3_SRC:/root/custom_folder \
    --bind /tmp:/root/af_output \
    --bind $AF3_MODELS:/root/models \
    --bind $AF3_DB:/root/public_databases \
    --bind /home/user/alphafold_inputs:/root/custom_folder \
    $AF3_CONTAINER \
    python /root/custom_folder/run_alphafold.py \
        --json_path=/root/custom_folder/fold_input.json \
        --model_dir=/root/models \
        --db_dir=/root/public_databases \
        --output_dir=/root/af_output
```

## Unloading

```bash
module unload alphafold3
```

This also unloads the Apptainer module.

## Troubleshooting

- Module not found: `module avail alphafold3` to check the exact name
- No nodes available: `sinfo -o "%N %G"` to check GPU node availability
- Container fails: verify `$AF3_CONTAINER`, `$AF3_MODELS`, `$AF3_DB` are set correctly after module load
- Input files not found: confirm the correct host directory is bound and paths are referenced from inside the container