Skip to content

Haddock3 container workflow & usage #1318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ optional arguments:

Check the [EXAMPLES](https://github.com/haddocking/haddock3/blob/main/examples/README.md) page for more some usage examples and the [User manual](https://www.bonvinlab.org/haddock3-user-manual) for a more detailed explanation of the configuration file.

## Container Usage Examples

- [Container Usage Guide](usage-container/docs/usage.md)
(see detailed docs on running, builidng container, Slurm snippets, etc.)

## Support

If you encounter any code-related issues, [please open an issue](https://github.com/haddocking/haddock3/issues/new/choose).
Expand Down
18 changes: 18 additions & 0 deletions usage-container/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## What I Love to See

We're not just building containers—we're crafting efficient, elegant tools for science. If you're looking for ways to make a difference, consider contributing to:

- **New functionalities** (e.g., new features or support)
- **Reducing redundancy** in scripts or layered installs
- **Shrinking image size** by stripping unused packages or optimizing layers
- **Lowering computational/carbon footprint** through performance tweaks or ecoconscious configurations (smaller images)

## Ideas Welcome — Let’s Connect!

Have a suggestion? Want to extend functionality, reduce image size, or make this container even more efficient and elegant? I'm all ears.

Feel free to:
- Open an [issue](https://github.com/Comp-era/Apptainer-Container-for-HADDOCK3/issues)
- Start a discussion
- Or reach out directly (shantanukhatri.bio@gmail.com), collaboration is always welcome.

21 changes: 21 additions & 0 deletions usage-container/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Shantanu Khatri

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
123 changes: 123 additions & 0 deletions usage-container/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Container workflow for HADDOCK3

This repository provides everything you need to build, run, and extend an **Apptainer/Singularity** container for HADDOCK3. [**HADDOCK3**](https://www.biorxiv.org/content/10.1101/2025.04.30.651432v1)(High Ambiguity Driven protein–protein Docking) is a flexible, information-driven software suite for modeling biomolecular complexes using experimental and theoretical restraints. **Docker**, **Singularity**, and **Apptainer** are containerization platforms that package applications and all their dependencies into lightweight, portable images, ensuring reproducible execution across different environments.

A ready-to-use Docker image for HADDOCK3 is published on the GitHub container registry, simply pull:
```bash
docker pull ghcr.io/haddocking/haddock3:2025.5.0
```
See the [HADDOCK3 container package](https://github.com/haddocking/haddock3/pkgs/container/haddock3) for details and version tags. This image serves as the canonical, versioned distribution of HADDOCK3 and can be used across development, CI/CD, and cloud environments.

To use this as the foundation for HPC-friendly SIF images, build **Apptainer** or **Singularity** containers directly from the Docker image in a single step. For example, to create an image:

```bash
# Build Apptainer image
apptainer build haddock3_mpi.sif docker://ghcr.io/haddocking/haddock3:2025.5.0

# Or, build with Singularity
singularity build haddock3_mpi.sif docker://ghcr.io/haddocking/haddock3:2025.5.0
```
**Note:** Refer to the [**usage.md**](https://github.com/Comp-era/HADDOCK3-Container/blob/main/docs/usage.md) and the example SLURM script available in the `scripts` folder for detailed instructions on how to run HADDOCK3 jobs in an HPC environment.
<pre> <strong>Version updates:</strong> The HADDOCK3 image is regularly updated. Please check the tags at <a href="https://github.com/haddocking/haddock3/pkgs/container/haddock3">ghcr.io/haddocking/haddock3</a> for the latest version. </pre>

---

### Build Your Own HADDOCK3 Container
Containerization techniques enable highly reproducible, customizable, and scalable scientific workflows. If you want to understand how the container is built under the hood from scratch or customize it for your own workflows, follow these detailed steps:
1. **Clone**

```bash
git clone https://github.com/Comp-era/HADDOCK3-Container.git
cd HADDOCK3-Container/recipe
```

**Repository Structure**

```plaintext
├── apptainer_recipe/
│ └── HADDOCK3.def # Definition file
├── docs/ # Documentation
│ ├── usage.md # Usage guide
├── scripts/ # Scripts
│ ├── slurm_run.sh # Multi-node MPI run script
├── LICENSE # MIT License
├── README.md # Overview
└── CONTRIBUTING.md # Contribution guidelines
```

2. **Build**

A definition file is a blueprint that tells the containerization platform how to build the container. It specifies the base OS, software packages, environment variables, and custom setup steps, ensuring your container is reproducible and tailored to your workflow.
A ready-to-use `HADDOCK3.def` is provided in the ([recipe/](https://github.com/Comp-era/HADDOCK3-Container/tree/main/recipe)) directory.

```bash
# Apptainer
apptainer build haddock3_mpi.sif haddock3_mpi.def

# Singularity
singularity build haddock3_mpi.sif haddock3_mpi.def
```

**Tip:** To create your own definition files to layer in additional packages, alternative MPI variants, Python libraries, and any domain-specific utilities.Just simply modify the `%post` section of `HADDOCK3.def` before building.

3. **Verify&Run**

- **Shell**: interactive access
```bash
apptainer shell haddock3_cpu-mpi.sif
```
- **HADDOCK3**: verify installation
```bash
apptainer shell haddock3_cpu-mpi.sif haddock3 --version
```


4. **Download a pre-built image**

You can also pull the pre-built apptainer image I created directly from GitHub’s container registry using the ORAS protocol:

```bash
apptainer pull oras://ghcr.io/comp-era/haddock3:2025.06-v1.0-haddock3-mpi
```
---

## Resources & Tutorials

- **Apptainer Installation & Usage**: Detailed installation instructions and usage examples can be found on the official docs: [apptainer.org/docs/admin/main/installation.html](https://apptainer.org/docs/admin/main/installation.html)
- **Official HADDOCK3 Tutorials**: Visit the Bonvin lab’s educational page for HADDOCK3 tutorials : [bonvinlab.org/education/HADDOCK3](https://www.bonvinlab.org/education/HADDOCK3/)
- **Source Code & Issues**: Explore the HADDOCK3 source code on GitHub: [github.com/haddocking/haddock3](https://github.com/haddocking/haddock3)

---

## Requirements

- **Host**: Linux with Apptainer or Singularity installed (local machine or HPC environment)
- **Disk**: ≥ 2 GB free for building
- **Python**: 3.10+ (inside container)

---

## Documentation

See the `docs/` folder:

- [**usage.md**](https://github.com/Comp-era/HADDOCK3-Container/blob/main/docs/usage.md) – Detailed usage and instructions to run Apptainer.

---

## Contributing

Kindly refer to [CONTRIBUTING.md](CONTRIBUTING.md) , for contributions.



---

## License

MIT License © 2025 Shantanu Khatri.

---

*Get ready for seamless reproducible workflow for HADDOCK3 runs!*

46 changes: 46 additions & 0 deletions usage-container/docs/usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
This guide explains how to run HADDOCK3 jobs either interactively or via SLURM batch submission (MPI HPC ready)
---

## Quick Start

### 1. Run Interactively with `srun`

To run HADDOCK3 in an interactive SLURM session:

#example code

srun --partition=compute \
--nodes=1 \
--ntasks-per-node=8 \
--chdir=/path/to/haddock3/examples/docking-protein-protein \
apptainer exec \
--bind /path/to/host:/path/to/host \
/path/to/haddock3_cpu-mpi.sif \
haddock3 docking-protein-protein-mpi.cfg

*Note: Change the `.cfg` file path and directory bindings to match your project location.*

---

### 2. Run as a Batch Job with `sbatch`

Submit your job to SLURM using the sample script in the `scripts/` folder:

```bash
scripts/ sbatch run_haddock3_slurm.sh
```

*Customize the script and config paths as needed.*

---




## Requirements

- SLURM-enabled HPC environment
- Docker, Apptainer or Singularity installed
- Image: `haddock-mpi-gpt.sif`
- `.cfg` configuration file for HADDOCK3

27 changes: 27 additions & 0 deletions usage-container/recipe/haddock3_mpi.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Bootstrap: docker
From: ubuntu:22.04

%labels
Maintainer Shantanu Khatri
Description "MPI-ready HADDOCK3 + mpi4py container"

%environment
export PATH=/usr/local/bin:$PATH
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/openmpi/lib:$LD_LIBRARY_PATH

%post
# Install core dependencies and MPI
apt-get update && apt-get install -y \
wget git build-essential cmake gfortran \
libfftw3-dev libxml2-dev zlib1g-dev \
openmpi-bin libopenmpi-dev \
python3 python3-pip \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Install Python packages
pip3 install --no-cache-dir --upgrade pip \
mpi4py haddock3

%runscript
echo "Welcome to the MPI-ready HADDOCK3 container."
exec "$@"
34 changes: 34 additions & 0 deletions usage-container/scripts/slurm_run._apptainer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

#SBATCH --job-name=HADDOCK3-docking
#SBATCH --output=HADDOCK3_%j.out
#SBATCH --nodes=3
#SBATCH --ntasks-per-node=120
#SBATCH --mem=256GB
#SBATCH --partition=compute

echo "Starting HADDOCK3 Docking Job"
echo "SLURM_JOBID = $SLURM_JOBID"
echo "SLURM_JOB_NODELIST = $SLURM_JOB_NODELIST"
echo "SLURM_NNODES = $SLURM_NNODES"
echo "SLURMTMPDIR = $SLURMTMPDIR"
echo "Date = $(date)"
echo "Hostname = $(hostname -s)"
echo "Working Directory = $(pwd)"
echo "Submit Directory = $SLURM_SUBMIT_DIR"

# Load necessary environment (optional depending on your setup)
source /lustre/oneApi/setvars.sh
export OMP_NUM_THREADS=1

# Run HADDOCK3 via Apptainer
cd "${WORK_DIR}"

# Ensure the working directory is set correctly
apptainer exec --bind /path/to/host/data:/path/to/container/data \
/path/to/haddock3_image.sif \
haddock3 your-docking-config.cfg


echo "HADDOCK3 Job Complete"
echo "Completed at: $(date)"
34 changes: 34 additions & 0 deletions usage-container/scripts/slurm_run_singularity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

#SBATCH --job-name=HADDOCK3-docking
#SBATCH --output=HADDOCK3_%j.out
#SBATCH --nodes=3
#SBATCH --ntasks-per-node=120
#SBATCH --mem=256GB
#SBATCH --partition=compute

echo "Starting HADDOCK3 Docking Job"
echo "SLURM_JOBID = $SLURM_JOBID"
echo "SLURM_JOB_NODELIST = $SLURM_JOB_NODELIST"
echo "SLURM_NNODES = $SLURM_NNODES"
echo "SLURMTMPDIR = $SLURMTMPDIR"
echo "Date = $(date)"
echo "Hostname = $(hostname -s)"
echo "Working Directory = $(pwd)"
echo "Submit Directory = $SLURM_SUBMIT_DIR"

# Load necessary environment (optional depending on your setup)
source /lustre/oneApi/setvars.sh
export OMP_NUM_THREADS=1

# Run HADDOCK3 via Apptainer
cd "${WORK_DIR}"

# Ensure the working directory is set correctly
singularity exec --bind /path/to/host/data:/path/to/container/data \
/path/to/haddock3_image.sif \
haddock3 your-docking-config.cfg


echo "HADDOCK3 Job Complete"
echo "Completed at: $(date)"