From 7759643d4cb8c42db0512dac0f7d564ca6bce019 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sun, 25 Oct 2026 01:31:35 +0200 Subject: [PATCH] rugnux --refine: refine the placed model, list its difference-map blobs, report under REFINE_ keys Opt-in. After the model's placement and everything it decides (setting, indexing, enantiomorph, MR, twin choice), the placed model is refined against the merge it was placed on (RefineModel) and the blobs of the refined mFo-DFc map are listed (FindDensityBlobs). Nothing reads the outcome: the reflection files, the space group and R_WORK/R_FREE of the model as given are those of a run without --refine. Writes _refined_model.cif/.pdb, _refined_maps.mtz (FP FC PHIC FWT PHWT DELFWT PHDELWT FOM FREE) and _blobs.json; the report's model section gains REFINE_* keys (start, placement and restrained R-factors, rmsd bonds/angles, clashes, fixed residues, weights, blob counts by kind) and the five strongest blobs. Documented in RUGNUX_MODEL_AND_REFERENCE.md and CPU_DATA_ANALYSIS.md. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu (cherry picked from commit aaee92711a205bf6a575a47c4db4555d34e7e8fe) --- docs/CPU_DATA_ANALYSIS.md | 7 ++++ docs/RUGNUX_MODEL_AND_REFERENCE.md | 17 ++++++++ rugnux/ResultReport.cpp | 64 ++++++++++++++++++++++++++++++ rugnux/Rugnux.h | 12 ++++++ rugnux/RugnuxCommandLine.cpp | 2 + rugnux/RugnuxOutputFiles.cpp | 32 +++++++++++++++ rugnux/RugnuxScaleMerge.cpp | 37 +++++++++++++++-- rugnux/rugnux_cli.cpp | 12 ++++++ 8 files changed, 180 insertions(+), 3 deletions(-) diff --git a/docs/CPU_DATA_ANALYSIS.md b/docs/CPU_DATA_ANALYSIS.md index 7189d903c..b91125dfa 100644 --- a/docs/CPU_DATA_ANALYSIS.md +++ b/docs/CPU_DATA_ANALYSIS.md @@ -18,6 +18,7 @@ This document describes the crystallographic algorithms implemented in Jungfrauj 12. auxiliary statistics (Wilson plot, ⟨I/σ(I)⟩, CC1/2, CCref), 13. amplitude estimation (French–Wilson) and R-free test-set flagging, 14. optional model-based validation: rigid-body placement of a supplied model (molecular replacement where the rigid body does not place it, or for a predicted model), R-free against it, sigma_A-weighted 2mFo−DFc / mFo−DFc electron-density maps, and an anomalous difference map with the strongest anomalous sites named. +15. optional restrained refinement of the placed model (`--refine`): rigid bodies and group B, then positions and B against a maximum-likelihood amplitude target with the dictionary's geometry, the X-ray weight chosen by R-free within geometry bounds, and the unexplained blobs of the refined difference map. The reference is split into four parts, in pipeline order; the section numbers run continuously @@ -59,6 +60,12 @@ The methods draw on, and in places reimplement, solutions from: - P. H. C. Eilers, "A perfect smoother", *Anal. Chem.* **75** (2003), 3631-3636, after E. T. Whittaker, "On a new method of graduation", *Proc. Edinburgh Math. Soc.* **41** (1923), 63-75 (the penalised smoother of the fulls' per-frame scale, §10.6). - H. F. Walker & P. Ni, "Anderson acceleration for fixed-point iterations", *SIAM J. Numer. Anal.* **49** (2011), 1715-1735, after D. G. Anderson, "Iterative procedures for nonlinear integral equations", *J. ACM* **12** (1965), 547-560 (the acceleration of the per-frame scaling loops, §10.6). - R. A. Fisher, "Frequency distribution of the values of the correlation coefficient in samples from an indefinitely large population", *Biometrika* **10** (1915), 507-521 (the z-transformation on which the correction surfaces' held-out half-set CC1/2 is compared). +- R. C. Agarwal, "A new least-squares refinement technique based on the fast Fourier transform algorithm", *Acta Cryst.* **A34** (1978), 791-809 (the gradient of the refinement target, §15). +- N. S. Pannu & R. J. Read, "Improved structure refinement through maximum likelihood", *Acta Cryst.* **A52** (1996), 659-668, and G. N. Murshudov, A. A. Vagin & E. J. Dodson, *Acta Cryst.* **D53** (1997), 240-255 (the maximum-likelihood amplitude target and the B restraints, §15). +- V. Y. Lunin & T. P. Skovoroda, *Acta Cryst.* **A51** (1995), 880-887 (the likelihood parameters from the free set, §15). +- A. A. Vagin et al., "REFMAC5 dictionary: organization of prior chemical knowledge and guidelines for its use", *Acta Cryst.* **D60** (2004), 2184-2195 (the restraint dictionary, §15). +- P. V. Afonine et al., "Towards automated crystallographic structure refinement with phenix.refine", *Acta Cryst.* **D68** (2012), 352-367 (the weight chosen among refinements by R-free, §15). +- D. C. Liu & J. Nocedal, "On the limited memory BFGS method for large scale optimization", *Math. Program.* **45** (1989), 503-528 (the minimiser, §15). - M. Wojdyr, "GEMMI: A library for structural biology", *J. Open Source Softw.* **7** (2022), 4200 (model / structure-factor / map machinery used in §14). - J. P. Wright, "Experiences with GPU decompression for bitshuffle + LZ4 data", HDF5 User Group meeting (2021), and [github.com/jonwright/bslz4decoders](https://github.com/jonwright/bslz4decoders) (device-side decoding of bitshuffle+LZ4 images, §0). - A. Thorn & G. M. Sheldrick, "ANODE: anomalous and heavy-atom density calculation", *J. Appl. Cryst.* **44** (2011), 1285-1287 (anomalous difference density read at the model's sites). diff --git a/docs/RUGNUX_MODEL_AND_REFERENCE.md b/docs/RUGNUX_MODEL_AND_REFERENCE.md index 65b32d536..5a6f51a25 100644 --- a/docs/RUGNUX_MODEL_AND_REFERENCE.md +++ b/docs/RUGNUX_MODEL_AND_REFERENCE.md @@ -44,6 +44,7 @@ the rest walks through a run step by step. | *(none)* | — | Everything from the data | — | | `--model ` | An atomic model, PDB or mmCIF, gzipped or not, recognised by content: an experimental structure or a prediction | Validation after the merge (R-work/R-free, CC(model, data), maps, the placed model); a rigid-body placement checked against a null, with molecular replacement where the rigid body does not place it, and straight away for a prediction | Labels only (hand, indexing, axes), and only where the model fits. Other space groups → `_mr.*` | | `--mr ` | The same kinds of model | As `--model`, but molecular replacement straight away, without the rigid body. `--mode mx` only, not together with `--model` | Hand label only. Other space groups → `_mr.*` | +| `--refine` | Nothing more (with `--model` or `--mr`) | Refines the placed model against the merge it was placed on - each chain as a rigid body and a B per residue, then every atom's position (and, where R-free says so, its B) restrained by the dictionary carried in rugnux, against a maximum-likelihood target - and lists the unexplained blobs of its difference map. Writes `_refined_model.cif`, `_refined_maps.mtz`, `_blobs.json`; reported under `REFINE_` keys | No - it runs after everything is decided and decides nothing | | PAE file beside a prediction | `AF--F1-predicted_aligned_error_v.json` next to `AF--F1-model_v.cif` (read automatically, no option) | Cuts the prediction into rigid domains for molecular replacement | No (a domain alone can only confirm the answer's group) | | `-z, --reference ` (`--reference-mtz`) | Merged data of the same crystal form: an MTZ, or a PDB structure-factor mmCIF (`-sf.cif`) | Fixes the space group (in its own setting) and the cell (softly), puts the merge on its axes, resolves the indexing ambiguity, hands over its R-free set, reports CCref on stills. Never a scale anchor | **Yes**: the space group, the axes, the indexing and the free set are the reference's | | `--reference-column