Space-group search: the twin-immune zone is read on a normalisation the control certifies

The zone verdict that arbitrates a refused promotion read its zone absolutely, against the
centric and acentric Wilson expectations, and an absolute reading is only as good as the
normalisation under it. On two refused 622 promotions - a 6/m crystal and a 312 one, whose added
operators disagreed at 4.7x and 5.2x the parent's H and merged to an R_meas of 0.34 under the
higher group - every class read centric: a 67 A^2 anisotropy, isotropically normalised in bins
of 100, spread one shell's expected intensity over a factor of 15 between its directions, and
the acentric control read 1.00 against its 0.74. The zone read the same as the control, +0.10
nats per reflection, and +124 nats over 947 reflections rescued a twin law.

Two things change. The anisotropy is fitted on the acentric reflections of the shells read
(ln I = c + s^T Q s, by least squares) and its deviatoric part taken out of every intensity
before anything is normalised; that alone brings the controls of the crystals measured to
0.73-0.77. What no normalisation removes, the control then certifies: an acentric population
reads -0.130 nats per reflection when the normalisation is right, a twinned one reads below
that, so whatever the control reads above it is the normalisation's - anisotropy, a
pseudo-translation, a pseudo-centring, noise all inflate every class towards centric alike -
and the zone, normalised the same way, carries the same per reflection; the calibrated evidence
has it taken off, and that is what the verdict reads. The two rescued twin laws now read -130
and -78 nats and stay refused, with the law named; the genuine promotions measured read +137 to
+580 (a pseudo-centred orthorhombic crystal whose control reads 0.99 still +334); the trigonal
and hexagonal partial twins -129 to -420 as before. The report prints the control's excess and
the calibrated evidence beside the raw one.

The metric-lattice re-ask carried a second copy of the two-arm rule without the zone: a P31
partial twin whose 32 the main rule had refused on the zone was promoted by that ask's
Lorentz-filtered arm. It now puts the same verdict to a refusal the other arm would outvote.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013nW6FNRP1bBJJ8pfHiByAT
This commit is contained in:
leonarski_fandClaude Fable 5.1 committed 2026-09-20 18:45:17 +02:00
1 parent 3ca22c07c1
commit 40874c2c2d
6 files changed
+267 -65

No files matched your search

+63 -7
View File
@@ -223,8 +223,12 @@ namespace {
// intensity from the acentric distribution, which is all the searches it was written for need, but
// the zone test reads exactly the difference. E^2 is chi^2 with one degree of freedom for a
// reflection centric in the true group (a squared Box-Muller normal), exponential otherwise, keyed
// on the asymmetric-unit index so the true group's symmetry is exact.
std::vector<MergedReflection> WilsonTetragonal(const char *true_group, double twin_fraction) {
// on the asymmetric-unit index so the true group's symmetry is exact. `anisotropy_b` is an extra
// Debye-Waller B along c* alone (A^2) - the same in both twin domains, a twin law being a lattice
// operation - and `scale_jitter` a log-normal factor of that width on every observed intensity,
// a nuisance with no direction that no normalisation removes.
std::vector<MergedReflection> WilsonTetragonal(const char *true_group, double twin_fraction,
double anisotropy_b = 0.0, double scale_jitter = 0.0) {
const gemmi::SpaceGroup &sub = gemmi::get_spacegroup_by_name(true_group);
const gemmi::SpaceGroup &super = gemmi::get_spacegroup_by_name("P 4 2 2");
const gemmi::Op twin = jfjoch_test::TwinLaw(sub, super);
@@ -237,7 +241,9 @@ namespace {
const double u2 = jfjoch_test::detail::UniformFromHkl({{asu[0] + 300, asu[1] + 300, asu[2] + 300}});
const double c = std::cos(2.0 * std::numbers::pi * u2);
const double e2 = gops.is_reflection_centric(hkl) ? -2.0 * std::log(u1) * c * c : -std::log(u1);
return 1000.0 * e2 * std::exp(-20.0 / (2.0 * std::pow(cell.calculate_d(hkl), 2)));
const double s_c = hkl[2] / cell.c;
return 1000.0 * e2 * std::exp(-20.0 / (2.0 * std::pow(cell.calculate_d(hkl), 2)))
* std::exp(-anisotropy_b * s_c * s_c / 2.0);
};
std::vector<MergedReflection> out;
for (int h = -19; h <= 19; ++h)
@@ -254,8 +260,12 @@ namespace {
r.k = k;
r.l = l;
r.d = static_cast<float>(d);
r.I = static_cast<float>((1.0 - twin_fraction) * true_intensity(hkl)
+ twin_fraction * true_intensity(twin.apply_to_hkl(hkl)));
const double u3 = jfjoch_test::detail::UniformFromHkl({{h + 700, k + 700, l + 700}});
const double u4 = jfjoch_test::detail::UniformFromHkl({{h + 900, k + 900, l + 900}});
const double jitter = std::exp(scale_jitter * std::sqrt(-2.0 * std::log(u3))
* std::cos(2.0 * std::numbers::pi * u4));
r.I = static_cast<float>(((1.0 - twin_fraction) * true_intensity(hkl)
+ twin_fraction * true_intensity(twin.apply_to_hkl(hkl))) * jitter);
r.sigma = static_cast<float>(0.01 * r.I + 1.0);
out.push_back(r);
}
@@ -268,8 +278,9 @@ namespace {
// stay acentric under it and are centric only where the added operators are real.
TEST_CASE("Twin-immune zones tell a perfect twin from real symmetry", "[twinning]") {
const gemmi::SpaceGroup &p422 = gemmi::get_spacegroup_by_name("P 4 2 2");
const gemmi::UnitCell tetragonal(47, 47, 63, 90, 90, 90);
const auto real = AnalyzeTwinImmuneZones(WilsonTetragonal("P 4 2 2", 0.0), p422);
const auto real = AnalyzeTwinImmuneZones(WilsonTetragonal("P 4 2 2", 0.0), tetragonal, p422);
REQUIRE(real.zones.size() == 3); // over 4, over 222, over the diagonal 222
for (const auto &z : real.zones) {
CAPTURE(z.operators);
@@ -280,11 +291,56 @@ TEST_CASE("Twin-immune zones tell a perfect twin from real symmetry", "[twinning
// A perfect P4 twin: whichever subgroup is taken as the parent, the operators added over it are
// not all real, and the zone reads acentric.
const auto twin = AnalyzeTwinImmuneZones(WilsonTetragonal("P 4", 0.5), p422);
const auto twin = AnalyzeTwinImmuneZones(WilsonTetragonal("P 4", 0.5), tetragonal, p422);
REQUIRE(twin.zones.size() == 3);
for (const auto &z : twin.zones) {
CAPTURE(z.operators);
CHECK(z.mean_abs_e2_minus_1 == Catch::Approx(0.736).margin(0.08));
CHECK(z.evidence_nats < 0.0);
CHECK(z.calibrated_evidence_nats < 0.0);
}
// Wilson data normalise cleanly: the control reads the acentric expectation and the
// calibration takes nothing off.
CHECK(real.control_excess_per_reflection < 0.01);
CHECK(twin.control_excess_per_reflection < 0.01);
}
// The zone is read absolutely, so it is only as good as the normalisation. A strong anisotropy
// leaves every class of an isotropically normalised merge reading centric, the acentric control
// included, and a zone - a plane - more so than the control's sphere; it is fitted and taken out
// before anything is read. What no normalisation removes, the control certifies: its excess over the
// acentric expectation is taken off every zone, so a partial twin's zone reads acentric and a real
// operator's centric, as they do on clean data.
TEST_CASE("Twin-immune zones are normalised for anisotropy and calibrated by the acentric control",
"[twinning]") {
const gemmi::SpaceGroup &p422 = gemmi::get_spacegroup_by_name("P 4 2 2");
const gemmi::SpaceGroup &p4 = gemmi::get_spacegroup_by_name("P 4");
const gemmi::UnitCell tetragonal(47, 47, 63, 90, 90, 90);
SECTION("a 60 A^2 anisotropy along c* is taken out") {
const auto twin = AnalyzeTwinImmuneZone(WilsonTetragonal("P 4", 0.2, 60.0), tetragonal, p422, p4);
REQUIRE(twin.zones.size() == 1);
CHECK(twin.anisotropy_delta_b_A2 == Catch::Approx(60.0).margin(15.0));
CHECK(twin.control.mean_abs_e2_minus_1 < 0.76); // a partial twin's control: at or below acentric
CHECK(twin.zones[0].calibrated_evidence_nats < -20.0);
const auto real = AnalyzeTwinImmuneZone(WilsonTetragonal("P 4 2 2", 0.0, 60.0), tetragonal, p422, p4);
REQUIRE(real.zones.size() == 1);
CHECK(real.control.mean_abs_e2_minus_1 == Catch::Approx(0.736).margin(0.05));
CHECK(real.zones[0].calibrated_evidence_nats > 20.0);
}
SECTION("a scale jitter no normalisation removes is calibrated off") {
const auto real = AnalyzeTwinImmuneZone(WilsonTetragonal("P 4 2 2", 0.0, 0.0, 0.6), tetragonal, p422, p4);
REQUIRE(real.zones.size() == 1);
CHECK(real.control.mean_abs_e2_minus_1 > 0.80); // inflated: the normalisation is wrong
CHECK(real.control_excess_per_reflection > 0.02);
CHECK(real.zones[0].calibrated_evidence_nats > 20.0);
// The twin's control is deflated by the twinning as much as the jitter inflates it, so
// nothing is taken off - and its zone, acentric, still reads so.
const auto twin = AnalyzeTwinImmuneZone(WilsonTetragonal("P 4", 0.2, 0.0, 0.6), tetragonal, p422, p4);
REQUIRE(twin.zones.size() == 1);
CHECK(twin.zones[0].calibrated_evidence_nats < -20.0);
}
}