From 4ffc1b152dda7af756965ac4fbb3a057c8a1bf2b Mon Sep 17 00:00:00 2001 From: Dawn Date: Mon, 24 Aug 2026 20:43:11 +0200 Subject: [PATCH] PanDDA2 1.0.0: new module, uv venv from sha-pinned xchem/PanDDA2 Separate module from PanDDA (different library): self-contained python 3.9 venv (torch==1.13.1 caps at py3.10), torch from the pytorch CPU wheel index, ~1 GB of CNN scoring models pre-fetched at build time because the package dir is read-only for users under /opt/psi. ccp4/9.0 runtime dep only, for pandda.inspect / pandda.export. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_0152MuuYUaapP7CtxrDAfvBh --- PanDDA2/README.md | 28 +++++++++++++++++++++ PanDDA2/build | 51 +++++++++++++++++++++++++++++++++++++++ PanDDA2/files/config.yaml | 13 ++++++++++ PanDDA2/modulefile | 16 ++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 PanDDA2/README.md create mode 100644 PanDDA2/build create mode 100644 PanDDA2/files/config.yaml create mode 100644 PanDDA2/modulefile diff --git a/PanDDA2/README.md b/PanDDA2/README.md new file mode 100644 index 0000000..55eb769 --- /dev/null +++ b/PanDDA2/README.md @@ -0,0 +1,28 @@ +# PanDDA2 + +PanDDA 2 (`pandda_2_gemmi`) — multi-dataset density analysis for fragment +screening. + +Not on PyPI: installed with uv into a self-contained python 3.9 venv from a +sha-pinned commit of xchem/PanDDA2 master (no usable release tags upstream; +module version 1.0.0 follows the README's announced version — bump the sha in +`build` to update). Torch comes from the pytorch CPU wheel index to avoid the +~2 GB CUDA build. + +The ~1 GB of CNN scoring models that PanDDA2 normally gdown-fetches on first +run are downloaded at build time into the installed package dir, because that +dir is read-only for users under /opt/psi. If Ra blocks Google Drive, download +the 5 files by hand (ids in `build`) and copy them into the dir named in the +die message. + +ccp4/9.0 is a runtime dependency (auto-loaded) for `pandda.inspect` / +`pandda.export`. The build needs no ccp4 — the venv is self-contained. +Upstream README claims inspect/export "do not function correctly" outside +ccp4/7.0.067; verify with 9.0 before trusting exports. + +Verify after load: + +```bash +pandda2.analyse --help +$PANDDA2_ENV/bin/python -c 'from pandda_gemmi.cnn import LitEventScoring' +``` diff --git a/PanDDA2/build b/PanDDA2/build new file mode 100644 index 0000000..72f6ec8 --- /dev/null +++ b/PanDDA2/build @@ -0,0 +1,51 @@ +#!/usr/bin/env modbuild + +pbuild::prep() { + : +} + +pbuild::configure() { + # modbuild's shell strips ~/.local/bin from PATH; override with UV=/path/to/uv if needed + UV="${UV:-$HOME/.local/bin/uv}" + export UV_CACHE_DIR="/opt/psi/MX/.uv-cache" + export UV_PYTHON_INSTALL_DIR="$PREFIX/python" + # python 3.9: PanDDA2's torch==1.13.1 pin has no wheels past 3.10, README targets 3.9 + "$UV" venv --python 3.9 "$PREFIX/venv" || \ + std::die 42 "PanDDA2: uv venv failed — is uv at \$UV?" +} + +pbuild::compile() { + : +} + +pbuild::install() { + UV="${UV:-$HOME/.local/bin/uv}" + export UV_CACHE_DIR="/opt/psi/MX/.uv-cache" + + # xchem/PanDDA2 master @ 2026-08-18, pinned for reproducibility — the repo + # has no usable release tags (only 'alpha'). Bump sha to update. + local -r sha=d513af6d8c49b602d4fd91c084fe62b7fb19da8e + # cpu extra-index: plain torch==1.13.1 from PyPI drags the ~2 GB CUDA build; + # the project's own [tool.uv.pip] cpu index only applies inside its repo dir + "$UV" pip install --python "$PREFIX/venv/bin/python" \ + --extra-index-url https://download.pytorch.org/whl/cpu \ + "pandda_2_gemmi @ git+https://github.com/xchem/PanDDA2.git@${sha}" || \ + std::die 42 "PanDDA2: uv pip install from GitHub failed" + + # First run gdown-fetches ~1 GB of CNN scoring models NEXT TO THE INSTALLED + # CODE (pandda_gemmi/pandda/get_scoring_models.py) — read-only for users + # under /opt/psi, so fetch them now into the exact dir the code checks. + local cnn_dir + cnn_dir=$("$PREFIX/venv/bin/python" -c 'import os, inspect; from pandda_gemmi.cnn import LitEventScoring; print(os.path.dirname(inspect.getfile(LitEventScoring)))') || \ + std::die 42 "PanDDA2: import pandda_gemmi.cnn failed — install is broken" + local -r GD="$PREFIX/venv/bin/gdown" + "$GD" 1b58MUIJdIYyYHr-UhASVCvIWtIgrLYtV -O "$cnn_dir/model_event.ckpt" && \ + "$GD" 1qyPqPylOguzXmt6XSFaXCKrnvb8gZ8E2 -O "$cnn_dir/model_event_config.yaml" && \ + "$GD" 15RnkrGtEmFvtBvIlwfaUE1QfQrD2npnu -O "$cnn_dir/event_score_quantiles.csv" && \ + "$GD" 17ow_rxuEvi0LitMP_jTWGMSDt-FfJCkR -O "$cnn_dir/model_build.ckpt" && \ + "$GD" 1HEXHZ6kfh92lQoWBHalGbUJ-iCsOIkFo -O "$cnn_dir/model_build_config.yaml" || \ + std::die 42 "PanDDA2: model fetch from Google Drive failed (blocked or quota) — download the 5 files by hand and copy them into ${cnn_dir}" + + [[ -x "$PREFIX/venv/bin/pandda2.analyse" ]] || \ + std::die 42 "PanDDA2: venv/bin/pandda2.analyse missing — install incomplete" +} diff --git a/PanDDA2/files/config.yaml b/PanDDA2/files/config.yaml new file mode 100644 index 0000000..947c3c9 --- /dev/null +++ b/PanDDA2/files/config.yaml @@ -0,0 +1,13 @@ +--- +format: 1 +PanDDA2: + defaults: + group: MX + overlay: base + relstage: unstable + # no urls/shasums — uv pip installs from a sha-pinned GitHub URL (see build) + versions: + 1.0.0: + config: + relstage: unstable + runtime_deps: [ccp4/9.0] diff --git a/PanDDA2/modulefile b/PanDDA2/modulefile new file mode 100644 index 0000000..779fe14 --- /dev/null +++ b/PanDDA2/modulefile @@ -0,0 +1,16 @@ +#%Module1.0 + +module-whatis "PanDDA 2: multi-dataset density analysis for fragment screening (pandda2.analyse)" +module-url "https://github.com/xchem/PanDDA2" +module-license "Apache-2.0" +module-maintainer "Jiaxin Duan " + +module-help " +PanDDA 2 (pandda_2_gemmi) in a self-contained python 3.9 venv, CNN scoring +models pre-downloaded at build time. ccp4/9.0 is auto-loaded as a runtime +dependency for pandda.inspect / pandda.export. +Main entry point: pandda2.analyse +" + +setenv PANDDA2_ENV $PREFIX/venv +prepend-path PATH $PREFIX/venv/bin