Skip to content
Merged
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
69 changes: 69 additions & 0 deletions containers/alphafold3/alphafold3.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Bootstrap: docker
From: nvidia/cuda:12.6.3-base-ubuntu24.04

# based on https://github.com/google-deepmind/alphafold3/blob/main/docker/Dockerfile
%labels
Author John LaGrone <jlagrone@smu.edu>
Version 1.0
Framework AlphaFold
Distribution Ubuntu 22.04
Application AlphaFold 3

%apprun run_alphafold.py
exec uv run python3 /app/alphafold/run_alphafold.py --model_dir=/models --db_dir=/public_databases "${@}"

%files
jackhmmer_seq_limit.patch

%post
ALPHAFOLD_TAG="v3.0.4"
DEBIAN_FRONTEND=noninteractive \
apt-get update --quiet \
&& apt-get install --yes --quiet python3.12 python3.12-dev \
&& apt-get install --yes --quiet git wget gcc g++ make zlib1g-dev zstd curl ca-certificates

curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="/root/.local/bin:$PATH"

export UV_COMPILE_BYTECODE=1
export UV_PROJECT_ENVIRONMENT=/alphafold3_venv
PATH="/hmmer/bin:/alphafold3_venv/bin:$PATH"

export PATH="/hmmer/bin:/alphafold3_venv/bin:$PATH"

mkdir /hmmer_build /hmmer ; \
wget http://eddylab.org/software/hmmer/hmmer-3.4.tar.gz --directory-prefix /hmmer_build ; \
cd /hmmer_build && echo "ca70d94fd0cf271bd7063423aabb116d42de533117343a9b27a65c17ff06fbf3 hmmer-3.4.tar.gz" | sha256sum --check && \
cd /hmmer_build && tar zxf hmmer-3.4.tar.gz && rm hmmer-3.4.tar.gz

cd /hmmer_build && patch -p0 < /jackhmmer_seq_limit.patch

cd /hmmer_build/hmmer-3.4 && ./configure --prefix /hmmer && \
cd /hmmer_build/hmmer-3.4 && make -j && \
cd /hmmer_build/hmmer-3.4 && make install && \
cd /hmmer_build/hmmer-3.4/easel && make install && \
rm -R /hmmer_build && \
cd

git clone https://github.com/google-deepmind/alphafold3.git && \
cd alphafold3 && \
git checkout ${ALPHAFOLD_TAG} && \
cd && \
mkdir -p /app && \
mv alphafold3 /app/alphafold && \
cd /app/alphafold && \
UV_LINK_MODE=copy uv sync --frozen --all-groups --no-editable

cd /app/alphafold && \
uv run build_data



%environment
export PATH="/root/.local/bin:$PATH"
export UV_COMPILE_BYTECODE=1
export UV_PROJECT_ENVIRONMENT=/alphafold3_venv
export PATH="/hmmer/bin:/alphafold3_venv/bin:$PATH"
export XLA_FLAGS="--xla_gpu_enable_triton_gemm=false"
export XLA_PYTHON_CLIENT_PREALLOCATE=true
export XLA_CLIENT_MEM_FRACTION=0.95
32 changes: 32 additions & 0 deletions containers/alphafold3/jackhmmer_seq_limit.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--- hmmer-3.4/src/jackhmmer.c
+++ hmmer-3.4/src/jackhmmer.c
@@ -73,6 +73,7 @@ static ESL_OPTIONS options[] = {
{ "--noali", eslARG_NONE, FALSE, NULL, NULL, NULL, NULL, NULL, "don't output alignments, so output is smaller", 2 },
{ "--notextw", eslARG_NONE, NULL, NULL, NULL, NULL, NULL, "--textw", "unlimit ASCII text output line width", 2 },
{ "--textw", eslARG_INT, "120", NULL, "n>=120", NULL, NULL, "--notextw", "set max width of ASCII text output lines", 2 },
+ { "--seq_limit", eslARG_INT, NULL, NULL, NULL, NULL, NULL, "--seq_limit", "if set, truncate all hits after this value is reached", 2 },
/* Control of scoring system */
{ "--popen", eslARG_REAL, "0.02", NULL, "0<=x<0.5",NULL, NULL, NULL, "gap open probability", 3 },
{ "--pextend", eslARG_REAL, "0.4", NULL, "0<=x<1", NULL, NULL, NULL, "gap extend probability", 3 },
@@ -298,6 +299,7 @@ output_header(FILE *ofp, ESL_GETOPTS *go
if (esl_opt_IsUsed(go, "--noali") && fprintf(ofp, "# show alignments in output: no\n") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed");
if (esl_opt_IsUsed(go, "--notextw") && fprintf(ofp, "# max ASCII text line length: unlimited\n") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed");
if (esl_opt_IsUsed(go, "--textw") && fprintf(ofp, "# max ASCII text line length: %d\n", esl_opt_GetInteger(go, "--textw")) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed");
+ if (esl_opt_IsUsed(go, "--seq_limit") && fprintf(ofp, "# set max sequence hits to return: %d\n", esl_opt_GetInteger(go, "--seq_limit")) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed");
if (esl_opt_IsUsed(go, "--popen") && fprintf(ofp, "# gap open probability: %f\n", esl_opt_GetReal (go, "--popen")) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed");
if (esl_opt_IsUsed(go, "--pextend") && fprintf(ofp, "# gap extend probability: %f\n", esl_opt_GetReal (go, "--pextend")) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed");
if (esl_opt_IsUsed(go, "--mx") && fprintf(ofp, "# subst score matrix (built-in): %s\n", esl_opt_GetString (go, "--mx")) < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed");
@@ -674,6 +676,13 @@ serial_master(ESL_GETOPTS *go, struct cf
/* Print the results. */
p7_tophits_SortBySortkey(info->th);
p7_tophits_Threshold(info->th, info->pli);
+ /* Limit the number of hits if specified. */
+ if (esl_opt_IsOn(go, "--seq_limit"))
+ {
+ int seq_limit = esl_opt_GetInteger(go, "--seq_limit");
+ info->th->N = ESL_MIN(info->th->N, seq_limit);
+ }
+
p7_tophits_CompareRanking(info->th, kh, &nnew_targets);
p7_tophits_Targets(ofp, info->th, info->pli, textw); if (fprintf(ofp, "\n\n") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed");
p7_tophits_Domains(ofp, info->th, info->pli, textw); if (fprintf(ofp, "\n\n") < 0) ESL_EXCEPTION_SYS(eslEWRITE, "write failed");
42 changes: 42 additions & 0 deletions modules/mp/apps/alphafold/3.0.4.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
whatis("AlphaFold3")
family("alphafold")

help([[Name: AlphaFold3
Version: 3.0.4
Website: https://github.com/google-deepmind/alphafold3
License Owners :

AlphaFold 3 is an advanced artificial intelligence model created by Google DeepMind and Isomorphic Labs that predicts the 3D structures and interactions of all of life's major molecules, going far beyond just proteins.
]])

LmodMessage('Terms of Use:')
LmodMessage('https://github.com/google-deepmind/alphafold3/blob/main/WEIGHTS_TERMS_OF_USE.md')
LmodMessage('')
LmodMessage('Usage:')
LmodMessage("run_alphafold.py --json_path=/path/to/fold_input.json --output_dir=/path/to/af_output")
LmodMessage('')
LmodMessage('Do not set the model_dir or database directory options. These are already set to minimize system load.')

local jobid = os.getenv("SLURM_JOB_ID") or ""

if (jobid == nil or jobid == "") then
LmodBreak("\nRunning AlphaFold outside of a job is not permitted. Please submit a job.\n")
end

always_load('apptainer')
local container_path="/hpc/m3/containers/alphafold3.sif"
local flags="--nv -B /hpc/mp/apps/alphafold/alphafold3_models/:/models --mount type=bind,src=/raid/local/datasets/alphafold3_dbs.squashfs,dst=/public_databases,ro,image-src=/ --app"

setenv("APPTAINERENV_JAX_PLATFORMS", "cuda")

function build_command(app, appname)
local app_command = pathJoin(app_path, app)
local cmd = 'apptainer run ' .. flags .. ' ' .. appname .. ' ' .. container_path
local sh_ending = ' "$@"'
local csh_ending = ' $*'
local sh_cmd = cmd .. sh_ending
local csh_cmd = cmd .. csh_ending
set_shell_function(app, sh_cmd, csh_cmd)
end

build_command("run_alphafold.py", "run_alphafold.py")
Loading