From d2e6c85edb6a7d539d32658691b2cb794bbd75c0 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sun, 15 Nov 2026 16:20:23 +0100 Subject: [PATCH] rugnux: the typed-angle rule of -C applies to a cell typed on the command line only A joint run that processes a failed sweep again hands it the reference sweep's measured cell as fixed_reference_unit_cell. Its angles are never the literal 90 or 120, so the rule reading the crystal system off the typed angles pushed every such rerun to P 1 (or, on a lucky bit pattern, to a wrong system). The rule now fires only for a cell given with -C. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK --- rugnux/rugnux_cli.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rugnux/rugnux_cli.cpp b/rugnux/rugnux_cli.cpp index bba857edf..3238a24fd 100644 --- a/rugnux/rugnux_cli.cpp +++ b/rugnux/rugnux_cli.cpp @@ -939,6 +939,7 @@ struct RugnuxCli { bool anomalous_mode = false; const gemmi::SpaceGroup *space_group = nullptr; std::optional fixed_reference_unit_cell; + bool unit_cell_typed = false; // -C on the command line, not a cell a joint run hands a sweep std::optional fixed_lattice_system; // from a -C cell without -S std::optional max_spot_count_override; float sigma_spot_finding = SpotFindingSettings{}.signal_to_noise_threshold; @@ -1259,6 +1260,7 @@ int RugnuxCli::Parse(int argc, char **argv) { exit(EXIT_FAILURE); } fixed_reference_unit_cell = uc; + unit_cell_typed = true; logger.Info( "Fixed reference unit cell set: a={:.3f} b={:.3f} c={:.3f} alpha={:.3f} beta={:.3f} gamma={:.3f}", uc->a, uc->b, uc->c, uc->alpha, uc->beta, uc->gamma); @@ -2006,8 +2008,9 @@ int RugnuxInputRun::PrepareRugnuxInput() { // never above or below, and only the space group within it is searched. Three 90s: orthorhombic, // or tetragonal / cubic where the lengths are equal within the usual tolerance; two 90s and a // 120: hexagonal; two 90s: monoclinic; three equal angles: rhombohedral; anything else names a - // triclinic lattice, whose group is P 1 - and the run then goes as with -S P1. - if (fixed_reference_unit_cell && space_group == nullptr) { + // triclinic lattice, whose group is P 1 - and the run then goes as with -S P1. Only a cell typed by + // the user: a measured cell a joint run hands a sweep to process again has no literal angles. + if (fixed_reference_unit_cell && unit_cell_typed && space_group == nullptr) { const auto &c = *fixed_reference_unit_cell; const int n90 = (c.alpha == 90.0f) + (c.beta == 90.0f) + (c.gamma == 90.0f); const bool has120 = c.alpha == 120.0f || c.beta == 120.0f || c.gamma == 120.0f;