From e01e9ad643983aa05d57a6232468402b63510653 Mon Sep 17 00:00:00 2001 From: John LaGrone Date: Tue, 22 Sep 2026 11:27:08 -0500 Subject: [PATCH 1/3] add container for alphafold3 --- containers/alphafold3/alphafold3.def | 69 +++++++++++++++++++ .../alphafold3/jackhmmer_seq_limit.patch | 32 +++++++++ 2 files changed, 101 insertions(+) create mode 100644 containers/alphafold3/alphafold3.def create mode 100644 containers/alphafold3/jackhmmer_seq_limit.patch diff --git a/containers/alphafold3/alphafold3.def b/containers/alphafold3/alphafold3.def new file mode 100644 index 00000000..0a9cf7ff --- /dev/null +++ b/containers/alphafold3/alphafold3.def @@ -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 + Version 1.0 + Framework AlphaFold + Distribution Ubuntu 22.04 + Application AlphaFold 3 + +%apprun run_alphafold.py + exec uv run python3 run_alphafold.py "${@}" + +%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 diff --git a/containers/alphafold3/jackhmmer_seq_limit.patch b/containers/alphafold3/jackhmmer_seq_limit.patch new file mode 100644 index 00000000..9249a1f6 --- /dev/null +++ b/containers/alphafold3/jackhmmer_seq_limit.patch @@ -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"); From 1579a2a3b0fcb5ae9324a696b81594a6b07e19f2 Mon Sep 17 00:00:00 2001 From: John LaGrone Date: Wed, 23 Sep 2026 11:09:59 -0500 Subject: [PATCH 2/3] modify container def --- containers/alphafold3/alphafold3.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/containers/alphafold3/alphafold3.def b/containers/alphafold3/alphafold3.def index 0a9cf7ff..7b62e7bd 100644 --- a/containers/alphafold3/alphafold3.def +++ b/containers/alphafold3/alphafold3.def @@ -10,7 +10,7 @@ From: nvidia/cuda:12.6.3-base-ubuntu24.04 Application AlphaFold 3 %apprun run_alphafold.py - exec uv run python3 run_alphafold.py "${@}" + exec uv run python3 /app/alphafold/run_alphafold.py --model_dir=/models --db_dir=/public_databases "${@}" %files jackhmmer_seq_limit.patch From 91e5884552ba087c9fb5dd90d1afd1c8c99cd290 Mon Sep 17 00:00:00 2001 From: John LaGrone Date: Tue, 29 Sep 2026 10:51:08 -0500 Subject: [PATCH 3/3] add alphafold module --- modules/mp/apps/alphafold/3.0.4.lua | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 modules/mp/apps/alphafold/3.0.4.lua diff --git a/modules/mp/apps/alphafold/3.0.4.lua b/modules/mp/apps/alphafold/3.0.4.lua new file mode 100644 index 00000000..1e665ae0 --- /dev/null +++ b/modules/mp/apps/alphafold/3.0.4.lua @@ -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")