battery: SHELXL at the reference's d_min, and three reference fixes

The SHELXL check also refines the published structure against the reflections inside the
reference's range (XDS's own limit on the XDS arms, the deposition's on the open arm), as
shx_ref_r1 / shx_ref_wr2 / shx_ref_fixed_r1. On a high-R_meas cubic set, 41 low-multiplicity
reflections in the detector corners past XDS's limit moved R1 from 0.090 to 0.105: an R1 at a
finer cut than the reference's is not a comparison of data quality.

The reference d_min rule no longer reads shells of two unique reflections. XDS prints CC1/2 0.0
for them (a correlation over two points is +-1 whatever the data), and on a tiny cubic cell whose
shells hold two to four reflections that put the reference at 1.86 A on data XDS merged to 0.78 A.

A set may name a redone CORRECT.LP (ref_lp, with ref_lp_why), which `refs` reads instead of the
one beside the data. One in-house small-molecule reference had been integrated with the overload
limit at half the detector's range and is replaced by a full re-run.

One open-arm small molecule without a deposition was scored against a different crystal's
published cell, 0.35% from the cell its own images give; it is now scored against the cell xia2
refines on the dataset itself (ref_override).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVeDQpv3w9JdZswRqKUW2H
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-11-22 11:45:48 +01:00
1 parent 50a1a3c846
commit a92d85f2ae
7 files changed
+77 -25

No files matched your search

+13 -1
View File
@@ -671,6 +671,12 @@ weights; a near SHELXL's 0.2 ceiling means sigmas or strong reflections are off)
`shx_hole` (residual density, e/A^3), `shx_rint`/`shx_rsigma` (as SHELXL prints them; R(int) only
means something for unmerged data), `shx_k_top` (<Fo2>/<Fc2> of the strongest analysis-of-variance
bin; below 1: strong reflections read low), `shx_fixed_r1`, `shx_cod`, `shx_status`, `shx_reason`.
Where the data reach past the reference's d_min (XDS's own limit `dmin_xds` on the XDS arms, the
deposition's `dmin` on the open arm), the final refinement is repeated on the reflections inside it:
`shx_ref_dmin`, `shx_ref_r1`, `shx_ref_wr2`, `shx_ref_fixed_r1`. A few low-multiplicity reflections
in the detector corners past the reference's limit can move R1 by more than the data's quality does,
so these are the numbers to read against an R1 refined on the reference's own data. Where the data
stop inside the reference's range they repeat the refinement above.
`python3 shelx_check.py <set work dir> <COD id>` runs it on one finished set; `python3 shelx_check.py --xds
<XDS_ASCII.HKL> <COD id>` runs the same recipe on XDS's corrected intensities (misfits dropped, as XDSCONV
drops them) - the like-for-like number for a set that has an XDS reference beside it.
@@ -885,6 +891,9 @@ is significant, and that decides which case applies (`inputs.reference_dmin`):
point where XDS's CC1/2 falls through 0.30 (the target of rugnux's own cutoff), interpolated in
1/d² between shell centres.
A shell of two unique reflections is not read: a correlation over two points is +-1 whatever the
data, XDS prints its CC1/2 as 0.0, and a tiny cubic cell has shells like that all the way out.
The derived value is the reference rugnux's own cut is scored against. The reference-range table
uses XDS's own limit, `dmin_xds`, because XDS's pooled R_meas, CC1/2 and completeness cover its
whole range; the manifest keeps the rule used as `dmin_rule`.
@@ -910,7 +919,10 @@ whole range; the manifest keeps the rule used as `dmin_rule`.
- **Inhouse / private**: add the row (`id`, `input`, tags, and `"expect": "no_lattice"` for a
control), then run `battery.py refs --arm inhouse --write` to fill in `ref` from the
`CORRECT.LP` beside the input. Without `--write`, `refs` only shows what would change.
A reference measured by hand goes in `ref_override`, which `refs` leaves alone.
A reference measured by hand goes in `ref_override`, which `refs` leaves alone. Where the XDS run
beside the data is itself faulty and was redone elsewhere, `ref_lp` names the new `CORRECT.LP`
(absolute, or relative to the data root) and `ref_lp_why` says what was wrong; `refs` then reads
that file instead.
A set whose reference is known to be wrong gets `"unscored": "<why>"`: it still runs, but
scores `unscored` instead of pass or fail.
A set whose files misdescribe the experiment in a way rugnux is not meant to detect (a placeholder
+12 -4
View File
@@ -394,6 +394,13 @@ def hardware_info():
# ------------------------------------------------------------------ running
def ref_dmin(e):
"""The reference's d_min the like-for-like numbers are taken at: XDS's own limit on the XDS arms
(see command), the deposition's on the open arm."""
ref = e.get("ref") or {}
return ref.get("dmin_xds") or ref.get("dmin")
def command(binary, e, opts, model=None):
cmd = [binary, "-o", "p", "--no-export-unmerged"]
if opts["threads"]:
@@ -408,7 +415,7 @@ def command(binary, e, opts, model=None):
# 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
# merged.
dmin = ref.get("dmin_xds") or ref.get("dmin")
dmin = ref_dmin(e)
if dmin:
cmd += ["--report-resolution",
f"{dmin:.3f}" + (f",{ref['dmax']:.3f}" if ref.get("dmax") else "")]
@@ -571,7 +578,7 @@ def run_one(run_dir, binary, e, opts):
if e.get("cod"):
# small molecule: its published structure refined against our p.hkl (report only)
row.update(shelx_check.check(wd, e["cod"], opts.get("cod_cache") or shelx_check.DEFAULT_CACHE,
opts.get("shelxl")))
opts.get("shelxl"), dmin=ref_dmin(e)))
return row
@@ -1168,13 +1175,14 @@ def cmd_discover(a, site):
def cmd_refs(a, site):
"""Re-read every set's XDS reference from the CORRECT.LP beside its input."""
"""Re-read every set's XDS reference from the CORRECT.LP beside its input, or from the set's
`ref_lp` where its reference was redone elsewhere."""
cfg = site["arms"][a.arm]
if cfg["reference"] != "xds":
sys.exit(f"the {a.arm} arm is not referenced to XDS")
man = json.load(open(cfg["manifest"]))
for e in man["sets"]:
lp = os.path.join(cfg["data_root"], os.path.dirname(e["input"]), "CORRECT.LP")
lp = os.path.join(cfg["data_root"], e.get("ref_lp") or os.path.join(os.path.dirname(e["input"]), "CORRECT.LP"))
if not os.path.exists(lp):
print(f"{e['id']:24s} no CORRECT.LP")
continue
+2 -2
View File
@@ -44,9 +44,9 @@
{"id": "citricacid_x10sa_20keV", "input": "citricacid_x10sa_20keV/citricacid_1_005_master.h5", "wavelength": 0.61993, "cod": "5000063", "tags": ["h5", "monoclinic", "small-molecule"], "ref": {"sgno": 4, "cell": [11.454, 5.579, 12.67, 90.0, 111.587, 90.0], "anomalous": true, "isa": 20.44, "completeness": 82.0, "r_meas": 0.041, "cc_half": 0.997, "multiplicity": 3.1, "dmin_low": 2.02, "r_meas_low": 0.05, "cc_half_high": 0.997, "dmin": 0.68, "dmin_rule": "xds_range", "dmin_xds": 0.68, "dmax": 50.0}, "ref_override": {"sg": "P 1 21/c 1", "sgno": 14}, "ref_override_why": "anhydrous citric acid, P 21/a (P 21/c in the standard setting); COD 5000063 - J. P. Glusker, J. A. Minkin, A. L. Patterson, Acta Cryst. B25 (1969) 1066-1072, doi:10.1107/S0567740869003542. XDS reports only Sohncke groups (P 21)"},
{"id": "hepes_x10sa_20keV", "input": "hepes_x10sa_20keV/hepes_1_004_master.h5", "wavelength": 0.61993, "cod": "2224210", "tags": ["h5", "orthorhombic", "small-molecule"], "ref": {"sgno": 19, "cell": [8.348, 9.575, 27.068, 90.0, 90.0, 90.0], "anomalous": true, "isa": 28.49, "completeness": 91.8, "r_meas": 0.031, "cc_half": 0.999, "multiplicity": 5.66, "dmin_low": 2.0, "r_meas_low": 0.037, "cc_half_high": 0.998, "dmin": 0.68, "dmin_rule": "xds_range", "dmin_xds": 0.68, "dmax": 50.0}, "ref_override": {"sg": "P b c a", "sgno": 61}, "ref_override_why": "HEPES, P b c a; COD 2224210 (100 K, 8.341 9.567 27.066) - P. Sledz, T. Minor, M. Chruszcz, Acta Cryst. E65 (2009) o3027-o3028, doi:10.1107/S1600536809042512. XDS reports only Sohncke groups (P 21 21 21)"},
{"id": "yag_x10sa_20keV", "input": "yag_x10sa_20keV/yag_2_004_master.h5", "wavelength": 0.61993, "cod": "2003066", "tags": ["h5", "cubic", "small-molecule"], "ref": {"sgno": 211, "cell": [11.997, 11.997, 11.997, 90.0, 90.0, 90.0], "anomalous": true, "isa": 3.18, "completeness": 99.0, "r_meas": 0.432, "cc_half": 0.947, "multiplicity": 28.44, "dmin_low": 1.99, "r_meas_low": 0.436, "cc_half_high": 0.885, "dmin": 0.68, "dmin_rule": "xds_range", "dmin_xds": 0.68, "dmax": 50.0}, "ref_override": {"sg": "I a -3 d", "sgno": 230}, "ref_override_why": "Y3Al5O12 garnet, I a -3 d; COD 2003066 - A. Nakatsuka, A. Yoshiasa, T. Yamanaka, Acta Cryst. B55 (1999) 266-272, doi:10.1107/S0108768198012567. XDS reports only Sohncke groups (I 4 3 2)", "tiers": {"ci": "small molecule, cubic Ia-3d, 0.66 A"}},
{"id": "kdp_x10sa_20keV", "input": "kdp_x10sa_20keV/kdp_1_003_master.h5", "wavelength": 0.61993, "cod": "9009999", "tags": ["h5", "tetragonal", "small-molecule"], "ref": {"sgno": 98, "cell": [7.425, 7.425, 6.924, 90.0, 90.0, 90.0], "anomalous": true, "isa": 4.1, "completeness": 99.2, "r_meas": 0.241, "cc_half": 0.969, "multiplicity": 6.14, "dmin_low": 2.06, "r_meas_low": 0.172, "cc_half_high": 0.911, "dmin": 0.74, "dmin_rule": "xds_range", "dmin_xds": 0.74, "dmax": 50.0}, "ref_override": {"sg": "I -4 2 d", "sgno": 122}, "ref_override_why": "KH2PO4 (KDP), tetragonal paraelectric phase, I -4 2 d; COD 9009999 - R. J. Nelmes, G. M. Meyer, J. E. Tibballs, J. Phys. C 15 (1982) 59-75, doi:10.1088/0022-3719/15/1/005. XDS reports only Sohncke groups (I 41 2 2)", "tiers": {"ci": "small molecule, tetragonal I-42d; I41md has the same absences"}},
{"id": "kdp_x10sa_20keV", "input": "kdp_x10sa_20keV/kdp_1_003_master.h5", "wavelength": 0.61993, "cod": "9009999", "tags": ["h5", "tetragonal", "small-molecule"], "ref": {"sgno": 98, "cell": [7.434, 7.434, 6.928, 90.0, 90.0, 90.0], "anomalous": false, "isa": 2.93, "completeness": 100.0, "r_meas": 0.386, "cc_half": 0.958, "multiplicity": 18.63, "dmin_low": 2.11, "r_meas_low": 0.277, "cc_half_high": 0.873, "dmin": 0.76, "dmin_rule": "xds_range", "dmin_xds": 0.76, "dmax": 50.0}, "ref_lp": "/data/battery/refs/kdp_x10sa_20keV/CORRECT.LP", "ref_lp_why": "XDS redone over the whole chain: the reference beside the data was integrated with OVERLOAD=65534, half the detector's range (every pixel above it discarded), in P1 and cut at 0.74 A; this run has OVERLOAD=133201 as the other in-house small-molecule references, the space group and cell given, the full resolution range, FRIEDEL'S_LAW=TRUE and MINIMUM_FRACTION_OF_INDEXED_SPOTS=0.2 (several domains); XDS.INP beside it", "ref_override": {"sg": "I -4 2 d", "sgno": 122}, "ref_override_why": "KH2PO4 (KDP), tetragonal paraelectric phase, I -4 2 d; COD 9009999 - R. J. Nelmes, G. M. Meyer, J. E. Tibballs, J. Phys. C 15 (1982) 59-75, doi:10.1088/0022-3719/15/1/005. XDS reports only Sohncke groups (I 41 2 2)", "tiers": {"ci": "small molecule, tetragonal I-42d; I41md has the same absences"}},
{"id": "nacl_x10sa_20keV", "input": "salt_x10sa/SaltPL_002_master.h5", "wavelength": 0.61993, "cod": "2108652", "tags": ["h5", "cubic", "small-molecule"], "ref": {"sgno": 209, "cell": [5.608, 5.608, 5.608, 90.0, 90.0, 90.0], "anomalous": false, "isa": 2.49, "completeness": 100.0, "r_meas": 0.379, "cc_half": 0.97, "multiplicity": 27.5, "dmin_low": 1.93, "r_meas_low": 0.339, "cc_half_high": 0.995, "dmin": 0.78, "dmin_rule": "xds_range", "dmin_xds": 0.78, "dmax": 50.0}, "ref_override": {"sg": "F m -3 m", "sgno": 225}, "ref_override_why": "rock salt (halite, NaCl), F m -3 m; COD 2108652 (a 5.6035, R 0.015) - V. Tsirelson, A. Stash, Acta Cryst. B76 (2020) 769-778, doi:10.1107/S2052520620009178. XDS reports only Sohncke groups (F 4 3 2); XDS indexed only its 150 strongest spots, given that group and the cell (several grains 5-10 deg apart; README_XDS beside the data)", "tiers": {"smoke": "known hard: tiny cubic F cell (rock salt), several grains, 99% of spots on powder rings; rc184 named the lattice tI and merged in I422"}},
{"id": "nacl_x10sa_2", "input": "salt_x10sa_2/SaltPL_003_master.h5", "wavelength": 0.61993, "cod": "2108652", "tags": ["h5", "cubic", "small-molecule"], "ref_override": {"sg": "F m -3 m", "sgno": 225}, "ref_override_why": "rock salt (halite, NaCl), F m -3 m; COD 2108652 (a 5.6035, R 0.015) - V. Tsirelson, A. Stash, Acta Cryst. B76 (2020) 769-778, doi:10.1107/S2052520620009178. XDS reports only Sohncke groups (F 4 3 2); XDS indexed only its 150 strongest spots, given that group and the cell (several grains 5-10 deg apart; README_XDS beside the data)", "tiers": {"smoke": "known hard: tiny cubic F cell (rock salt), several grains, 99% of spots on powder rings; the second sweep of nacl_x10sa_20keV's setup, a minute later"}, "ref": {"sgno": 209, "cell": [5.606, 5.606, 5.606, 90.0, 90.0, 90.0], "anomalous": false, "isa": 2.69, "completeness": 100.0, "r_meas": 0.325, "cc_half": 0.989, "multiplicity": 27.09, "dmin_low": 1.93, "r_meas_low": 0.268, "cc_half_high": 0.871, "dmin": 1.858, "dmin_rule": "cc_half_0.30", "dmin_xds": 0.78, "dmax": 50.0}},
{"id": "nacl_x10sa_2", "input": "salt_x10sa_2/SaltPL_003_master.h5", "wavelength": 0.61993, "cod": "2108652", "tags": ["h5", "cubic", "small-molecule"], "ref_override": {"sg": "F m -3 m", "sgno": 225}, "ref_override_why": "rock salt (halite, NaCl), F m -3 m; COD 2108652 (a 5.6035, R 0.015) - V. Tsirelson, A. Stash, Acta Cryst. B76 (2020) 769-778, doi:10.1107/S2052520620009178. XDS reports only Sohncke groups (F 4 3 2); XDS indexed only its 150 strongest spots, given that group and the cell (several grains 5-10 deg apart; README_XDS beside the data)", "tiers": {"smoke": "known hard: tiny cubic F cell (rock salt), several grains, 99% of spots on powder rings; the second sweep of nacl_x10sa_20keV's setup, a minute later"}, "ref": {"sgno": 209, "cell": [5.606, 5.606, 5.606, 90.0, 90.0, 90.0], "anomalous": false, "isa": 2.69, "completeness": 100.0, "r_meas": 0.325, "cc_half": 0.989, "multiplicity": 27.09, "dmin_low": 1.93, "r_meas_low": 0.268, "cc_half_high": 0.871, "dmin": 0.78, "dmin_rule": "xds_range", "dmin_xds": 0.78, "dmax": 50.0}},
{"id": "lascorbate", "input": "lascorbate/lascorbate_1_a39733_master.h5", "wavelength": 0.49594, "tags": ["h5", "orthorhombic", "small-molecule"], "ref": {"sgno": 19, "cell": [4.439, 8.496, 18.921, 90.0, 90.0, 90.0], "anomalous": false, "isa": 17.97, "completeness": 39.6, "r_meas": 0.039, "cc_half": 0.999, "multiplicity": 8.82, "dmin_low": 1.66, "r_meas_low": 0.037, "cc_half_high": 0.996, "dmin": 0.56, "dmin_rule": "xds_range", "dmin_xds": 0.56, "dmax": 50.0}},
{"id": "lcystine_x10sa_20keV", "input": "lcystine_x10sa_20keV/lcystine_2_004_master.h5", "wavelength": 0.61993, "cod": "1513328", "tags": ["h5", "hexagonal", "small-molecule"], "ref_override": {"sg": "P 61 2 2", "sgno": 178, "cell": [5.422, 5.422, 56.275, 90.0, 90.0, 120.0]}, "ref_override_why": "hexagonal L-cystine, P 61 2 2; COD 5000005 - B. M. Oughton and P. M. Harrison, Acta Cryst. 12 (1959) 396-404, doi:10.1107/S0365110X59001177. No XDS reference: XDS indexes under 10% of the spots of either sweep, so the row is scored on lattice and symmetry only"},
{"id": "lcystine_x10sa_25keV", "input": "lcystine_x10sa_25keV/lcystine_2_003_master.h5", "wavelength": 0.49594, "cod": "1513328", "tags": ["h5", "hexagonal", "small-molecule"], "ref_override": {"sg": "P 61 2 2", "sgno": 178, "cell": [5.422, 5.422, 56.275, 90.0, 90.0, 120.0]}, "ref_override_why": "hexagonal L-cystine, P 61 2 2; COD 5000005 - B. M. Oughton and P. M. Harrison, Acta Cryst. 12 (1959) 396-404, doi:10.1107/S0365110X59001177. No XDS reference: XDS indexes under 10% of the spots of either sweep, so the row is scored on lattice and symmetry only"},
+5 -1
View File
@@ -164,8 +164,12 @@ def parse_correct_lp(path):
include_low, include_high = (float(m.group(1)), float(m.group(2))) if m else (0.0, 0.0)
table_high = float(shells[-1][0]) if shells else 0.0
dmin_xds = (include_high if include_high > 0 else table_high) or None
# A correlation over two points is +-1 whatever the data, and XDS prints CC1/2 0.0 for a shell of
# two unique reflections (a tiny cubic cell has shells like that all the way out): such a shell
# says nothing about where the signal fades, so the rule below does not read it.
ref["dmin"], ref["dmin_rule"] = reference_dmin(
[(float(f[0]), num(f[10]) / 100, f[10].endswith("*")) for f in shells], include_low, dmin_xds)
[(float(f[0]), num(f[10]) / 100, f[10].endswith("*")) for f in shells if int(f[2]) >= 3],
include_low, dmin_xds)
ref["dmin_xds"] = dmin_xds
ref["dmax"] = include_low or None
return ref
+1 -1
View File
@@ -156,7 +156,7 @@
{"id": "9zm0", "input": "9zm0/Atg23ANNS_9zm0_9ZM0/data/SeAtg23_B_10_2115_master.h5", "wavelength": 0.97988, "ref": {"sg": "P 1 21 1", "sgno": 4, "cell": [50.409, 30.101, 91.244, 90.0, 97.146, 90.0], "dmin": 2.1}, "tags": ["h5", "monoclinic"]},
{"id": "9zmu", "input": "9zmu/BrmeA_18154_a_B2-Apo_9zmu/data/PSL-0613_7518_master.h5", "wavelength": 0.97856, "ref": {"sg": "P 65 2 2", "sgno": 179, "cell": [47.81, 47.81, 492.58, 90.0, 90.0, 120.0], "dmin": 1.98}, "tags": ["h5", "hexagonal"]},
{"id": "cuhf2", "input": "cuhf2/03_CuHF2pyz2PF6b_P_O/CuHF2pyz2PF6b_P_O_01.nxs", "wavelength": 0.4859, "pinned": true, "tags": ["nxs", "small-molecule"]},
{"id": "cytidine", "input": "cytidine/20151020-Cytidine-2th-30/fixed-omega--180-phi-scan01_00001.cbf", "wavelength": 0.68966, "ref": {"sg": "P 21 21 21", "sgno": 19, "cell": [13.98, 14.788, 5.119, 90.0, 90.0, 90.0], "dmin": null}, "cod": "2001311", "tags": ["cbf", "orthorhombic", "small-molecule"]},
{"id": "cytidine", "input": "cytidine/20151020-Cytidine-2th-30/fixed-omega--180-phi-scan01_00001.cbf", "wavelength": 0.68966, "ref": {"sg": "P 21 21 21", "sgno": 19, "cell": [13.98, 14.788, 5.119, 90.0, 90.0, 90.0], "dmin": null}, "cod": "2001311", "ref_override": {"cell": [14.032, 14.806, 5.137, 90.0, 90.0, 90.0]}, "ref_override_why": "there is no deposition: the cell above is the COD entry's, a different crystal, 0.35% smaller than the one these images give. The override is the cell xia2 refines on this dataset (DIALS 5.13665(3) 14.03181(10) 14.80550(9), XDS 5.140 14.030 14.800), in the COD setting; source doi:10.5281/zenodo.33555", "tags": ["cbf", "orthorhombic", "small-molecule"]},
{"id": "dnba", "input": "dnba/35dnba_30K_2_04_00001.cbf", "wavelength": 0.6889, "ref": {"sg": "C 1 2/c 1", "sgno": 15, "cell": [20.2635, 8.7575, 9.6697, 90.0, 109.941, 90.0], "dmin": 0.48}, "cod": "4510615", "tags": ["cbf", "monoclinic", "small-molecule"]},
{"id": "lalanine", "input": "lalanine/pgw240050_01_00001.cbf", "wavelength": 0.6889, "ref": {"sg": "P 21 21 21", "sgno": 19, "cell": [5.791, 5.944, 12.269, 90.0, 90.0, 90.0], "dmin": null}, "cod": "2311261", "tags": ["cbf", "orthorhombic", "small-molecule"], "tiers": {"smoke": "small molecule, miniCBF"}},
{"id": "metformin", "input": "metformin/013_Mmetformin_01_master.h5", "wavelength": 0.4859, "ref": {"sg": "P 1 21/c 1", "sgno": 14, "cell": [7.9104, 13.8794, 7.931, 90.0, 114.606, 90.0], "dmin": 0.45}, "cod": "2108029", "tags": ["h5", "monoclinic", "small-molecule"], "tiers": {"smoke": "small molecule, Diamond I19 NXmx master"}},
+13 -3
View File
@@ -37,6 +37,8 @@ NOISE = {
"wall_s": ("rel", 0.25), # and at least 10 s - see beyond_noise()
"shx_r1": ("abs", 0.003), # SHELXL refinement of a small molecule's COD structure
"shx_wr2": ("abs", 0.005),
"shx_ref_r1": ("abs", 0.003),
"shx_ref_wr2": ("abs", 0.005),
"shx_goof": ("abs", 0.03),
"shx_exti": ("abs", 0.02),
}
@@ -136,7 +138,9 @@ def fill_shelx(run_dir, man, res):
e = MANIFESTS.get(r["arm"], {}).get(key(r)[1]) or own.get((r["arm"], r["set"])) or {}
wd = os.path.join(run_dir, "work", r["arm"], r["set"])
if e.get("cod") and "shx_status" not in r and os.path.exists(os.path.join(wd, "p.hkl")):
todo.append((r, (wd, e["cod"], COD_CACHE or shelx_check.DEFAULT_CACHE, SHELXL)))
ref = e.get("ref") or {}
todo.append((r, (wd, e["cod"], COD_CACHE or shelx_check.DEFAULT_CACHE, SHELXL,
ref.get("dmin_xds") or ref.get("dmin"))))
if not todo or not SHELXL:
return
print(f"SHELXL refinement for {len(todo)} small-molecule sets of an older run ...", file=sys.stderr)
@@ -281,7 +285,7 @@ def changes(ra, rb):
for name in ("refres_r_meas", "refres_isa", "refres_lowres_r_meas"):
if ra.get(name) is not None and rb.get(name) is not None and beyond_noise(name, ra[name], rb[name]):
out.append(name)
for name in ("shx_r1", "shx_wr2", "shx_goof", "shx_exti"):
for name in ("shx_r1", "shx_wr2", "shx_goof", "shx_exti", "shx_ref_r1", "shx_ref_wr2"):
if ra.get(name) is not None and rb.get(name) is not None and beyond_noise(name, ra[name], rb[name]):
out.append("SHELXL " + name[4:])
if beyond_noise("wall_s", ra.get("wall_s"), rb.get("wall_s")):
@@ -610,6 +614,8 @@ def build(run_dir, baseline=None, allow_incomplete=False):
"off; K top is <Fo2>/<Fc2> of SHELXL's strongest analysis-of-variance bin (below 1: strong "
"reflections read low). Fixed-model R1(F) scores the data against |Fc| of the COD model as "
"published, one scale, nothing refined. R(int) means something only for unmerged data. "
"The same recipe is repeated over the reference's range (XDS's d_min, or the deposition's) "
"where the data reach past it, so R1 compares with the reference at the same d_min. "
"Reported, never scored.")
rows = []
for r in sorted(shx, key=lambda r: (order.get(r["arm"], 9), r["set"])):
@@ -621,9 +627,13 @@ def build(run_dir, baseline=None, allow_incomplete=False):
f(r.get("shx_peak")) + " / " + f(r.get("shx_hole")),
f(r.get("shx_rint"), "{:.4f}") + " / " + f(r.get("shx_rsigma"), "{:.4f}"),
f(r.get("shx_k_top"), "{:.3f}"), f(r.get("shx_fixed_r1"), "{:.4f}"),
f(r.get("shx_ref_dmin")) + ": " + f(r.get("shx_ref_r1"), "{:.4f}") + " / "
+ f(r.get("shx_ref_wr2"), "{:.4f}") + " / " + f(r.get("shx_ref_fixed_r1"), "{:.4f}")
if r.get("shx_ref_dmin") else "-",
r["shx_status"] if r["shx_status"] == "ok" else f"{r['shx_status']}: {r.get('shx_reason')}"])
doc.table(["set", "arm", "COD", "own d_min", "R1 >4sig (n)", "wR2", "GooF", "EXTI", "WGHT a / b",
"peak / hole e/A3", "R(int) / R(sigma)", "K top", "fixed-model R1(F)", "status"],
"peak / hole e/A3", "R(int) / R(sigma)", "K top", "fixed-model R1(F)",
"at ref d_min: R1 / wR2 / fixed-model R1", "status"],
rows, num=range(3, 13))
derived = {r["set"]: r for r in res if (r.get("d_min_ref_rule") or "xds_range") != "xds_range"}
+31 -13
View File
@@ -43,7 +43,8 @@ COD_URL = "https://www.crystallography.net/cod/{}.cif"
KEYS = ("shx_status", "shx_reason", "shx_cod", "shx_r1", "shx_n4", "shx_r1_all", "shx_wr2",
"shx_goof", "shx_exti", "shx_wght_a", "shx_wght_b", "shx_peak", "shx_hole", "shx_rint",
"shx_rsigma", "shx_k_top", "shx_fixed_r1")
"shx_rsigma", "shx_k_top", "shx_fixed_r1", "shx_ref_dmin", "shx_ref_r1", "shx_ref_wr2",
"shx_ref_fixed_r1")
def find_shelxl(site_path=None):
@@ -238,9 +239,21 @@ def fixed_model_r1(st, refl, M, lam):
return round(min(r1(x) for x in np.concatenate(([0.0], np.geomspace(1e-4, 100, 121)))), 4)
def check(wd, cod_id, cache=DEFAULT_CACHE, shelxl=None, work=None):
def refine(st, lam, cellp, refl, M, d, shelxl):
"""The final refinement in directory `d`: three rounds of 12 cycles with the weights SHELXL suggests."""
os.makedirs(d, exist_ok=True)
write_hkl(refl, M, os.path.join(d, "f.hkl"))
wght = "0.1"
for _ in range(3):
write_ins(st, lam, cellp, wght, 12, os.path.join(d, "f.ins"))
vals, suggested = run_shelxl(shelxl, "f", d)
wght = suggested or wght
return vals
def check(wd, cod_id, cache=DEFAULT_CACHE, shelxl=None, work=None, dmin=None):
"""shx_* fields for one finished set in work dir `wd` (p.hkl + p_report.txt). `work`: where
SHELXL runs (default <wd>/shelx)."""
SHELXL runs (default <wd>/shelx). `dmin`: the reference's d_min, for the shx_ref_* fields."""
out = {k: None for k in KEYS}
out["shx_cod"] = cod_id
if not shelxl:
@@ -271,16 +284,21 @@ def check(wd, cod_id, cache=DEFAULT_CACHE, shelxl=None, work=None):
if best is None:
return dict(out, shx_status="error", shx_reason="SHELXL gave no R1 in any setting")
_, M, c = best
d = os.path.join(work, "final")
os.makedirs(d, exist_ok=True)
write_hkl(refl, M, os.path.join(d, "f.hkl"))
wght = "0.1"
for _ in range(3):
write_ins(st, lam, c, wght, 12, os.path.join(d, "f.ins"))
vals, suggested = run_shelxl(shelxl, "f", d)
wght = suggested or wght
vals = refine(st, lam, c, refl, M, os.path.join(work, "final"), shelxl)
out.update(vals)
out["shx_fixed_r1"] = fixed_model_r1(st, refl, M, lam)
if dmin:
# The same recipe over the reference's range: where the data reach past the reference's
# d_min, the tail alone can move R1 more than the quality of the data does, so the two
# are compared at the same d_min. Where they do not, it is the refinement above.
cut = [r for r in refl if dcell.calculate_d(list(r[:3])) >= dmin]
if len(cut) < len(refl):
ref = refine(st, lam, c, cut, M, os.path.join(work, "refres"), shelxl)
fixed = fixed_model_r1(st, cut, M, lam)
else:
ref, fixed = vals, out["shx_fixed_r1"]
out.update(shx_ref_dmin=dmin, shx_ref_r1=ref["shx_r1"], shx_ref_wr2=ref["shx_wr2"],
shx_ref_fixed_r1=fixed)
out["shx_status"] = "ok" if vals["shx_r1"] is not None else "error"
if vals["shx_r1"] is None:
out["shx_reason"] = "SHELXL did not finish the refinement (see shelx/final/f.lst)"
@@ -289,10 +307,10 @@ def check(wd, cod_id, cache=DEFAULT_CACHE, shelxl=None, work=None):
return out
def check_tmp(wd, cod_id, cache, shelxl):
def check_tmp(wd, cod_id, cache, shelxl, dmin=None):
"""check() for a finished (read-only) run directory: SHELXL works in a temporary directory."""
with tempfile.TemporaryDirectory(prefix="shelx_") as tmp:
return check(wd, cod_id, cache, shelxl, tmp)
return check(wd, cod_id, cache, shelxl, tmp, dmin)
def xds_work_dir(xds_ascii, wd):