From 1bab3e57b90030a36e73ae048e43527aa69d405d Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sun, 4 Oct 2026 12:13:43 +0200 Subject: [PATCH] Battery: refined shared-set R-free is REFMAC's own, not recomputed from the output MTZ refined_shared() recomputed R-free as sum|F - FC_ALL_LS| / sum F from REFMAC's output MTZ. That MTZ's F is not the input F: REFMAC writes it with its overall anisotropic scale applied. On strongly anisotropic data the scale multiplies the noise of the weak direction, and the recomputed R comes out far above REFMAC's own R-free over the very same reflections. 9RCS (deltaB ~250 A^2, deposit STARANISO-corrected): the recomputed shared-set R-free was 0.503 against REFMAC's own 0.368 on the same 378 free reflections (deposit 0.366/0.365), which is the whole of the +0.137 the open arm reported for this set. Across the 152 untwinned rc173 sets the two agree to a median 0.0001 and to within 0.03 everywhere else. Both refinements' free sets are the shared set by construction, so REFMAC's own R-free is the shared-set number already, as the twin branch used it. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01K5K8jvPPbmCrbqnWkddTuB --- tools/battery/README.md | 7 +++---- tools/battery/model_check.py | 20 ++++---------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/tools/battery/README.md b/tools/battery/README.md index ce514aab5..c1201ab80 100644 --- a/tools/battery/README.md +++ b/tools/battery/README.md @@ -279,10 +279,9 @@ share: - shared free set = the depositor's free reflections present in BOTH data sets (after the change of basis), which takes the lower of the two limits in every direction, anisotropic cuts and rejected reflections included; depositor free reflections outside it are removed from both; -- R-free recomputed from each output MTZ over exactly the shared set (F against FC_ALL_LS, i.e. - with REFMAC's own scale and bulk solvent, which reproduces REFMAC's R-free over its free set); - for a twinned refinement the output MTZ holds no twinned Fc, so REFMAC's own R-free is used - - its free set IS the shared set. +- R-free is REFMAC's own: each data set's free set IS the shared set. It is not recomputed from + the output MTZ, whose F carries REFMAC's anisotropic scale - on strongly anisotropic data that + scale multiplies the noise of the weak direction and the recomputed R comes out far too high. | field | meaning | |---|---| diff --git a/tools/battery/model_check.py b/tools/battery/model_check.py index fcd8bd687..cebed27d8 100644 --- a/tools/battery/model_check.py +++ b/tools/battery/model_check.py @@ -356,17 +356,6 @@ def rename_misfit_ligands(workdir, tag, xyz): return out, ", ".join(f"{k}->{v}" for k, v in new.items()) -def shared_set_r(out_mtz, shared_keys): - """R = sum|Fo - Fc| / sum Fo over the shared free reflections, from REFMAC's output MTZ (F - against FC_ALL_LS, which carries REFMAC's own scaling and bulk solvent: over REFMAC's free set - it reproduces REFMAC's R-free). Not for a twinned refinement, whose twinned Fc is not written.""" - m = gemmi.read_mtz_file(out_mtz) - fo = np.array(m.column_with_label("F"), copy=False).astype(float) - fc = np.array(m.column_with_label("FC_ALL_LS"), copy=False).astype(float) - sel = np.isin(asu_key(m.make_miller_array(), m.spacegroup), shared_keys) & np.isfinite(fo) & np.isfinite(fc) - return float(np.sum(np.abs(fo[sel] - fc[sel])) / np.sum(fo[sel])), int(sel.sum()) - - def asu_key(hkl, sg): """hkl_key of the reflections mapped into gemmi's asymmetric unit (REFMAC writes its output in its own convention, which is not always the same one).""" @@ -403,11 +392,10 @@ def refined_shared(workdir, data, dep, cell_m, sg_m, xyz, twin): xyz, out["ligands_renamed"] = renamed r = refine(workdir, tag, mtz, xyz, twin) out["refined_rwork" + suffix], out["refined_rfree_refmac" + suffix] = r - if not twin: - out["refined_rfree_shared" + suffix], out["shared_free_n_used" + suffix] = shared_set_r( - os.path.join(workdir, tag + "_out.mtz"), shared) - else: # REFMAC's own R-free is over exactly the shared set (it is these data's free set) - out["refined_rfree_shared" + suffix] = out["refined_rfree_refmac" + suffix] + # REFMAC's own R-free is over exactly the shared set: it is both data sets' free set. Not + # recomputed from the output MTZ - its F carries REFMAC's anisotropic scale, which on + # strongly anisotropic data blows up the weak direction's noise and inflates R + out["refined_rfree_shared" + suffix] = out["refined_rfree_refmac" + suffix] return {k_: (round(v, 4) if isinstance(v, float) else v) for k_, v in out.items()}