From c6a58d96c7166c768d490fd1fe47b4403730388e Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sun, 20 Sep 2026 20:02:04 +0200 Subject: [PATCH] Twin-immune zone: carry the pseudo-translation across a committed reindex The zone that arbitrates a refused point group is read on the merge that follows a committed change of basis (Rugnux.cpp: the reindex re-indexes every integrated reflection and re-ingests the rotation merge, and the merge the zone reads is made after that), but the pseudo-translation it was normalised by is measured on the search merge, before it. The zone spends that vector assigning each reflection a phase class by cos(2 pi h.u), which is a phase class only if h and u are in the same basis; left in the old one it partitions the reflections at random and normalises the zone by noise, with nothing in the numbers to say so. The reindex is (h,k,l)_new = M (h,k,l)_old, so h.u is preserved by u_new = (M^T)^-1 u_old - the ordinary transformation of a real-space fractional coordinate. Transform rather than re-measure: the vector is better determined on the search merge (a merge already folded under the adopted symmetry has averaged across the very phase classes the vector names), the transform is exact, and it costs nothing where re-measuring costs a second pseudo-translation analysis. Reachability: over eleven battery runs no crystal both commits a change of basis and carries a detected pseudo-translation into a refused point group, so no merged result in the corpus moves. The population that commits one has just grown, which is why it is worth fixing now rather than when it first bites. How wrong the vector is depends on it. A half-integer vector compatible with the committed centring survives unchanged - the two expressions differ by a lattice vector and every allowed reflection sees the same class. A general one does not: for an I-centring commit, cos(2 pi h.u) read in the two bases correlates -0.01 over the allowed reflections and disagrees in sign on 51% of them. Verified unchanged where nothing is committed: three rotation crystals with a detected pseudo-translation - two of them arbitrating a refused point group on this zone, one of them committing a reindex without a refusal - give byte-identical output.hkl, output.mtz, output.cif, output_P1.mtz and output_unmerged.mtz, and the same space group and TWIN_ZONE_DECISION. [tncs], [twinning] and [SearchSpaceGroup] pass. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_013nW6FNRP1bBJJ8pfHiByAT --- rugnux/Rugnux.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/rugnux/Rugnux.cpp b/rugnux/Rugnux.cpp index 10a46f362..9276b6999 100644 --- a/rugnux/Rugnux.cpp +++ b/rugnux/Rugnux.cpp @@ -6703,9 +6703,25 @@ ProcessResult Rugnux::RunPipeline(RugnuxObserver *observer, bool write_output, b // refused group and acentric in the adopted one, so they are distinct reflections // of this merge, at full multiplicity and production scale - where the P1 search // merge of a weak crystal has no shell with signal enough to read a zone on. + // The pseudo-translation is carried into the basis this merge is indexed on. It was + // measured on the search merge, before the change of basis committed above re-indexed + // the reflections, and the zone spends it assigning each reflection a phase class by + // cos(2 pi h.u) - which is a phase class only if h and u share a basis. Left in the + // old one it names classes at random and normalises the zone by noise, silently: the + // numbers stay the size they were. The reindex is (h,k,l)_new = M (h,k,l)_old, so h.u + // is preserved by u_new = (M^T)^-1 u_old - the ordinary transformation of a + // real-space fractional coordinate. Where nothing was committed this is the identity. + TranslationalNCSResult zone_tncs = pre_tncs; + if (commit_reindex && zone_tncs.detected) { + const gemmi::Vec3 u = commit_reindex->transpose().inverse().multiply( + gemmi::Vec3(pre_tncs.vector_frac[0], pre_tncs.vector_frac[1], + pre_tncs.vector_frac[2])); + zone_tncs.vector_frac = {u.x - std::floor(u.x), u.y - std::floor(u.y), + u.z - std::floor(u.z)}; + } const int zone = hi_sg.has_value() ? TwinZoneVerdict(sm.merged, gemmi::UnitCell(*result.consensus_cell), hi_search, - sg_search, result, TranslationalNCSVectorForLTest(pre_tncs)) : 0; + sg_search, result, TranslationalNCSVectorForLTest(zone_tncs)) : 0; if (zone < 0) { const std::string msg = fmt::format( "Point group {} was refused ({}), and the twin-immune zone of its added "