Rotation indexing: integrate every frame for a lattice most frames fail; sign flip must beat chance
Two first-pass decisions taken on frame counts at their noise floor, both found on a hexagonal small-molecule crystal embedded in a powder of its own microcrystals (the non-ice powder rings index on the crystal's own cell; 13-16% of the pooled validation spots lie on the lattice): - Sparse lattice. A lattice whose pooled spots fall under the per-frame floor (20%) is integrated on every frame only if fewer than 1/6 of the validation frames clear the floor. At 12/60 the floor was kept, so only the frames in the upper tail of the same population were integrated: 267 of 1800 frames merged, 22.7k rocking events -> 4.2k fulls, completeness 74%. The bar is now the majority (score < N/2). 25 keV sweep: completeness 74% -> 99% to 0.56 A, frames rejected 1533 -> 137, SHELXL R1 (COD model) 0.150 -> 0.156 / 0.150 -> 0.139 depending on the COD entry. No other set of the overnight battery (open, in-house, private) is in the changed band (pooled < 20% with 10-29 of 60 frames). - Axis sign. The opposite spindle sign was adopted on 1/60 frames against 0/60; every rescue after that ran on the wrong sign and the 20 keV sweep ended in "No crystal lattice found" (with some compiler flags the file's sign scored 9/60 and the run indexed). The flipped lattice must now also beat chance on the pooled spots, the test the run puts its final lattice to; a sparse pattern at the right sign still passes (2/60 frames, 89% of the validation spots). 20 keV sweep: fails -> P 61 2 2, 5.41/56.0 A, SHELXL R1 0.137 (was 0.76 in the runs that indexed). tools/battery/shelx_check.py: the fixed-model R1(F) now fits SHELXL's extinction coefficient together with the scale (scan over x), since extinction belongs to the crystal and otherwise dominates the strongest reflections (HEPES 0.099 -> 0.059). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K5K8jvPPbmCrbqnWkddTuB
This commit is contained in:
1 parent
e72236b08d
commit
67b4d91130
2 files changed
+41
-15
No files matched your search
+23
-6
@@ -4732,13 +4732,27 @@ ProcessResult Rugnux::RunPipeline(RugnuxObserver *observer, bool write_output, b
|
||||
flipped.Axis(-gon->GetAxis());
|
||||
experiment_.Goniometer(flipped);
|
||||
FirstPass alt = pick_best(*indexer_pool, *indexer);
|
||||
if (alt.result.has_value() && alt.score > best.score) {
|
||||
// More frames is not enough on its own while both counts sit at the floor: 1/60 against
|
||||
// 0/60 is noise, and adopting it puts every rescue below on the wrong sign (measured: a
|
||||
// run whose file sign, kept, went on to index found nothing once flipped on 1/60). So
|
||||
// the flipped lattice must also beat chance on the pooled spots - the test the run puts
|
||||
// its final lattice to - which a sparse pattern at the right sign passes on few frames
|
||||
// (2/60 frames, 89% of the validation spots against 0% by chance).
|
||||
const bool alt_real = alt.result.has_value() && alt.score > best.score
|
||||
&& beats_chance(pooled_evidence(*indexer, *alt.result));
|
||||
if (alt_real) {
|
||||
logger.Info("Rotation axis sign: the file's axis indexes {}/{} validation frames, "
|
||||
"the opposite sign {}/{} - adopting the opposite sign for this run",
|
||||
best.score, static_cast<int>(validation.size()),
|
||||
alt.score, static_cast<int>(validation.size()));
|
||||
best = alt;
|
||||
} else {
|
||||
if (alt.result.has_value() && alt.score > best.score)
|
||||
logger.Info("Rotation axis sign: the opposite sign indexes {}/{} validation frames "
|
||||
"against the file's {}/{}, but its lattice does not beat chance on the "
|
||||
"pooled spots - the file's sign is kept",
|
||||
alt.score, static_cast<int>(validation.size()),
|
||||
best.score, static_cast<int>(validation.size()));
|
||||
experiment_.Goniometer(*gon); // the file was right; put it back
|
||||
}
|
||||
}
|
||||
@@ -5686,14 +5700,17 @@ ProcessResult Rugnux::RunPipeline(RugnuxObserver *observer, bool write_output, b
|
||||
}
|
||||
}
|
||||
indexer->ForceRotationIndexerResult(*best.result);
|
||||
// A lattice the pooled spots accept while hardly a validation frame clears the per-frame
|
||||
// floor (LATTICE_MIN_INDEXED_FRACTION) on its own, because the sweep as a whole puts fewer of
|
||||
// its spots on the lattice than that floor asks of each frame: the crystal is real but its
|
||||
// A lattice the pooled spots accept while most validation frames fail the per-frame floor
|
||||
// (LATTICE_MIN_INDEXED_FRACTION) on their own, because the sweep as a whole puts fewer of its
|
||||
// spots on the lattice than that floor asks of each frame: the crystal is real but its
|
||||
// spots are a minority of every frame - a weak crystal inside a powder of its own
|
||||
// microcrystals and ice. The floor cannot tell its frames from anything else, so integrate
|
||||
// every frame from the sweep's lattice, as XDS and DIALS do, and leave the frames to the
|
||||
// scaling. A sweep that is sparse only in spots per frame (a small molecule) keeps the floor.
|
||||
const bool sparse_lattice = best.score < static_cast<int>(validation.size()) / 6
|
||||
// scaling. The frames that do clear it are the upper tail of the same population: measured
|
||||
// on a crystal in a powder of itself (13% of the pooled spots on the lattice), 12/60
|
||||
// cleared it, and keeping the floor integrated 15% of the sweep. A sweep that is sparse
|
||||
// only in spots per frame (a small molecule) keeps the floor.
|
||||
const bool sparse_lattice = best.score < static_cast<int>(validation.size()) / 2
|
||||
&& pooled < LATTICE_MIN_INDEXED_FRACTION;
|
||||
indexer->IntegrateEveryFrame(sparse_lattice);
|
||||
if (sparse_lattice)
|
||||
|
||||
@@ -16,7 +16,9 @@ Recipe (the same for every run, so two runs compare):
|
||||
the same recipe takes a merged or an unmerged HKLF 4 file; R(int)/R(sigma) are read where
|
||||
SHELXL prints them (meaningful for unmerged data only).
|
||||
- "fixed-model R1(F)": the data scored against |Fc| of the COD model as published (gemmi, no
|
||||
refinement, one scale): a check that does not depend on what SHELXL can absorb into ADPs or EXTI.
|
||||
refinement of the model, a scale and SHELXL's extinction coefficient fitted): a check that does
|
||||
not depend on what SHELXL can absorb into ADPs. Extinction is a property of this crystal, not of
|
||||
the model, and without it the strongest reflections dominate the score.
|
||||
|
||||
Derived from the small-molecule harness of the 2026-10 data-quality work (codref.py/fixedmodel.py).
|
||||
SHELXL is called, not shipped: give its path as site key "shelxl" or have it on PATH (it comes with
|
||||
@@ -197,8 +199,9 @@ def run_shelxl(shelxl, name, cwd):
|
||||
"shx_k_top": k_top}, " ".join(wght)
|
||||
|
||||
|
||||
def fixed_model_r1(st, refl, M):
|
||||
"""R1(F) of the (reindexed) data against |Fc| of the COD model as published, one scale."""
|
||||
def fixed_model_r1(st, refl, M, lam):
|
||||
"""R1(F) of the (reindexed) data against |Fc| of the COD model as published, with one scale and
|
||||
SHELXL's extinction, Fc2* = Fc2 (1 + 0.001 x Fc2 lambda^3 / sin 2theta)^-1/2, x fitted by a scan."""
|
||||
sg = spacegroup(st)
|
||||
ops = sg.operations()
|
||||
asu = gemmi.ReciprocalAsu(sg)
|
||||
@@ -216,15 +219,21 @@ def fixed_model_r1(st, refl, M):
|
||||
groups.setdefault(tuple(asu.to_asu(list(map(int, n)), ops)[0]), []).append((i, s))
|
||||
if not groups:
|
||||
return None
|
||||
fo, fc = [], []
|
||||
fo, fc, ext = [], [], []
|
||||
for hkl, obs in groups.items():
|
||||
w = [1 / s ** 2 for _, s in obs]
|
||||
fo.append(sum(i * wi for (i, _), wi in zip(obs, w)) / sum(w))
|
||||
fc.append(abs(calc.calculate_sf_from_small_structure(st, list(hkl))) ** 2)
|
||||
fo, fc = np.array(fo), np.array(fc)
|
||||
fo = fo / (np.sum(fo * fc) / np.sum(fc * fc))
|
||||
Fo, Fc = np.sqrt(np.clip(fo, 0, None)), np.sqrt(fc)
|
||||
return round(float(np.sum(np.abs(Fo - Fc)) / np.sum(Fo)), 4)
|
||||
sin_th = lam / (2 * st.cell.calculate_d(list(hkl)))
|
||||
ext.append(0.001 * lam ** 3 / (2 * sin_th * np.sqrt(1 - sin_th ** 2)))
|
||||
fo, fc, ext = np.array(fo), np.array(fc), np.array(ext)
|
||||
|
||||
def r1(x):
|
||||
fcx = fc / np.sqrt(1 + x * fc * ext)
|
||||
f = fo / (np.sum(fo * fcx) / np.sum(fcx * fcx))
|
||||
Fo = np.sqrt(np.clip(f, 0, None))
|
||||
return float(np.sum(np.abs(Fo - np.sqrt(fcx))) / np.sum(Fo))
|
||||
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):
|
||||
@@ -269,7 +278,7 @@ def check(wd, cod_id, cache=DEFAULT_CACHE, shelxl=None, work=None):
|
||||
vals, suggested = run_shelxl(shelxl, "f", d)
|
||||
wght = suggested or wght
|
||||
out.update(vals)
|
||||
out["shx_fixed_r1"] = fixed_model_r1(st, refl, M)
|
||||
out["shx_fixed_r1"] = fixed_model_r1(st, refl, M, lam)
|
||||
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)"
|
||||
|
||||
Reference in new issue
Block a user