From 29b5d7cce15a4c0fa13230ca5565d398c653ce82 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Mon, 21 Sep 2026 08:14:52 +0200 Subject: [PATCH] tools/battery: every set runs bare, and an anomalous reference reads the per-hand table The XDS arms passed -A wherever the reference had been measured with FRIEDEL'S_LAW=FALSE, so that the merging statistics would be comparable. That reason is gone: a rotation run decides with Friedel's mates merged whatever -A says, and now reports itself counted both ways out of that one run, so -A is presentation only and passing it changes nothing a battery reads. Verified on a 6 keV set: the reflections, the MTZ and the mmCIF of an -A run are byte-identical to a bare one, and the reports differ in the FRIEDELS_LAW line alone. Comparability now comes from the report instead. Where a reference kept the mates apart, the scorer takes uniques, completeness, multiplicity, , R_meas and CC1/2 from the run's ANOM_REFRES_* block - the same merge counted per Bijvoet hand, which is how XDS counted. ISa is not among them: there is one error model, it is fitted on the hands, and REFRES_ISA is it. The report reader also learns the third shell table, so it stops taking the per-hand table's first row for the reference range's low-resolution shell. Re-scored on six sets. The anomalous rows stop comparing a Friedel-merged multiplicity against a per-hand one (28.65 against XDS's 12.42 becomes 15.54; 19.69 against 8.85 becomes 11.09), completeness moves 1-2 points onto the reference's own footing, R_meas ratios move a few percent and the CC1/2 noise ratio rises, as it must when CC1/2 is read at the reference's multiplicity. No verdict moves: pass and fail are decided on the lattice, the space group and the resolution, none of which these numbers reach. The two non-anomalous rows score exactly as before. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_013nW6FNRP1bBJJ8pfHiByAT --- tools/battery/battery.py | 15 ++++++++------- tools/battery/score.py | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/tools/battery/battery.py b/tools/battery/battery.py index 72ed37663..84c75a0d7 100644 --- a/tools/battery/battery.py +++ b/tools/battery/battery.py @@ -26,7 +26,7 @@ The site config (data roots, runs root, lock, gpulock, private manifest, baselin $JFJOCH_BATTERY_SITE, else site.json beside this script (not committed; site.example.json is). Every set runs once, with one command per arm (COMMAND_DOC): the open arm with the deposited model -(--model), the XDS arms with -A where XDS was anomalous and XDS's range as a report-only second +(--model), the XDS arms with XDS's range as a report-only second table (--report-resolution). Neither option changes the processing, so the one run is both what a user gets and the like-for-like comparison. @@ -68,8 +68,9 @@ PDB_ID = re.compile(r"^[0-9][A-Za-z0-9]{3}$") COMMAND_DOC = { "deposition": "`rugnux --model ` (without --model where there is no " "deposited model: small molecules, unpublished sets)", - "xds": "`rugnux [-A] --report-resolution , `: -A where XDS kept " - "Friedel mates apart; the second statistics table at XDS's range is report-only", + "xds": "`rugnux --report-resolution , `: the second statistics " + "table at XDS's range is report-only; where XDS kept Friedel mates apart the scorer " + "reads the run's own per-hand table, which needs no flag", } LOCAL_SITE = os.path.join(HERE, "site.json") @@ -174,10 +175,10 @@ def command(binary, e, opts, model=None): cmd += ["-N", str(opts["threads"])] ref = e.get("ref") or {} if e["reference"] == "xds": - # XDS merged with FRIEDEL'S_LAW=FALSE: merge Friedel mates separately too, or the merging - # statistics are not comparable - if ref.get("anomalous"): - cmd.append("-A") + # No -A, whatever the reference did. A rotation run decides with Friedel's mates merged + # either way, and reports the merge counted BOTH ways from that one run; -A only says which + # of the two tables was asked for. Where XDS merged with FRIEDEL'S_LAW=FALSE the scorer + # reads rugnux's per-hand block (ANOM_REFRES_*) instead, which is the like-for-like table. # a second statistics table over XDS's own range, from the same merge (report only). XDS's # own limit, not the derived reference d_min: the manifest's XDS totals are over XDS's range, # so only that makes the table like for like. Shells past rugnux's own cut print as not diff --git a/tools/battery/score.py b/tools/battery/score.py index 6d213c039..8742d1bab 100644 --- a/tools/battery/score.py +++ b/tools/battery/score.py @@ -38,7 +38,10 @@ def read_report(path): if f[:2] == ["d_min", "N_obs"]: header = f elif header and f and re.match(r"^\d+\.\d+$", f[0]): - prefix = "REFRES_" if "REFRES_RANGE" in out else "" + # Three tables in report order: the run's own, the --report-resolution one, and the + # per-hand (FRIEDEL'S_LAW=FALSE) one, whose keys are written just above it. + prefix = ("ANOM_" if "ANOM_UNIQUE_REFLECTIONS" in out + else "REFRES_" if "REFRES_RANGE" in out else "") out[prefix + "LOWRES_D"] = f[0] r_meas = f[header.index("R_meas")].rstrip("%") # "3.7%", or "-" for none out[prefix + "LOWRES_R_MEAS"] = "" if r_meas == "-" else str(round(float(r_meas) / 100, 4)) @@ -199,6 +202,20 @@ def judge(entry, rep, run_note): # the same merge binned over the reference's range (--report-resolution, XDS arms) r.update({k: fnum(rep.get(k.upper())) for k in REFRES_KEYS}) r["refres_range"] = rep.get("REFRES_RANGE") + # An XDS reference measured with FRIEDEL'S_LAW=FALSE counts its uniques, completeness, + # multiplicity, R_meas and CC1/2 per Bijvoet hand, so what is like for like is the per-hand + # table of the same rugnux merge - the Friedel-merged one has about twice the multiplicity. + # Both tables come out of one bare run: -A is presentation only and changes nothing that is + # compared here. ISa is not among them - there is one error model, fitted on the hands, and + # REFRES_ISA is it. + r["per_hand_reference"] = False + if ref.get("anomalous"): + for k in ("unique_reflections", "completeness", "multiplicity", "i_over_sigma", + "r_meas", "cc_half"): + v = fnum(rep.get("ANOM_REFRES_" + k.upper())) + if v is not None: + r["refres_" + k] = v + r["per_hand_reference"] = True r["isa_ratio"] = round(r["refres_isa"] / r["isa_ref"], 4) if r["refres_isa"] and r["isa_ref"] else None r["r_meas_ratio"] = (round(r["refres_r_meas"] / r["r_meas_ref"], 4) if r["refres_r_meas"] and r["r_meas_ref"] else None)