SearchSpaceGroup: glide groups without a centre of symmetry; the centre decided by absences, a default, or the intensity distribution

Non-Sohncke candidates were enumerated only when their PROPER rotations equalled the measured
point group's, which only centrosymmetric groups satisfy. Groups without a centre (Pc, Pna2_1,
I-42d, I4_1md, Fdd2, P-42_1c, I-43d) were never candidates: where a centrosymmetric group shares
their absences rugnux wrote it silently (Pc -> P2/c), and where none does the dead glide zone was
dropped and a Sohncke subgroup written (KDP-type I-42d data -> I4_122).

- Enumerate non-Sohncke groups by Laue class. The Sohncke-signature dedup, CellHostsRotations and
  the glide-evidence bar are unchanged. Groups with identical absences in the same Laue class are
  scored once and carried as `same_absences`; a selected candidate brings them into
  `alternatives`.
- Convention for which twin is written: the centrosymmetric one where it exists (missed centres are
  the common error, Baur & Kassner 1992), otherwise the lowest-numbered (I4_1md over I-42d).
- The centrosymmetric default gives way only when, on the general reflections of the Laue class of
  the final merge, <|L|>, <|E^2-1|> and N(0.1), each calibrated against acentric/centric intensities
  simulated with the reflections' own sigmas (fixed-seed mt19937_64, own deviate transforms), read
  acentric (L f <= 0.3, others <= 0.5), every f lies in [-0.3, 1.3], the always-centric control reads
  centric (f >= 0.5), and the lattice excludes twinning (gemmi Le Page metric admits no rotation
  beyond the Laue class, no TWIN_DOMAIN leftover lattice). Then the group is switched and re-merged.
- Report: SPACE_GROUP_CENTRE (IMPLIED_BY_ABSENCES / ABSENT_BY_ABSENCES / NOT_DETERMINED /
  ABSENT_BY_STATISTICS), CENTRE_TWINNING_EXCLUDED, CENTRE_STATISTICS_* on every searched run, and
  prose for the absence-equivalent alternatives.

Battery (targeted): all 14 small-molecule sets vs 58a4bf (smt-all, kdp-all): every group
unchanged except kdp_x10sa_20keV I 41 2 2 -> I 41 m d with I -4 2 d as the alternative; dnba stays
C 1 2/c 1, now NOT_DETERMINED with C 1 c 1 listed (statistics read centric, f 0.96-1.24). The
P2_1/c, Pbca and Ia-3d sets read IMPLIED_BY_ABSENCES with no alternative.
Protein panel (19 sets, twinned panel + controls, run glide-prot): every space group equals the
rc174-all base (3r6o re-run with the base binary: I 41 2 2 both); no SPACE_GROUP_CENTRE on any.
Twinned proteins read the centre statistics NOT_APPLICABLE (L f -0.3 to -1.7) or ACENTRIC.
Private subset (8 sets): 8/8 groups unchanged vs 58a4bf.
The glide-zone evidence scan over battery 3 (every non-Sohncke group of each run's Laue class,
centrosymmetric or not) peaks at 0.69 nats/reflection on proteins against the 2.0 bar.

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:
leonarski_fandClaude Opus 5.5 committed 2026-10-04 23:18:02 +02:00
1 parent c27d352c20
commit 60b7fb86fa
13 files changed
+727 -42

No files matched your search

+126
View File
@@ -1,11 +1,13 @@
#include <catch2/catch_all.hpp>
#include "../image_analysis/scale_merge/SearchSpaceGroup.h"
#include "../image_analysis/scale_merge/CentreOfSymmetry.h"
#include "gemmi/symmetry.hpp"
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <random>
#include <string>
#include <tuple>
#include <unordered_set>
@@ -815,3 +817,127 @@ TEST_CASE("SearchSpaceGroup never claims an inversion centre") {
CHECK(result.best_space_group->is_sohncke());
CHECK_FALSE(result.glide_space_group.has_value());
}
// A NON-centrosymmetric glide group holds only half the rotations of its Laue class, so it has to be
// enumerated by Laue class to be a candidate at all. Where its absences have no centrosymmetric
// carrier (I-42d, Fdd2, P-42_1c, I-43d) it is the only group naming the glide; I-42d and I4_1md
// predict the same absences, so the one not written is reported beside the one that is.
TEST_CASE("SearchSpaceGroup names a glide with no centrosymmetric carrier") {
struct Case {
std::string input_name;
std::vector<std::string> accepted; // the written group and its same-absence twins
gemmi::UnitCell cell;
};
const std::vector<Case> cases = {
{"I -4 2 d", {"I 41 m d", "I -4 2 d"}, gemmi::UnitCell(7.4, 7.4, 6.9, 90, 90, 90)},
{"P -4 21 c", {"P -4 21 c"}, gemmi::UnitCell(7.4, 7.4, 6.9, 90, 90, 90)},
{"F d d 2", {"F d d 2"}, gemmi::UnitCell(11.0, 13.0, 17.0, 90, 90, 90)},
{"I -4 3 d", {"I -4 3 d"}, gemmi::UnitCell(9.0, 9.0, 9.0, 90, 90, 90)},
};
for (const auto& tc : cases) {
DYNAMIC_SECTION(tc.input_name) {
const gemmi::SpaceGroup& sg = gemmi::get_spacegroup_by_name(tc.input_name);
const auto merged = GenerateMergedReflectionsForSpaceGroup(sg, 12);
SearchSpaceGroupOptions opt;
opt.merge_friedel = true;
opt.cell = tc.cell;
opt.enumerate_all_settings = true;
const auto result = SearchSpaceGroup(merged, opt);
INFO(SearchSpaceGroupResultToText(result));
REQUIRE(result.best_space_group.has_value());
std::vector<std::string> named{result.best_space_group->xhm()};
for (const auto& alt : result.alternatives)
named.push_back(alt.xhm());
CHECK_THAT(named, Catch::Matchers::UnorderedEquals(tc.accepted));
CHECK(result.glide_space_group.has_value());
REQUIRE(result.sohncke_space_group.has_value());
CHECK(result.sohncke_space_group->is_sohncke());
}
}
}
// Pc and P2/c (Pna2_1 and Pnma) predict the same absences and differ by an inversion centre, which
// Friedel's law hides. By convention the CENTROSYMMETRIC one is written, whichever the data came
// from, and the other is reported as an alternative - never dropped, so the run does not claim a
// centre nothing measured.
TEST_CASE("SearchSpaceGroup writes the centrosymmetric group and reports its non-centrosymmetric twin") {
struct Case {
std::string input_name;
std::string written;
std::string alternative;
gemmi::UnitCell cell;
};
const gemmi::UnitCell monoclinic(11.0, 13.0, 17.0, 90.0, 101.0, 90.0);
const gemmi::UnitCell orthorhombic(11.0, 13.0, 17.0, 90.0, 90.0, 90.0);
const std::vector<Case> cases = {
{"P 1 c 1", "P 1 2/c 1", "P 1 c 1", monoclinic},
{"P 1 2/c 1", "P 1 2/c 1", "P 1 c 1", monoclinic},
{"C 1 c 1", "C 1 2/c 1", "C 1 c 1", monoclinic},
{"P n a 21", "P n a m", "P n a 21", orthorhombic},
};
for (const auto& tc : cases) {
DYNAMIC_SECTION(tc.input_name) {
const gemmi::SpaceGroup& sg = gemmi::get_spacegroup_by_name(tc.input_name);
const auto merged = GenerateMergedReflectionsForSpaceGroup(sg, 10);
SearchSpaceGroupOptions opt;
opt.merge_friedel = true;
opt.cell = tc.cell;
opt.enumerate_all_settings = true;
const auto result = SearchSpaceGroup(merged, opt);
INFO(SearchSpaceGroupResultToText(result));
REQUIRE(result.best_space_group.has_value());
CHECK(result.best_space_group->xhm() == tc.written);
CHECK(std::any_of(result.alternatives.begin(), result.alternatives.end(),
[&](const gemmi::SpaceGroup& a) { return a.xhm() == tc.alternative; }));
}
}
}
// The centre-of-symmetry statistics on synthetic Wilson data: acentric and centric intensities on the
// general reflections of a 2/m Laue class, with the reflections a 2-fold maps to their Friedel mate
// (h0l) centric in both. The calibrated readings must land at their ends, and only the acentric set
// may read ACENTRIC.
TEST_CASE("AnalyzeCentreOfSymmetry separates acentric from centric Wilson data") {
const gemmi::UnitCell cell(11.0, 13.0, 17.0, 90.0, 101.0, 90.0);
const gemmi::SpaceGroup& sg = gemmi::get_spacegroup_by_name("P 1 2/c 1");
for (const bool centric : {false, true}) {
DYNAMIC_SECTION((centric ? "centric" : "acentric")) {
std::mt19937 rng(7);
std::exponential_distribution<double> expo(1.0);
std::normal_distribution<double> gauss(0.0, 1.0);
std::vector<MergedReflection> merged;
const gemmi::GroupOps gops = sg.operations();
const gemmi::ReciprocalAsu asu(&sg);
for (int h = -10; h <= 10; ++h)
for (int k = 0; k <= 10; ++k)
for (int l = -12; l <= 12; ++l) {
const gemmi::Op::Miller hkl{{h, k, l}};
if ((h == 0 && k == 0 && l == 0) || !asu.is_in(hkl) || gops.is_systematically_absent(hkl))
continue;
const double d = cell.calculate_d(hkl);
if (d < 0.8)
continue;
// h0l is centric under the 2-fold whatever the crystal is.
const bool c = centric || k == 0;
const double z = gauss(rng);
const double I = 1000.0 * std::exp(-2.0 / (d * d)) * (c ? z * z : expo(rng));
merged.push_back(MergedReflection{.h = h, .k = k, .l = l,
.I = static_cast<float>(I), .sigma = 1.0f,
.d = static_cast<float>(d)});
}
const auto r = AnalyzeCentreOfSymmetry(merged, sg);
INFO("n " << r.n_general << " pairs " << r.l_pairs << " L f " << r.mean_abs_l.f << " E f "
<< r.mean_abs_e2_minus_1.f << " N f " << r.n_z_01.f << " control f "
<< r.control_mean_abs_e2_minus_1.f);
REQUIRE(r.n_general > 1000);
CHECK(r.applicable);
CHECK(r.mean_abs_l.f == Catch::Approx(centric ? 1.0 : 0.0).margin(0.2));
CHECK(r.mean_abs_e2_minus_1.f == Catch::Approx(centric ? 1.0 : 0.0).margin(0.2));
CHECK(r.reads_acentric == !centric);
}
}
}