scale_merge: score a half-integer twin law as given, not rounded to integers
OperatorScorer rounded each entry of the Miller-index matrix to an integer before building the gemmi operator, so a pseudo-merohedral law of a centred lattice - whose entries in the lattice's own basis are halves, such as the hexagonal two-folds of a C-centred cell with a = sqrt(3) b - was scored as a different operator altogether: on a crystal twinned by it at about 0.3 its pairs read unrelated (H 0.61, CC 0.02) where phenix.xtriage reads a Britton fraction of 0.33 for the same law, and the twin was missed. The entries are now kept in gemmi's 1/DEN units, and ScoreOperator skips an index whose image under the operator is not integral (the centring-absent class) instead of letting apply_to_hkl truncate it onto a reflection it does not relate. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HVeDQsU5a8AJUdJPgWevAK
This commit is contained in:
1 parent
fa94f24777
commit
fe6660cecf
2 files changed
+47
-2
No files matched your search
@@ -949,7 +949,13 @@ RowModulation FindRowModulation(const gemmi::UnitCell& cell, const std::array<in
|
||||
for (size_t i = 0; i < m.n; ++i) {
|
||||
if (!m.pass_cc[i] || visited[i] == epoch)
|
||||
continue;
|
||||
const auto m2 = op.apply_to_hkl(gemmi::Op::Miller{{m.H[i], m.K[i], m.L[i]}});
|
||||
// A pseudo-merohedral law of a centred lattice has half-integer entries in the lattice's own
|
||||
// basis (OperatorScorer), so it maps an index outside the centring onto non-integers; such an
|
||||
// image is no reflection, and apply_to_hkl would silently truncate it onto one.
|
||||
const auto scaled = op.apply_to_hkl_without_division(gemmi::Op::Miller{{m.H[i], m.K[i], m.L[i]}});
|
||||
if (scaled[0] % gemmi::Op::DEN != 0 || scaled[1] % gemmi::Op::DEN != 0 || scaled[2] % gemmi::Op::DEN != 0)
|
||||
continue;
|
||||
const auto m2 = gemmi::Op::divide_hkl_by_DEN(scaled);
|
||||
const HKLKey k2 = Canonicalize(m2[0], m2[1], m2[2], opt.merge_friedel);
|
||||
if (k2 == m.key[i])
|
||||
continue; // reflection lies on this rotation axis
|
||||
@@ -3209,12 +3215,16 @@ std::optional<SpaceGroupOperatorScore> OperatorScorer::operator()(const gemmi::M
|
||||
// gemmi applies an Op to Miller indices through the TRANSPOSE of its rot (Op::apply_to_hkl), and
|
||||
// writes an hkl triplet from the transpose as well, so the operator whose Miller-index matrix is M
|
||||
// is the Op holding M^T - and its triplet then reads as the rows of M, as everywhere else here.
|
||||
// The entries are kept in gemmi's 1/DEN units, not rounded to integers first: a pseudo-merohedral
|
||||
// law of a centred lattice (a C-centred cell with a = sqrt(3) b, say) has half-integer entries in
|
||||
// that basis, and rounding them scored a different operator - its pairs read unrelated (H 0.61, CC
|
||||
// 0.02) on a crystal twinned by it at 0.3.
|
||||
gemmi::Op op{};
|
||||
op.notation = 'h';
|
||||
op.tran = {0, 0, 0};
|
||||
for (int i = 0; i < 3; ++i)
|
||||
for (int j = 0; j < 3; ++j)
|
||||
op.rot[i][j] = static_cast<int>(std::lround(hkl_matrix[j][i])) * gemmi::Op::DEN;
|
||||
op.rot[i][j] = static_cast<int>(std::lround(hkl_matrix[j][i] * gemmi::Op::DEN));
|
||||
|
||||
const NormalisedMerge &nm = *impl->nm;
|
||||
std::vector<uint32_t> visited(nm.n, 0);
|
||||
|
||||
@@ -998,3 +998,38 @@ TEST_CASE("AnalyzeCentreOfSymmetry separates acentric from centric Wilson data")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A pseudo-merohedral twin law of a centred lattice has half-integer entries in the lattice's own
|
||||
// basis (a C-centred cell with a = sqrt(3) b is metrically hexagonal, and the hexagonal two-folds read
|
||||
// as h/2 +- 3k/2 ...): it maps the centring-present indices onto integers and the absent ones onto
|
||||
// halves. Scored as given it relates its own pairs; rounded to integers it is a different operator.
|
||||
TEST_CASE("Operator correlation of a half-integer pseudo-merohedral law") {
|
||||
const gemmi::Op law = gemmi::parse_triplet("h/2-k/2,-3/2*h-k/2,-l", 'h');
|
||||
gemmi::Mat33 m; // the Miller-index matrix of the law: h -> M h, rows as the triplet reads
|
||||
for (int i = 0; i < 3; ++i)
|
||||
for (int j = 0; j < 3; ++j)
|
||||
m[i][j] = static_cast<double>(law.rot[j][i]) / gemmi::Op::DEN;
|
||||
// Friedel-merged C-centred reflections whose intensity is a function of the orbit under the law.
|
||||
std::vector<MergedReflection> merged;
|
||||
for (int h = -8; h <= 8; ++h)
|
||||
for (int k = -8; k <= 8; ++k)
|
||||
for (int l = -8; l <= 8; ++l) {
|
||||
if ((h + k) % 2 != 0 || (h == 0 && k == 0 && l == 0))
|
||||
continue;
|
||||
const gemmi::Op::Miller hkl{{h, k, l}};
|
||||
const gemmi::Op::Miller mate = law.apply_to_hkl(hkl);
|
||||
const gemmi::Op::Miller neg{{-h, -k, -l}}, mate_neg{{-mate[0], -mate[1], -mate[2]}};
|
||||
if (hkl < neg)
|
||||
continue; // one Friedel mate
|
||||
const gemmi::Op::Miller rep = std::max({hkl, neg, mate, mate_neg});
|
||||
merged.push_back(MergedReflection{.h = h, .k = k, .l = l,
|
||||
.I = static_cast<float>(SyntheticIntensityFromAsu(rep)),
|
||||
.sigma = 1.0, .d = static_cast<float>(CalcSyntheticD(h, k, l))});
|
||||
}
|
||||
const auto score = OperatorCorrelation(merged, m);
|
||||
REQUIRE(score.has_value());
|
||||
CHECK(score->n_pairs > 300);
|
||||
CHECK(score->cc > 0.99); // on shell-normalised E^2, and the synthetic d does not follow the law exactly
|
||||
CHECK(score->h_stat == Catch::Approx(0.0).margin(1e-6));
|
||||
CHECK(score->op_triplet_hkl == "h/2-k/2,-3/2*h-k/2,-l");
|
||||
}
|
||||
Reference in new issue
Block a user