From e8fbae879a6199156bf9dc225e27db27e405c6fb Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sun, 6 Sep 2026 21:53:17 +0200 Subject: [PATCH] rugnux: the two offline instruments go, and one release states one report version The finalist-ledger and glide instruments were built to measure a question each, over stored merges, and both questions have been answered. They were never asked for and they are not part of the product: neither is installed, both duplicate what rugnux itself does with a flag, and each is one more executable to keep linking. The --finalist-ledger mode stays where it belongs, in rugnux. Their removal also retires the CUDA device-link property they would have needed in the portable build, which is the shape of problem an unused target creates: a configuration nobody builds, breaking for a target nobody runs. The changelog claimed four different REPORT_VERSION values inside one unreleased section, which is development history rather than something a user can act on. A release states its report version once; the entries keep what they changed. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01EFEJG6WBQv8th4UJFNe53N --- docs/CHANGELOG.md | 11 ++-- rugnux/CMakeLists.txt | 13 +---- rugnux/rugnux_glide.cpp | 115 --------------------------------------- rugnux/rugnux_ledger.cpp | 107 ------------------------------------ 4 files changed, 7 insertions(+), 239 deletions(-) delete mode 100644 rugnux/rugnux_glide.cpp delete mode 100644 rugnux/rugnux_ledger.cpp diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b919e1613..d4e8474e2 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -7,19 +7,19 @@ * The rugnux results report carries `PATHOLOGY_FLAGS=`, one closed-vocabulary code per condition that warned, beside the plain-English `WARNING:` lines. * The rugnux results report warns when the merged data carry no usable signal, and when too little of reciprocal space was measured inside the fitted resolution. * `rugnux --developer` writes the full results report: the pipeline-internal keys and the long explanations the default report leaves out. -* The rugnux results report is shorter and its sections are renumbered 1-5 with no gaps; `REPORT_VERSION` is 8. +* The rugnux results report is shorter and its sections are renumbered 1-5 with no gaps. * `rugnux --mode scale` reports the detector tilt and direct beam of the geometry it re-scaled at, instead of zeros that read as a flat detector, and no longer warns that no image was indexed on a run whose lattice came from its input file. * The rugnux results report omits `FITTED_RESOLUTION` where the CC1/2 curve it is fitted on never falls off, instead of asserting a resolution the shell table refutes. -* The rugnux results report measures translational pseudo-symmetry and reports it as `TNCS_DETECTED=` and the `TNCS_*` keys under the `PSEUDO_TRANSLATION` flag, reporting a translation the merged data are exactly invariant under as `UNDECLARED_LATTICE_TRANSLATION=` under `LATTICE_TRANSLATION` instead; `REPORT_VERSION` is 10. +* The rugnux results report measures translational pseudo-symmetry and reports it as `TNCS_DETECTED=` and the `TNCS_*` keys under the `PSEUDO_TRANSLATION` flag, reporting a translation the merged data are exactly invariant under as `UNDECLARED_LATTICE_TRANSLATION=` under `LATTICE_TRANSLATION` instead. * The rugnux space-group search scores axial systematic absences against the intensity modulation of any half-integer pseudo-translation the merged data carry, instead of claiming a screw axis that the pseudo-translation alone explains. -* The twinning L-test pairs each reflection with a partner sharing the class of a detected pseudo-translation, so a crystal carrying one is no longer reported as untwinned because the pseudo-symmetry raised <|L|>; `L_TEST_VS_TNCS=` says whether it was repaired, unaffected, or could not be read at all, and `REPORT_VERSION` is 11. +* The twinning L-test pairs each reflection with a partner sharing the class of a detected pseudo-translation, so a crystal carrying one is no longer reported as untwinned because the pseudo-symmetry raised <|L|>; `L_TEST_VS_TNCS=` says whether it was repaired, unaffected, or could not be read at all. * The rugnux lattice search puts every rotation the cell metric can host to the intensities, so a crystal whose lattice is nearly but not exactly hexagonal is no longer processed in a point group of order two because the metric was named hexagonal. * `rugnux` counts a frame as indexed from 6 spots on its lattice rather than 9, so a weakly diffracting crystal whose frames cannot carry 9 is no longer refused the lattice it fits; `--min-indexed-spots` still overrides it. * The rugnux reindexing resolver refuses a reference correlation measured on too few reflections instead of scoring it zero, so a run is no longer reindexed on an operator that mapped almost everything outside the reference's coverage. * `SPACE_GROUP_ALTERNATIVES=` lists every candidate the absences support equally well, keyed on the absence evidence rather than on a raw count, so a group predicting one more absence on a zone the sweep never measured is no longer dropped from the list. * A screw axis whose absences the merged data show to be extinct is no longer refused because a handful of reflections in its class read as present, so a crystal whose strongest axial row carries rocking-curve tails from its neighbours is assigned the screw its absences support. * `-C` accepts a known cell in any equivalent description - conventional or primitive, centred or not - instead of only the reduced primitive form, so a centred cell given the way it is published no longer makes the run report that it found no lattice. -* The rugnux space-group search determines glide planes from zonal systematic absences, so a non-Sohncke space group such as P 2_1/c or Pbca is named where the run previously stopped at its Sohncke subgroup; the results report carries the best Sohncke group for the same data as `SOHNCKE_SPACE_GROUP=` on every run that searched for a space group, and `REPORT_VERSION` is 12. A centre of symmetry is not determinable from intensities and is never claimed. +* The rugnux space-group search determines glide planes from zonal systematic absences, so a non-Sohncke space group such as P 2_1/c or Pbca is named where the run previously stopped at its Sohncke subgroup; the results report carries the best Sohncke group for the same data as `SOHNCKE_SPACE_GROUP=` on every run that searched for a space group. A centre of symmetry is not determinable from intensities and is never claimed. * `rugnux` corrects each reflection for the sensor's quantum efficiency at the angle the diffracted beam meets the detector. * `rugnux` applies the sensor quantum-efficiency correction to still images processed on a GPU, which were left uncorrected while the same data on a CPU-only machine was corrected. @@ -38,7 +38,7 @@ * `rugnux` writes the unmerged MTZ by default, with a P1 merge beside it, a batch header for every image the observations span, and events kept to the same `--min-captured-fraction` as the merge, so a wrong space group can be re-merged in a scaling program without reprocessing. * `rugnux` decides which partials belong to one rocking event from an angle rather than a frame count, so a coarsely sliced sweep no longer joins two crossings of the Ewald sphere into a single full reflection. * `rugnux` writes reflection files in the conventions downstream programs read: `FreeR_flag` is 0 for the test set and 1 for the working set - it was the other way round - the merged and P1 MTZ carry the reserved `HKL_base` dataset so a CCP4 program reads the wavelength instead of falling back to 1.54187 A, and the merged mmCIF marks the free set as `_refln.status` = `f`. -* The rugnux results report carries the space groups the data cannot separate and the enantiomorph state, the model's verdict and what it was allowed to decide, the detector geometry measured and what a single sweep cannot determine, the resolution the CC1/2 fit reached, which reciprocal axis each anisotropic diffraction limit belongs to, and twinning measured before and after the space group was decided; `REPORT_VERSION` is 7, and `SPACE_GROUP_ENANTIOMORPH= DETERMINED_FROM_MODEL` is now `ASSUMED_FROM_MODEL`. +* The rugnux results report carries the space groups the data cannot separate and the enantiomorph state, the model's verdict and what it was allowed to decide, the detector geometry measured and what a single sweep cannot determine, the resolution the CC1/2 fit reached, which reciprocal axis each anisotropic diffraction limit belongs to, and twinning measured before and after the space group was decided, and `SPACE_GROUP_ENANTIOMORPH= DETERMINED_FROM_MODEL` is now `ASSUMED_FROM_MODEL`. * The rugnux results report records how the crystal sat on the goniometer as `SPINDLE_SYMMETRY_AXIS_ANGLE_DEG=` and `SPINDLE_SYMMETRY_AXIS_ORDER=` - the angle from the spindle to the nearest symmetry axis and that axis's order - on every rotation run that determined a space group, not only when the angle was small enough to warn about. * The rugnux results report writes `SPINDLE_LOST_UNIQUE_FRACTION=` - the fraction (0-1) of unique reflections the mounting made unmeasurable under the measured point group - with the same number in the HDF5 master as `/entry/MX/spindleLostUniqueFraction`, and the spindle-mounting warning fires on that exact number instead of on the angle to the nearest symmetry axis. * Stills and grid scans carry a per-image `spindle_blind_fraction` - how much of a rotation sweep's blind cone the crystal's orientation would make unrecoverable, 0.5 and above calling for a second orientation - through the CBOR stream, the HDF5 files as `/entry/MX/spindleBlindFraction`, the REST plot and scan-result APIs, and the viewer and frontend plots; an absent value means the frame could not be assessed and is not a 0. @@ -52,6 +52,7 @@ * `rugnux --mode calibration` refuses to write a `.poni` for a detector whose stored image is mirrored or turned by a multiple of 90 degrees, the format having no field for it. * CC1/2 is computed on half-sets of equal size, so every reflection measured more than once contributes to it, as in XDS and phenix.merging_statistics, and a CPU-only build now reports the same value as a CUDA one; reported CC1/2 values move slightly, most where multiplicity is low. * The rugnux manual is reorganised into task pages with a run overview and worked phenix / REFMAC5 / Phaser / SHELXC/D/E / POINTLESS-AIMLESS / careless examples, and the HDF5 and API documentation say how a grid scan records the angle its spindle stood at: the goniometer axis with a step of 0. +* The results report's `REPORT_VERSION` is 12. ### 1.0.0-rc.165 This is an UNSTABLE release. It includes many experimental features, as well as many AI generated fixes. We recommend using rc.152 for production use. diff --git a/rugnux/CMakeLists.txt b/rugnux/CMakeLists.txt index 54506ca8c..65f0669c1 100644 --- a/rugnux/CMakeLists.txt +++ b/rugnux/CMakeLists.txt @@ -33,24 +33,13 @@ ADD_EXECUTABLE(rugnux rugnux_cli.cpp) TARGET_LINK_LIBRARIES(rugnux Rugnux JFJochReader JFJochImageAnalysis JFJochWriter) INSTALL(TARGETS rugnux RUNTIME COMPONENT rugnux) -# Offline finalist-ledger instrument (triage only, not installed): runs the space-group evidence -# table over a stored P1-merged MTZ. -ADD_EXECUTABLE(rugnux_ledger rugnux_ledger.cpp) -TARGET_LINK_LIBRARIES(rugnux_ledger JFJochImageAnalysis JFJochReader gemmi) - -ADD_EXECUTABLE(rugnux_glide rugnux_glide.cpp) -TARGET_LINK_LIBRARIES(rugnux_glide JFJochImageAnalysis JFJochReader gemmi) - # libcufft_static.a carries a relocatable-device-code object (separate_callback.o), so an executable # linking it needs a CUDA device-link step -- without it the host link fails on an undefined # __cudaRegisterLinkedBinary_* symbol. CUDA 13 no longer ships libcufft_static_nocallback.a, which # used to be the way around it. CUDA_RESOLVE_DEVICE_SYMBOLS makes CMake emit that step while leaving # the host link driver alone, so the -march/-flto flags CI passes still apply. -# Every executable that links JFJochImageAnalysis needs it, not just rugnux: the two offline -# instruments below link the same library and so pull the same cufft object. IF (JFJOCH_PORTABLE_ONLY AND JFJOCH_CUDA_AVAILABLE AND TARGET CUDA::cufft_static) - SET_TARGET_PROPERTIES(rugnux rugnux_ledger rugnux_glide - PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON) + SET_TARGET_PROPERTIES(rugnux PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON) ENDIF() diff --git a/rugnux/rugnux_glide.cpp b/rugnux/rugnux_glide.cpp deleted file mode 100644 index 5c8cd6c9e..000000000 --- a/rugnux/rugnux_glide.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute -// SPDX-License-Identifier: GPL-3.0-only - -// Offline glide-plane instrument, built the same way as rugnux_ledger: it reads the P1 cross-check -// MTZ a rotation run already writes and asks the space-group search what it makes of it, printing -// the Sohncke answer and the glide (small-molecule) answer side by side. -// -// It exists to MEASURE the false-alarm rate of glide detection on a corpus of protein crystals -// without re-processing a single image: a protein is chiral and can have no glide plane, so every -// glide this prints on protein data is a false positive by construction, and the rate is what -// decides whether glide detection may touch the reported group at all. -// -// Usage: rugnux_glide [tag] [nthreads] [d_min_A] - -#include -#include -#include -#include -#include - -#include - -#include "../common/Reflection.h" -#include "../image_analysis/scale_merge/SearchSpaceGroup.h" - -int main(int argc, char** argv) { - if (argc < 2) { - std::cout << "Usage: rugnux_glide [tag] [nthreads] [d_min_A]" << std::endl; - return 1; - } - const std::string path = argv[1]; - const std::string tag = argc > 2 ? argv[2] : "-"; - const int nthreads = argc > 3 ? std::atoi(argv[3]) : 4; - const double d_min = argc > 4 ? std::atof(argv[4]) : 0.0; - - gemmi::Mtz mtz; - try { - mtz.read_file_gz(path, true); - } catch (const std::exception& e) { - std::cerr << "GLIDE\t" << tag << "\tREAD_FAIL\t" << e.what() << std::endl; - return 1; - } - const gemmi::Mtz::Column* ci = mtz.column_with_label("IMEAN", nullptr, 'J'); - const gemmi::Mtz::Column* cs = mtz.column_with_label("SIGIMEAN", nullptr, 'Q'); - if (ci == nullptr || cs == nullptr) { - std::cerr << "GLIDE\t" << tag << "\tNO_IMEAN" << std::endl; - return 1; - } - - std::vector merged; - merged.reserve(static_cast(mtz.nreflections)); - for (int i = 0; i < mtz.nreflections; ++i) { - const size_t row = static_cast(i) * mtz.columns.size(); - MergedReflection r; - r.h = static_cast(std::lround(mtz.data[row + 0])); - r.k = static_cast(std::lround(mtz.data[row + 1])); - r.l = static_cast(std::lround(mtz.data[row + 2])); - r.I = mtz.data[row + ci->idx]; - r.sigma = mtz.data[row + cs->idx]; - if (!std::isfinite(r.I) || !std::isfinite(r.sigma) || r.sigma <= 0.0f) - continue; - r.d = static_cast(mtz.cell.calculate_d( - {{static_cast(r.h), static_cast(r.k), static_cast(r.l)}})); - merged.push_back(r); - } - - SearchSpaceGroupOptions opt; - opt.nthreads = static_cast(std::max(1, nthreads)); - opt.cell = mtz.cell; - opt.enumerate_all_settings = true; - opt.enumerate_all_rotation_sets = true; - opt.d_min_limit_A = d_min; - - const auto run = [&](bool with_glide) { - opt.enumerate_non_sohncke = with_glide; - return SearchSpaceGroup(merged, opt); - }; - const auto base = run(false); - const auto full = run(true); - - const auto name = [](const std::optional& sg) { - return sg.has_value() ? (sg->is_reference_setting() ? sg->short_name() : sg->xhm()) - : std::string("-"); - }; - std::cout << "GLIDE\t" << tag << "\tMETA\tn=" << merged.size() - << "\tcell=" << mtz.cell.a << "," << mtz.cell.b << "," << mtz.cell.c - << "," << mtz.cell.alpha << "," << mtz.cell.beta << "," << mtz.cell.gamma - << "\tvol=" << mtz.cell.volume - << "\tpg=" << (full.point_group_hm.empty() ? "?" : full.point_group_hm) - << "\tbase=" << name(base.best_space_group) - << "\tbest=" << name(full.best_space_group) - << "\tsohncke=" << name(full.sohncke_space_group) - << "\tglide=" << name(full.glide_space_group) - // How CLOSE a non-Sohncke candidate got, which is the number a recalibration needs and - // "no glide was named" does not carry: the rank of the first non-Sohncke candidate in - // the ranked list (0 = it won), and the evidence gap to the winner. - << "\tns_rank=" << [&]{ - for (size_t i = 0; i < full.candidates.size(); ++i) - if (!full.candidates[i].space_group.is_sohncke()) - return static_cast(i); - return -1; - }() << std::endl; - // Every glide zone of every candidate that was scored, not only the winner's: the false-alarm - // rate is a property of the ZONES, and a zone that fell just under the bar is exactly what a - // calibration has to see. - for (const auto& c : full.candidates) - for (const auto& z : c.glide_zones) - std::cout << "GLIDE\t" << tag << "\tZONE\t" - << (c.space_group.is_reference_setting() ? c.space_group.short_name() - : c.space_group.xhm()) - << "\t" << z.label << "\tn_abs=" << z.n_absent << "\tn_ctl=" << z.n_control - << "\tubar=" << z.mean_u << "\tev=" << z.evidence << "\tev_per=" << z.evidence_per_reflection - << std::endl; - return 0; -} diff --git a/rugnux/rugnux_ledger.cpp b/rugnux/rugnux_ledger.cpp deleted file mode 100644 index 463049b75..000000000 --- a/rugnux/rugnux_ledger.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute -// SPDX-License-Identifier: GPL-3.0-only - -// Offline finalist-ledger instrument. Reads a P1-merged MTZ - the P1 cross-check dataset every -// rotation run already writes, which is the run's own observations at FULL resolution, production -// scaled, and folded under no symmetry at all - and prints the ledger for it. -// -// The point of reading THAT file is the one the space-group audit keeps arriving at: the search -// decides on a low-resolution, zeta-filtered SEARCH merge, and the full-resolution merge where a -// false operator shows itself is never consulted. This tool consults it, changes nothing, and is -// only an instrument: it exists to measure whether the separation is there before any gate is -// allowed to read it. -// -// A resolution limit may be passed as the 4th argument. That is the paired contrast the whole -// hypothesis rests on: the production search decides on a low-resolution merge, so running the same -// vector twice - once at full range, once cut back to the search range - asks whether the contrast a -// false operator shows is actually being thrown away by the cut, on one crystal, with everything -// else held identical. -// -// Usage: rugnux_ledger [tag] [nthreads] [d_min_A] - -#include -#include -#include -#include -#include - -#include - -#include "../common/Reflection.h" -#include "../image_analysis/scale_merge/SearchSpaceGroup.h" - -int main(int argc, char** argv) { - if (argc < 2) { - std::cout << "Usage: rugnux_ledger [tag] [nthreads]" << std::endl; - return 1; - } - const std::string path = argv[1]; - const std::string tag = argc > 2 ? argv[2] : "-"; - const int nthreads = argc > 3 ? std::atoi(argv[3]) : 4; - const double d_min = argc > 4 ? std::atof(argv[4]) : 0.0; - - gemmi::Mtz mtz; - try { - mtz.read_file_gz(path, true); - } catch (const std::exception& e) { - std::cerr << "LEDGER\t" << tag << "\tREAD_FAIL\t" << e.what() << std::endl; - return 1; - } - - const gemmi::Mtz::Column* ci = mtz.column_with_label("IMEAN", nullptr, 'J'); - const gemmi::Mtz::Column* cs = mtz.column_with_label("SIGIMEAN", nullptr, 'Q'); - if (ci == nullptr || cs == nullptr) { - std::cerr << "LEDGER\t" << tag << "\tNO_IMEAN" << std::endl; - return 1; - } - - std::vector merged; - merged.reserve(static_cast(mtz.nreflections)); - for (int i = 0; i < mtz.nreflections; ++i) { - const size_t row = static_cast(i) * mtz.columns.size(); - MergedReflection r; - r.h = static_cast(std::lround(mtz.data[row + 0])); - r.k = static_cast(std::lround(mtz.data[row + 1])); - r.l = static_cast(std::lround(mtz.data[row + 2])); - r.I = mtz.data[row + ci->idx]; - r.sigma = mtz.data[row + cs->idx]; - if (!std::isfinite(r.I) || !std::isfinite(r.sigma) || r.sigma <= 0.0f) - continue; - r.d = static_cast(mtz.cell.calculate_d( - {{static_cast(r.h), static_cast(r.k), static_cast(r.l)}})); - // I_half stays NaN: the merged MTZ carries no half-set columns, so the random-noise R floor - // cannot be formed here. Every ratio that needs it reads "-" in the table below, and the - // first step out of P1 - the one case with no other operator to be the reference - is - // therefore NOT measurable from a stored MTZ. It needs the in-process hook. - merged.push_back(r); - } - - SearchSpaceGroupOptions opt; - opt.nthreads = static_cast(std::max(1, nthreads)); - opt.cell = mtz.cell; - opt.enumerate_all_settings = true; - opt.enumerate_all_rotation_sets = true; - opt.d_min_limit_A = d_min; - // No lattice_system cap: the metric class this run indexed on is not in the file. Measured over - // 40 crystals when the same question was asked before, the cap was non-binding on every one of - // them, so releasing it here costs nothing and keeps the tool independent of the run's lattice. - - const auto result = SearchSpaceGroup(merged, opt); - - std::cout << "LEDGER\t" << tag << "\tMETA\tdmin=" << d_min << "\tn=" << merged.size() - << "\tcell=" << mtz.cell.a << "," << mtz.cell.b << "," << mtz.cell.c - << "," << mtz.cell.alpha << "," << mtz.cell.beta << "," << mtz.cell.gamma - << "\tpg=" << (result.point_group_hm.empty() ? "?" : result.point_group_hm) - << "\torder=" << result.point_group_order - << "\tsg=" << (result.best_space_group ? result.best_space_group->xhm() : "-") - << "\tbest_op_r=" << result.global_best_operator_r << std::endl; - for (const auto& e : result.point_group_ledger) - std::cout << "LEDGER\t" << tag << "\tROW\t" << e.point_group_hm << "\t" << e.order - << "\t" << e.min_class_cc << "\t" << e.r_added << "\t" << e.r_over_best - << "\t" << e.h_ratio << "\t" << e.chi2_over_best << "\t" << e.b_extra - << "\t" << e.b_over_parent - << "\t" << (e.adopted ? "ADOPTED" : e.eligible ? "eligible" : "refused") - << "\t" << (e.refused_reason.empty() ? "-" : e.refused_reason) << std::endl; - std::cout << std::endl << FinalistLedgerToText(result) << std::endl; - return 0; -}