Commit Graph
3 Commits
Author SHA1 Message Date
leonarski_fandClaude Opus 4.8 386f345758 rugnux: probe indexing ambiguities against the model in validation
ModelValidation now fits the scaled model to each reindexing of the observed
reflections (identity plus the twin laws from ReindexAmbiguityOperators) and
keeps the one with the lowest R-free. The scale + per-shell + R computation is
factored into a per-candidate lambda so every candidate is scored identically.

No-op for a holohedral crystal (no twin laws), e.g. lysozyme, where the only
candidate is the identity. The enantiomorph/screw ambiguity is still resolved
from the model hand, not probed - |Fcalc| is the same for both hands so R-free
cannot distinguish them.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 08:20:27 +02:00
leonarski_fandClaude Opus 4.8 e91b520863 rugnux: fix SG/cell from a reference MTZ, and reindex data into the model's enantiomorph
Two ways the processing now adopts symmetry from an external reference:

- Reference MTZ (-z) fixes the space group and unit cell, unless -S / -C override them
  (the explicit flag always wins - so -S with the "wrong" enantiomorph is allowed). The cell
  is a soft reference: indexing may still drift within tolerance, as with -C.

- rugnux --model: when the data was merged in the enantiomorph of the model's space group
  (e.g. data P4(1)2(1)2, model P4(3)2(1)2 - the merged intensities cannot tell them apart),
  ValidateAgainstModel reindexes the observed reflections into the model's hand (via gemmi
  change_of_hand_op). This keeps the data setting consistent with the model; it does not change
  the R-factors, which use |F|.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 22:30:33 +02:00
leonarski_fandClaude Opus 4.8 d6924aa901 rugnux: add --model for R-free and 2Fo-Fc / Fo-Fc maps from an atomic model
New offline capability: `rugnux --model model.pdb` validates the merged intensities
against a PDB model. It computes structure factors from the model on a grid (IT92 x-ray
form factors, FFT), adds an optimized flat bulk solvent (SolventMasker + gemmi Scaling:
k_sol, b_sol, overall k and anisotropic B) and a per-resolution-shell scale, then reports
R-work / R-free and writes 2Fo-Fc and Fo-Fc CCP4 maps plus a map-coefficient MTZ
(FP, FC, PHIC, FWT/PHWT, DELFWT/PHDELWT, FREE). No refinement of the structure itself;
the model is only re-fractionalized into the data cell (a rigid cell adjustment).

The observed amplitudes are the French-Wilson |F| already on the merged reflections
(MergedReflection.F, computed at end of merge), so the R-free/maps use exactly the same
amplitudes as the written reflection file.

ModelValidation.{h,cpp} holds the logic; wired via --model (ProcessConfig.model_path) into
both the full pipeline (Rugnux::Run write site) and the --scale re-merge path. Links the
unified `gemmi` static target for the model / structure-factor / map headers.

Verified on lyso_ref: R-free 0.346, mean 2Fo-Fc at atom centres +2.16 sigma, maps written.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 21:27:44 +02:00