From 77494991a6427a89015c327f6283739c47c61fbb Mon Sep 17 00:00:00 2001 From: Dawn Date: Wed, 2 Sep 2026 09:26:34 +0200 Subject: [PATCH] update qfit to make qligand working --- qfit/README.md | 55 ++++++++++++++++++++++-------------------- qfit/build | 34 +++++++++++++++++--------- qfit/files/config.yaml | 13 +++++++++- qfit/modulefile | 6 ++--- 4 files changed, 66 insertions(+), 42 deletions(-) diff --git a/qfit/README.md b/qfit/README.md index d8eec47..13f6df7 100644 --- a/qfit/README.md +++ b/qfit/README.md @@ -2,34 +2,36 @@ qFit 3 — automated multiconformer model building for X-ray crystallography and cryo-EM (`qfit_protein`, `qfit_ligand`, -`qfit_covalent_ligand`, `edia`, ...). Repo is named `qfit-3.0`; module +`qfit_covalent_ligand`, ...). Repo is named `qfit-3.0`; module follows the name/version rule as `qfit/`. - Upstream: https://github.com/ExcitedStates/qfit-3.0 - License: MIT +## Versions + +- **2025.3** (Dec 2025) — current. Post-2024-paper qFit-ligand + (RDKit `-sm SMILES` route, `-em` flag). Python 3.12, solvers + cvxpy + pyscipopt (SCIP) declared in `install_requires` — no + extras, no CPLEX size cap. +- **3.2.2** (Aug 2022) — legacy, pre-paper qfit_ligand algorithm. + Python 3.10 (`numpy<1.22`), cvxopt + CPLEX Community Edition + pip-installed as extras. Last upstream tag with the `v` prefix — + its `urls:` is overridden per-version in `config.yaml`. + ## How it is built uv route (careless-style) from the sha-pinned GitHub tag tarball into -`$PREFIX/venv`, Python **3.10** (upstream pins `numpy<1.22`, which has -no 3.11+ wheels). The small C extension builds with the gcc/12.3.0 -module (plain C, no gcc runtime dep). Upstream quirks the recipe -handles: +`$PREFIX/venv`. The small C extension (`_extensions.c`) builds with +the gcc/12.3.0 module (plain C, no gcc runtime dep). Both eras need +`SETUPTOOLS_SCM_PRETEND_VERSION` (`use_scm_version=True` but the +tarball has no `.git`). 3.x-only quirks (solver extras, `setuptools<81` +for the runtime `pkg_resources` import) are branched on `V_PKG` in +`build`; upstream fixed both by 2024.3. -- `use_scm_version=True` but the tarball has no `.git` → - `SETUPTOOLS_SCM_PRETEND_VERSION=` is exported for the build. -- MIQP solvers are only listed in upstream's conda `environment.yml`, - not in `install_requires` → `cvxopt` and `cplex` are pip-installed - explicitly. -- `logtools.py` imports `pkg_resources` at runtime but upstream never - declares setuptools (conda/virtualenv always shipped it, uv venvs - don't) — and setuptools ≥81 removed `pkg_resources` entirely → - `setuptools<81` is pip-installed explicitly. - -**CPLEX caveat**: the pip `cplex` wheel is the IBM Community Edition, -limited to 1000 variables/constraints. Large residues/ligands may hit -the cap; the fix is a full academic CPLEX install into the venv -(https://www.ibm.com/academic/) — documented by upstream. +**CPLEX caveat (3.x only)**: the pip `cplex` wheel is the IBM Community +Edition, limited to 1000 variables/constraints. 2024.3+ uses SCIP and +has no such cap. `uv` must be on the build host (default `~/.local/bin/uv`, override with `UV=/path/to/uv`). @@ -42,16 +44,17 @@ cd qfit modbuild build \ --tmpdir=/das/work/p21/p21515/.cache/Pmodules \ --distdir=/das/work/p21/p21515/.cache/Pmodules \ - 3.2.2 -module use MX unstable && module load qfit/3.2.2 + 2025.3 +module use MX unstable && module load qfit/2025.3 ``` ## Verifying the install ```sh -which qfit_protein # -> .../qfit/3.2.2/venv/bin/qfit_protein +which qfit_protein # -> .../qfit/2025.3/venv/bin/qfit_protein qfit_protein --help # argparse usage, no traceback -"$QFIT_ENV/bin/python" -c "import qfit, cplex, cvxopt; print(qfit.__version__)" +qfit_ligand --help # should list -sm/--smiles (2024.3+) +"$QFIT_ENV/bin/python" -c "import qfit, pyscipopt, cvxpy; print(qfit.__version__)" ``` The post-refinement scripts (`qfit_final_refine_xray.sh`) call phenix: @@ -60,6 +63,6 @@ The post-refinement scripts (`qfit_final_refine_xray.sh`) call phenix: ## Adding a new version Add version + tarball sha256 in `files/config.yaml` (`sha256sum` the -downloaded `v.tar.gz`), check whether upstream unpinned -numpy/pandas (a newer pin may allow a newer venv Python), then build as -above. +downloaded `.tar.gz` — tags have no `v` prefix since 2024), check +whether upstream relaxed the numpy pin further (may allow a newer venv +Python), then build as above. diff --git a/qfit/build b/qfit/build index 22900c4..3972e99 100755 --- a/qfit/build +++ b/qfit/build @@ -1,18 +1,27 @@ #!/usr/bin/env modbuild # qFit (multiconformer model building), uv route from the sha-pinned GitHub -# tarball. Three upstream traps handled here: -# - use_scm_version needs git metadata the tarball lacks -> SETUPTOOLS_SCM_PRETEND_VERSION -# - numpy pinned <1.22 -> newest CPython with wheels is 3.10 -# - MIQP solvers (cvxopt, cplex) are only in environment.yml, not -# install_requires -> pip them explicitly or qfit dies at runtime +# tarball. Upstream traps differ by era, so both hooks branch on V_PKG: +# - 3.x (2022): numpy<1.22 caps Python at 3.10; MIQP solvers (cvxopt, cplex) +# only in environment.yml -> pip explicitly; logtools imports pkg_resources +# at runtime and uv venvs ship no setuptools -> pin setuptools<81 +# (>=81 removed pkg_resources entirely). +# - 2024.3+ : numpy relaxed to <2 -> Python 3.12; solvers switched to +# cvxpy+pyscipopt and moved into install_requires (no CPLEX size cap); +# pkg_resources import removed -> no extras needed at all. +# - both eras: use_scm_version needs git metadata the tarball lacks +# -> SETUPTOOLS_SCM_PRETEND_VERSION 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" - "$UV" venv --python 3.10 "$PREFIX/venv" || std::die 42 "uv venv failed - is uv at \$UV?" + case "$V_PKG" in + 3.*) PY=3.10 ;; # numpy<1.22 has no 3.11+ wheels + *) PY=3.12 ;; # numpy<2 -> 1.26.x wheels up to 3.12 + esac + "$UV" venv --python "$PY" "$PREFIX/venv" || std::die 42 "uv venv failed - is uv at \$UV?" } pbuild::compile() { @@ -24,13 +33,14 @@ pbuild::install() { export UV_CACHE_DIR="/opt/psi/MX/.uv-cache" export CC=gcc export SETUPTOOLS_SCM_PRETEND_VERSION="${V_PKG}" - # cplex is the IBM Community Edition pip wheel (problem-size limited); - # full CPLEX needs an academic license, see README. - # setuptools<81: qfit's logtools.py imports pkg_resources at RUNTIME; uv venvs - # don't ship setuptools, and setuptools >=81 removed pkg_resources entirely - # (verified: the 84.0.0 wheel has zero pkg_resources files, 80.9.0 has them) + local extras=() + case "$V_PKG" in + # cplex is the IBM Community Edition pip wheel (problem-size limited); + # full CPLEX needs an academic license, see README. + 3.*) extras=('setuptools<81' cvxopt cplex) ;; + esac "$UV" pip install --python "$PREFIX/venv/bin/python" \ - 'setuptools<81' cvxopt cplex "$SRC_DIR" || \ + "${extras[@]}" "$SRC_DIR" || \ std::die 42 "qfit install failed - check build log above" [[ -x "$PREFIX/venv/bin/qfit_protein" ]] || std::die 42 "qfit_protein missing from venv" } diff --git a/qfit/files/config.yaml b/qfit/files/config.yaml index 8e8c212..49d0915 100644 --- a/qfit/files/config.yaml +++ b/qfit/files/config.yaml @@ -7,14 +7,25 @@ qfit: relstage: unstable urls: # repo is named qfit-3.0 but the tool/module is qfit (name/version guardrail) - - url: https://github.com/ExcitedStates/qfit-3.0/archive/refs/tags/v${V_PKG}.tar.gz + # upstream dropped the "v" tag prefix from 2024v1 on; 3.x overrides below + - url: https://github.com/ExcitedStates/qfit-3.0/archive/refs/tags/${V_PKG}.tar.gz name: qfit-${V_PKG}.tar.gz strip_dirs: 1 shasums: qfit-3.2.2.tar.gz: b3c37a45598c31aabfb0a0024710b8e22ea6ffd49355ad69a17b93a7777e699d + qfit-2025.3.tar.gz: 40e31b49828eaeb4575e3535f0c4b93c4d82bc3cbd502f8d9f3b7bd4ff99fafa versions: 3.2.2: config: relstage: unstable # gcc for the small C extension (_extensions.c); plain C, so no runtime dep build_requires: [gcc/12.3.0] + # last release with the old "v" tag prefix + urls: + - url: https://github.com/ExcitedStates/qfit-3.0/archive/refs/tags/v${V_PKG}.tar.gz + name: qfit-${V_PKG}.tar.gz + strip_dirs: 1 + 2025.3: + config: + relstage: unstable + build_requires: [gcc/12.3.0] diff --git a/qfit/modulefile b/qfit/modulefile index 57e922a..e207ccc 100644 --- a/qfit/modulefile +++ b/qfit/modulefile @@ -6,9 +6,9 @@ module-license "MIT" module-maintainer "MX Data " module-help " -qFit 3: qfit_protein, qfit_ligand, qfit_covalent_ligand, edia and -friends, in a private Python venv with cvxopt + IBM CPLEX Community -Edition as MIQP solvers. The post-refinement scripts +qFit 3: qfit_protein, qfit_ligand, qfit_covalent_ligand and friends, +in a private Python venv. MIQP solvers: cvxopt + IBM CPLEX Community +Edition (3.x) or cvxpy + SCIP (2024.3+). The post-refinement scripts (qfit_final_refine_xray.sh) expect phenix on PATH - load a phenix module for those. "