symmetry: carry the space group as the group, not as its number
The adopted space group travelled the pipeline as a bare int and was rebuilt downstream with find_spacegroup_by_number, which returns the reference setting. So every setting a number cannot name was destroyed one line after it was determined: P 1 1 2 came back as P 1 2 1, I 1 1 2 as C 1 2 1, R 3:R as R 3:H. DatasetSettings now holds the gemmi::SpaceGroup itself, DiffractionExperiment exposes it as GetGemmiSpaceGroup() / GetSpaceGroupOrP1(), and everything that used to take an int - HKLKeyGenerator (its int constructor is gone, so the compiler finds the callers), the merge, the R-free flags, French-Wilson, the reindexing ambiguity, the completeness enumeration, the MTZ and mmCIF exports, the model validation - takes the group. -S keeps the setting the symbol names rather than reducing it to a number. The end message carries both spellings and a reader prefers the name, since only the name keeps the setting while the number is what a reader written before the name understands. It carries them over CBOR too: the determined group was never serialised at all, so a group rugnux chose reached the master file only when the same process wrote it, and an online writer fell back to whatever the user had supplied at the start. Both keys are optional additions, so an older reader skips them and a newer one reads an older sender. On disk the master's /entry/sample/space_group carries the extended Hermann-Mauguin name and is what the reader takes the group from, so a setting survives a _process.h5 and the --mode scale that re-reads it; the number stays beside it and is the fallback for files written before. Every one of the 230 reference settings the old writer could produce reads back as itself, so older files are unaffected. Stage A and Stage B of the search still enumerate reference settings only, so this determines no group differently today - it is what the enumeration needs before it can be widened. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFEJG6WBQv8th4UJFNe53N
This commit is contained in:
@@ -44,6 +44,76 @@ TEST_CASE("HDF5DataType_ElemType","[HDF5]") {
|
||||
CHECK(type_u32.IsInteger());
|
||||
}
|
||||
|
||||
TEST_CASE("JFJochReader_SpaceGroupSetting", "[HDF5][Full]") {
|
||||
// A space group is carried through the master file as its name, not its number, because a number
|
||||
// only ever names the reference setting. Both groups here are non-reference settings that a
|
||||
// number destroys: "P 1 1 2" comes back from 3 as "P 1 2 1", and "R 3:R" from 146 as "R 3:H"
|
||||
// (short_name() loses that one too - only xhm() is faithful).
|
||||
const auto setting = GENERATE(std::string("P 1 1 2"), std::string("R 3:R"));
|
||||
const gemmi::SpaceGroup *sg = gemmi::find_spacegroup_by_name(setting);
|
||||
REQUIRE(sg != nullptr);
|
||||
|
||||
// The number is not a carrier for it, which is the whole reason the name is written.
|
||||
DiffractionExperiment by_number(DetJF(1));
|
||||
by_number.SpaceGroupNumber(sg->number);
|
||||
CHECK(by_number.GetGemmiSpaceGroup()->xhm() != setting);
|
||||
|
||||
DiffractionExperiment x(DetJF(1));
|
||||
x.FilePrefix("test_sg_setting").ImagesPerTrigger(1).OverwriteExistingFiles(true);
|
||||
x.SetSpaceGroup(*sg);
|
||||
CHECK(x.GetGemmiSpaceGroup()->xhm() == setting);
|
||||
CHECK(x.GetSpaceGroupNumber() == sg->number);
|
||||
|
||||
RegisterHDF5Filter();
|
||||
{
|
||||
StartMessage start_message;
|
||||
x.FillMessage(start_message);
|
||||
|
||||
EndMessage end_message;
|
||||
end_message.max_image_number = 0;
|
||||
end_message.space_group_name = sg->xhm();
|
||||
std::unique_ptr<NXmx> master = std::make_unique<NXmx>(start_message);
|
||||
master->Finalize(end_message);
|
||||
}
|
||||
{
|
||||
JFJochHDF5Reader reader;
|
||||
REQUIRE_NOTHROW(reader.ReadFile("test_sg_setting_master.h5"));
|
||||
auto dataset = reader.GetDataset();
|
||||
REQUIRE(dataset->experiment.GetGemmiSpaceGroup().has_value());
|
||||
CHECK(dataset->experiment.GetGemmiSpaceGroup()->xhm() == setting);
|
||||
}
|
||||
remove("test_sg_setting_master.h5");
|
||||
REQUIRE(H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("JFJochReader_SpaceGroupNumberOnly", "[HDF5][Full]") {
|
||||
// A file written before the name was recorded carries only the number; it still reads back, as
|
||||
// the reference setting the number names.
|
||||
DiffractionExperiment x(DetJF(1));
|
||||
x.FilePrefix("test_sg_number").ImagesPerTrigger(1).OverwriteExistingFiles(true);
|
||||
x.SpaceGroupNumber(96);
|
||||
|
||||
RegisterHDF5Filter();
|
||||
{
|
||||
StartMessage start_message;
|
||||
x.FillMessage(start_message);
|
||||
|
||||
EndMessage end_message;
|
||||
end_message.max_image_number = 0;
|
||||
std::unique_ptr<NXmx> master = std::make_unique<NXmx>(start_message);
|
||||
master->Finalize(end_message);
|
||||
}
|
||||
{
|
||||
JFJochHDF5Reader reader;
|
||||
REQUIRE_NOTHROW(reader.ReadFile("test_sg_number_master.h5"));
|
||||
auto dataset = reader.GetDataset();
|
||||
REQUIRE(dataset->experiment.GetGemmiSpaceGroup().has_value());
|
||||
CHECK(dataset->experiment.GetGemmiSpaceGroup()->xhm() == "P 43 21 2");
|
||||
}
|
||||
remove("test_sg_number_master.h5");
|
||||
REQUIRE(H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("JFJochReader_MasterFile", "[HDF5][Full]") {
|
||||
DiffractionExperiment x(DetJF(1));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user