From 1f5427008d5eba60e013fbcd9e9e8565f2ec723f Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sun, 15 Nov 2026 21:46:38 +0100 Subject: [PATCH] Auto mode: P 1 on a metric-constrained lattice is decided against the lattice held triclinic A lattice is promoted to a centred or higher class on its metric alone, and the geometry and integration are held to that class. Where the space-group search then finds no symmetry (P 1), the constraint has nothing behind it. A stored rotation run in that state is now made once more from the start with the lattice held triclinic (IndexingSettings::FixedLatticeSystem, the hold a triclinic -C gives), and the merge whose CC1/2, averaged per shell on Fisher's z, is higher is the answer. Measured on a triclinic small-molecule set indexed C-centred monoclinic (angles held at 90 deg, 0.05 deg inside tolerance; the C lattice took 45% of the spots against 63% free, and a 27 deg segment indexed in the other hand of the pseudo-2-fold): bare run CC1/2 0.203, R_meas 41.3%, I/sigma 11.1 (UNUSABLE) -> CC1/2 0.987, R_meas 10.5%, I/sigma 12.7, identical to -S P1; one extra run (~3 s). No set of the rc186/rc187 full, private, multisweep or private-multisweep battery runs ends in P 1 on a lattice other than triclinic P, so no battery set reaches the new path. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK --- docs/CPU_DATA_ANALYSIS_INDEXING.md | 7 ++++ rugnux/Rugnux.cpp | 54 ++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/docs/CPU_DATA_ANALYSIS_INDEXING.md b/docs/CPU_DATA_ANALYSIS_INDEXING.md index aa83b6b9a..7fac4ebb2 100644 --- a/docs/CPU_DATA_ANALYSIS_INDEXING.md +++ b/docs/CPU_DATA_ANALYSIS_INDEXING.md @@ -295,6 +295,13 @@ re-checks, about a second each. The checks taken on the pre-pass frames - the geometry walk's refits, the metric-symmetry arm and the pre-pass spot-crowding count - stay on those frames in both modes, and their near ties are re-checked once every frame is in on both. +A lattice is promoted to a centred or higher class on its metric alone, and the geometry and +integration are then held to that class. Where the space-group search afterwards finds no symmetry +at all (P 1) on such a lattice, the constraint has nothing left behind it, so a stored rotation run +is made once more with the lattice held triclinic from its first pass (as `-S P1` holds it), and of +the two merges the one whose CC1/2, averaged per resolution shell on Fisher's $z$, is higher is the +answer. + **A first pass that ends with no usable lattice tries a leaner, shallower one.** A crystal sitting in a crystalline powder floods the pass with spots that are not its own — measured, 2112 spots a frame against the 80 a clean crystal on the same beamline gives — and the FFT then takes its cell out of the diff --git a/rugnux/Rugnux.cpp b/rugnux/Rugnux.cpp index 9a43c9272..6b6b899c3 100644 --- a/rugnux/Rugnux.cpp +++ b/rugnux/Rugnux.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -471,6 +472,27 @@ void RaiseFFTBoundForKnownCell(IndexingSettings &settings, const DiffractionExpe "(shortest axis {:.1f} A)", floor_A, shortest); } } + + // The merged CC1/2 per shell on Fisher's z, averaged: what two merges of one sweep are judged on. + double MergedShellZ(const ProcessResult &r) { + double z = 0; + int n = 0; + for (const auto &sh : r.merge_statistics.shells) + if (std::isfinite(sh.cc_half) && std::fabs(sh.cc_half) < 1.0) { + z += std::atanh(sh.cc_half); + n++; + } + return n > 0 ? z / n : -std::numeric_limits::infinity(); + } + + // The space-group search ran and found no symmetry, on a lattice indexed under a metric constraint - + // a centring, or angles held at a higher system's values - that the intensities then gave no support. + bool TriclinicOnConstrainedLattice(const ProcessResult &r) { + return r.has_merge_statistics && r.space_group_search && r.space_group && r.space_group->number == 1 + && r.rotation_lattice_type + && (r.rotation_lattice_type->centering != 'P' + || r.rotation_lattice_type->crystal_system != gemmi::CrystalSystem::Triclinic); + } } @@ -509,6 +531,13 @@ ProcessResult Rugnux::Run(RugnuxObserver *observer) { looser->near_tie_rechecks_ = std::make_shared(); looser->looser_spots_ = true; looser->config_.spot_finding.false_pixels_per_frame *= 10.0f; + // And as it starts with the lattice held triclinic, for a run whose space-group search ends in P 1 on + // a lattice it indexed under a metric constraint: the intensities said there is no symmetry, so the + // constraint the geometry and integration were held to has nothing behind it. + const auto free_triclinic = std::make_shared(*this); + free_triclinic->near_tie_rechecks_ = std::make_shared(); + free_triclinic->experiment_.ImportIndexingSettings( + experiment_.GetIndexingSettings().FixedLatticeSystem(gemmi::CrystalSystem::Triclinic)); const SpotFindingSettings spot_finding = config_.spot_finding; Rugnux *run = this; ProcessResult result; @@ -531,6 +560,31 @@ ProcessResult Rugnux::Run(RugnuxObserver *observer) { result = again->RunAllPasses(observer); run = again.get(); } + // Two hypotheses about the lattice, decided on the merges: the constrained one as integrated, and + // the free triclinic one integrated again from its own first pass. + if (!result.cancelled && !config_.live && !user_cell_ && TriclinicOnConstrainedLattice(result)) { + Logger logger("Rugnux"); + logger.Info("P 1 on a {}-centred {} lattice: the run is made again with the lattice held triclinic", + result.rotation_lattice_type->centering, + gemmi::crystal_system_str(result.rotation_lattice_type->crystal_system)); + if (observer) + observer->OnStep("Triclinic lattice hypothesis (P 1 on a constrained lattice)"); + try { + ProcessResult free = free_triclinic->RunAllPasses(observer); + const double z_constrained = MergedShellZ(result); + const double z_free = free.has_merge_statistics ? MergedShellZ(free) + : -std::numeric_limits::infinity(); + logger.Info("Lattice held as indexed or triclinic: merged CC1/2 per shell on Fisher's z {:+.4f} " + "as indexed, {:+.4f} triclinic => {}", z_constrained, z_free, + z_free > z_constrained ? "triclinic" : "as indexed"); + if (z_free > z_constrained) { + result = std::move(free); + run = free_triclinic.get(); + } + } catch (const NoLatticeFound &) { + logger.Info("Lattice held triclinic: no lattice found - the lattice as indexed stands"); + } + } } catch (NoLatticeFound &e) { if (!looser_spots_ && config_.spot_finding.adaptive_threshold && !config_.live && !cancelled_) { Logger("Rugnux").Info("No lattice: the run is made again with the spot finder's operating point ten "