Skip to content

Commit 984d18a

Browse files
committed
Add cf-random containers
1 parent d922387 commit 984d18a

4 files changed

Lines changed: 668 additions & 0 deletions

File tree

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Build like:
2+
# docker buildx build -t cf-random:latest -f Dockerfile --build-arg GIT_REPO=https://github.com/ncbi/CF-random_software --build-arg GIT_REF=main .
3+
4+
FROM mambaorg/micromamba:latest
5+
6+
# Re-define ARGs after FROM (ARGs before FROM are reset)
7+
ARG GIT_REPO=https://github.com/ncbi/CF-random_software
8+
ARG GIT_REF=main
9+
ARG LOCALCOLABFOLD_REPO=https://github.com/YoshitakaMo/localcolabfold
10+
ARG LOCALCOLABFOLD_REF=main
11+
LABEL org.opencontainers.image.source="${GIT_REPO}"
12+
LABEL org.opencontainers.image.title="CF-random"
13+
LABEL org.opencontainers.image.description="Predict alternative protein conformations and fold-switching proteins using AlphaFold2-based sequence association"
14+
LABEL org.opencontainers.image.version="1.0"
15+
LABEL org.opencontainers.image.authors="NCBI"
16+
LABEL org.opencontainers.image.licenses="See LICENSE.md"
17+
18+
# Install system dependencies
19+
RUN micromamba install -y -c conda-forge \
20+
wget \
21+
git \
22+
curl \
23+
ca-certificates \
24+
&& micromamba clean -a -y
25+
26+
USER root
27+
RUN apt-get update && apt-get install -y --no-install-recommends \
28+
procps \
29+
&& rm -rf /var/lib/apt/lists/*
30+
USER mambauser
31+
32+
# Set up conda environment
33+
ENV PATH="/opt/conda/bin:$PATH"
34+
ENV CONDA_DIR="/opt/conda"
35+
36+
# Create conda environment for CF-random with Python 3.10
37+
RUN micromamba create -y -p /opt/conda/envs/cf-random \
38+
python=3.10 \
39+
gxx_linux-64 \
40+
gcc_linux-64 \
41+
gfortran_linux-64 \
42+
binutils_linux-64 \
43+
openmm==8.2.0 \
44+
pdbfixer==1.10 \
45+
kalign2==2.04 \
46+
hhsuite==3.3.0 \
47+
mmseqs2 \
48+
foldseek \
49+
-c conda-forge -c bioconda \
50+
&& micromamba clean -a -y
51+
52+
# Clone LocalColabFold repository (using base shell)
53+
RUN git clone ${LOCALCOLABFOLD_REPO} /tmp/localcolabfold && \
54+
cd /tmp/localcolabfold && \
55+
git checkout ${LOCALCOLABFOLD_REF}
56+
57+
# Clone CF-random repository as mambauser
58+
USER mambauser
59+
WORKDIR /home/mambauser/app
60+
RUN git clone ${GIT_REPO} .
61+
62+
# Activate the environment for Python operations
63+
SHELL ["micromamba", "run", "-n", "cf-random", "/bin/bash", "-c"]
64+
65+
# Install ColabFold and JAX with CUDA support
66+
RUN pip install --no-warn-conflicts \
67+
"colabfold[alphafold-minus-jax] @ git+https://github.com/sokrypton/ColabFold" && \
68+
pip install "colabfold[alphafold]" && \
69+
pip install --upgrade "jax[cuda12]==0.5.3" && \
70+
pip install --upgrade tensorflow && \
71+
pip install silence_tensorflow
72+
73+
# Install CF-random Python dependencies
74+
RUN pip install \
75+
textalloc \
76+
tmtools \
77+
adjustText \
78+
thefuzz \
79+
mdtraj \
80+
biopython \
81+
seaborn \
82+
MDAnalysis \
83+
scikit-learn
84+
85+
# Install pymol-open-source from conda-forge
86+
RUN micromamba install -y -c conda-forge pymol-open-source && \
87+
micromamba clean -a -y
88+
89+
# Switch back to base shell for operations that need root permissions
90+
SHELL ["/bin/bash", "-c"]
91+
92+
# Switch to root user for creating directories
93+
USER root
94+
95+
# Copy CF-random code to /opt/cf-random for easy access
96+
RUN mkdir -p /opt/cf-random && \
97+
cp -r /home/mambauser/app/code /opt/cf-random/ && \
98+
chmod +x /opt/cf-random/code/*.py
99+
100+
# Switch to micromamba shell for Python operations
101+
USER mambauser
102+
SHELL ["micromamba", "run", "-n", "cf-random", "/bin/bash", "-c"]
103+
104+
# Modify ColabFold for non-GUI backend and suppress TensorFlow warnings
105+
RUN sed -i -e "1s#^#import matplotlib\\nmatplotlib.use('Agg')\\n#" \
106+
/opt/conda/envs/cf-random/lib/python*/site-packages/colabfold/plot.py && \
107+
sed -i -e "s#from io import StringIO#from io import StringIO\\nfrom silence_tensorflow import silence_tensorflow\\nsilence_tensorflow()#g" \
108+
/opt/conda/envs/cf-random/lib/python*/site-packages/colabfold/batch.py
109+
110+
# Modify default params directory in download.py
111+
RUN sed -i -e "s#appdirs.user_cache_dir(__package__ or \"colabfold\")#\"/opt/conda/params\"#g" \
112+
/opt/conda/envs/cf-random/lib/python*/site-packages/colabfold/download.py
113+
114+
# Remove cache directory
115+
RUN rm -rf /opt/conda/envs/cf-random/lib/python*/site-packages/colabfold/__pycache__
116+
117+
# Download AlphaFold2 weights (non-interactive)
118+
# Note: Commented out to avoid long build times. Run at runtime with:
119+
# docker run cf-random:latest python -m colabfold.download
120+
# RUN python -m colabfold.download
121+
122+
# Set environment variables
123+
ENV PATH="/opt/conda/envs/cf-random/bin:$PATH"
124+
ENV CONDA_DEFAULT_ENV="cf-random"
125+
126+
# Set working directory
127+
WORKDIR /workspace
128+
129+
# Create directories for data and databases
130+
RUN mkdir -p /workspace/data /workspace/databases /workspace/output
131+
132+
# Copy internal README.md
133+
COPY README.container.md /README.md
134+
135+
# Default command shows help
136+
CMD ["python", "/opt/cf-random/code/main.py", "--help"]
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# CF-random Docker Image
2+
3+
This Docker image provides a containerized environment for CF-random, a tool for predicting alternative protein conformations and fold-switching proteins using AlphaFold2-based sequence association.
4+
5+
## Source Information
6+
7+
**Repository**: https://github.com/ncbi/CF-random_software
8+
**Branch/Tag**: main
9+
**LocalColabFold**: https://github.com/YoshitakaMo/localcolabfold
10+
**Citation**: Lee, M., Schafer, J.W., Prabakaran, J. et al. Large-scale predictions of alternative protein conformations by AlphaFold2-based sequence association. Nat Commun 16, 5622 (2025). https://doi.org/10.1038/s41467-025-60759-5
11+
12+
## Description
13+
14+
CF-random predicts alternative conformations and fold-switching proteins by sampling AlphaFold2 predictions with different multiple sequence alignments (MSAs). It integrates LocalColabFold for structure prediction and Foldseek for database searches.
15+
16+
## Database Setup
17+
18+
The image includes Foldseek but does NOT pre-download any databases. To use the blind mode or other database-dependent features, you need to download and mount the Foldseek databases.
19+
20+
### Downloading AlphaFold2 Weights
21+
22+
The image does NOT include pre-downloaded AlphaFold2 weights. Download them at first use:
23+
24+
```bash
25+
docker run --rm -v /path/to/params:/params cf-random:latest \
26+
python -m colabfold.download
27+
```
28+
29+
Then mount the params directory when running:
30+
```bash
31+
docker run -v /path/to/params:/params cf-random:latest ...
32+
```
33+
34+
### Downloading Foldseek Databases
35+
36+
Before running the container, download the PDB database (or any other Foldseek database you need):
37+
38+
```bash
39+
# Create a directory for databases on your host
40+
mkdir -p /path/to/databases
41+
42+
# Download PDB database (this will take some time and requires ~50GB+)
43+
# Run this outside the container or mount the database directory
44+
docker run --rm -v /path/to/databases:/databases cf-random:latest \
45+
foldseek databases PDB /databases/pdb /databases/tmp
46+
```
47+
48+
Alternatively, you can download databases using foldseek directly on your host system if you have it installed, then mount the directory into the container.
49+
50+
## Usage Examples
51+
52+
### Basic Help
53+
54+
```bash
55+
docker run --rm cf-random:latest python /opt/cf-random/code/main.py --help
56+
```
57+
58+
### Fold-Switching Mode with GPU
59+
60+
Predict fold-switching proteins with reference structures:
61+
62+
```bash
63+
docker run --gpus all \
64+
-v $(pwd)/data:/workspace/data \
65+
-v $(pwd)/output:/workspace/output \
66+
-w /workspace/data \
67+
cf-random:latest \
68+
python /opt/cf-random/code/main.py \
69+
--fname 2oug_C-search/ \
70+
--pdb1 2oug_C.pdb \
71+
--pdb2 6c6s_D.pdb \
72+
--option FS
73+
```
74+
75+
### Alternative Conformation Mode
76+
77+
Predict alternative conformations:
78+
79+
```bash
80+
docker run --gpus all \
81+
-v $(pwd)/data:/workspace/data \
82+
-v $(pwd)/output:/workspace/output \
83+
-w /workspace/data \
84+
cf-random:latest \
85+
python /opt/cf-random/code/main.py \
86+
--fname 5olw_A-search \
87+
--pdb1 5olw_A.pdb \
88+
--pdb2 5olx_A.pdb \
89+
--option AC \
90+
--nMSA 5
91+
```
92+
93+
### Blind Mode with Foldseek Databases
94+
95+
For blind mode, you need to mount the Foldseek databases:
96+
97+
```bash
98+
docker run --gpus all \
99+
-v $(pwd)/data:/workspace/data \
100+
-v $(pwd)/output:/workspace/output \
101+
-v /path/to/databases:/workspace/databases \
102+
-w /workspace/data \
103+
cf-random:latest \
104+
python /opt/cf-random/code/main.py \
105+
--pname Mad2_test \
106+
--fname 2vfx_L-search/ \
107+
--option blind
108+
```
109+
110+
### Using ColabFold Directly
111+
112+
You can also use LocalColabFold directly:
113+
114+
```bash
115+
docker run --gpus all \
116+
-v $(pwd)/input:/workspace/input \
117+
-v $(pwd)/output:/workspace/output \
118+
-w /workspace \
119+
cf-random:latest \
120+
colabfold_batch \
121+
/workspace/input \
122+
/workspace/output \
123+
--model-type ptm
124+
```
125+
126+
## Volume Mounts
127+
128+
- **`/workspace/data`**: Directory for input files (MSA, PDB files, etc.)
129+
- **`/workspace/output`**: Directory for output files
130+
- **`/workspace/databases`**: Directory for Foldseek databases (if using blind mode)
131+
- **`/opt/cf-random/code`**: Directory containing CF-random Python scripts
132+
133+
## Environment Variables
134+
135+
- **`CONDA_DEFAULT_ENV=cf-random`**: The conda environment is already activated
136+
- **`PATH`**: Includes `/opt/conda/envs/cf-random/bin` where all tools are installed
137+
138+
## GPU Support
139+
140+
This image includes JAX with CUDA support. To use GPU acceleration:
141+
142+
```bash
143+
docker run --gpus all ...
144+
```
145+
146+
Make sure you have the NVIDIA Docker runtime installed and your GPU drivers are up to date (CUDA 12.1+ required).
147+
148+
## Input Requirements
149+
150+
- **MSA files**: Should be in A3M format, typically in a subdirectory (e.g., `protein-search/0.a3m`)
151+
- **PDB files**: Should have a single chain, not multiple chains
152+
- **Reference PDBs**: For default modes (FS and AC), you need reference PDB files
153+
- **range_fs_pairs_all.txt**: Required for fold-switching mode to define residue ranges
154+
155+
## Troubleshooting
156+
157+
### Out of Memory Errors
158+
159+
If you encounter GPU memory issues, try reducing the number of models or using a smaller batch size.
160+
161+
### Database Not Found
162+
163+
For blind mode, ensure you've downloaded the Foldseek databases and mounted them correctly to `/workspace/databases`.
164+
165+
### MSA Format Issues
166+
167+
Ensure your MSA files are in A3M format compatible with ColabFold.
168+
169+
## Additional Tools
170+
171+
The image also includes:
172+
- **colabfold_batch**: Main ColabFold batch prediction tool
173+
- **foldseek**: Fast and sensitive protein structure search
174+
- **kalign2**: Multiple sequence alignment tool
175+
- **mmseqs2**: Ultra-fast and sensitive sequence search
176+
- **pymol**: Molecular visualization (pymol-open-source)
177+
178+
## License
179+
180+
Please see the LICENSE.md file in the CF-random repository for licensing information.

0 commit comments

Comments
 (0)