diff --git a/image_analysis/structure_refinement/Refinement.cpp b/image_analysis/structure_refinement/Refinement.cpp index 924ed0803..a5c173e54 100644 --- a/image_analysis/structure_refinement/Refinement.cpp +++ b/image_analysis/structure_refinement/Refinement.cpp @@ -4150,7 +4150,31 @@ bool ProperSubgroup(const gemmi::GroupOps &sub, const gemmi::GroupOps &super) { for (const gemmi::Op::Tran &cen : sub.cen_ops) if (std::find(super.cen_ops.begin(), super.cen_ops.end(), cen) == super.cen_ops.end()) return false; - return true; + // The translations too, on some origin of sub: moved by p, its operator (R, t) reads (R, t + (R - 1) p). The + // rotations alone also pass a 2 where super has a 2(1) - P 1 2 1 is a subgroup of P 21 21 2 on no origin, and a + // model refined under it would overlay copies where the data have none. + constexpr int D = gemmi::Op::DEN; + for (int px = 0; px < D; ++px) + for (int py = 0; py < D; ++py) + for (int pz = 0; pz < D; ++pz) { + const int p[3] = {px, py, pz}; + bool all = true; + for (const gemmi::Op &op : sub.sym_ops) { + gemmi::Op moved = op; + for (int i = 0; i < 3; ++i) + moved.tran[i] += (op.rot[i][0] * px + op.rot[i][1] * py + op.rot[i][2] * pz) / D - p[i]; + moved.wrap(); + const gemmi::Op &s = *super.find_by_rotation(op.rot); + if (std::none_of(super.cen_ops.begin(), super.cen_ops.end(), + [&](const gemmi::Op::Tran &cen) { return s.add_centering(cen) == moved; })) { + all = false; + break; + } + } + if (all) + return true; + } + return false; } std::vector ExpandToSubgroup(const std::vector &merged, const gemmi::SpaceGroup &from, diff --git a/image_analysis/structure_refinement/Refinement.h b/image_analysis/structure_refinement/Refinement.h index 484001fd5..08861f2a7 100644 --- a/image_analysis/structure_refinement/Refinement.h +++ b/image_analysis/structure_refinement/Refinement.h @@ -284,7 +284,8 @@ struct RefinementResult { // As REFMAC5 keeps twin-related reflections in one set (Roversi et al. (2012) Acta Cryst. D68, 418-424) int CloseFreeSet(std::vector &merged, const gemmi::UnitCell &cell, const gemmi::SpaceGroup &sg); -// Whether every operation of `sub` is one of `super`'s (its rotation, and its centring), `super` the larger group: +// Whether every operation of `sub` is one of `super`'s (its rotation, its translation on some origin of `sub`, and its +// centring), `super` the larger group: // `sub` is then a group the data merged in `super` could not tell from it (a P2(1) crystal whose copies are // pseudo-symmetric, merged in P4(1)2(1)2). bool ProperSubgroup(const gemmi::GroupOps &sub, const gemmi::GroupOps &super); diff --git a/tests/RefinementTest.cpp b/tests/RefinementTest.cpp index 7f84cf8f4..cfe691ecc 100644 --- a/tests/RefinementTest.cpp +++ b/tests/RefinementTest.cpp @@ -1281,6 +1281,11 @@ TEST_CASE("Refinement_model_in_a_subgroup_of_the_data", "[Refinement]") { CHECK(!ProperSubgroup(super.operations(), sub.operations())); CHECK(!ProperSubgroup(sub.operations(), sub.operations())); CHECK(!ProperSubgroup(gemmi::find_spacegroup_by_name("C 1 2 1")->operations(), super.operations())); + // the translations count, on any origin of the subgroup + const gemmi::GroupOps p21212 = gemmi::find_spacegroup_by_name("P 21 21 2")->operations(); + CHECK(ProperSubgroup(gemmi::find_spacegroup_by_name("P 1 21 1")->operations(), p21212)); + CHECK(ProperSubgroup(gemmi::find_spacegroup_by_name("P 1 1 2")->operations(), p21212)); + CHECK(!ProperSubgroup(gemmi::find_spacegroup_by_name("P 1 2 1")->operations(), p21212)); gemmi::Structure truth = residue_crystal({"TRP"}, cell, "P 1 21 1", 5); { // the residue's mate by the 2-fold along a, exact: the crystal is then P 2 2(1) 1 (pseudo-P2(1)2(1)2(1))