From df3a5939f00311a36a5f263d5e00031e4c824dd5 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Mon, 23 Nov 2026 10:38:16 +0100 Subject: [PATCH] Doubled cell: a class the probe has refused is reported, not merged Where the supercell probe reads no rise in the half-integer class and none is to be read on a merge, the doubled cell can only be the other answer - a merge written beside the answer, never adopted. Such a pass still integrated the whole sweep in the doubled cell and merged it, with its own space-group search and correction surfaces: 42 of the 47 doubled passes of the battery's rotation arms, 3-80 s each, 545 s in all (integration 179 s, scaling and merging 286 s - the space-group search alone 180 s), for _doubled files no check had read. The pass is not run for such a class. The report keeps what the probe measured (the SUPERCELL_* keys with the decision and the doubled cell under DOUBLED_CELL_ADOPTED, DOUBLED_CELL_DECISION and DOUBLED_CELL_OTHER_CELL) and says with DOUBLED_CELL_OTHER_MERGED whether the other cell was merged; the file keys follow only where it was. A class that rises on the probe, or a sweep too weak for the probe to read the rise, still merges both cells and decides with both in hand, exactly as before, so the other-answer-only pass setting (1824c721f) is gone with the pass it described. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01HVeDQrPqZ52Tp6rzzZGxf3 --- docs/RUGNUX_REPORT.md | 23 +++++++++------- rugnux/ResultReport.cpp | 20 ++++++++------ rugnux/Rugnux.h | 10 +++---- rugnux/RugnuxPasses.cpp | 52 ++++++++++++++++++++++++------------- rugnux/RugnuxScaleMerge.cpp | 7 +++-- 5 files changed, 66 insertions(+), 46 deletions(-) diff --git a/docs/RUGNUX_REPORT.md b/docs/RUGNUX_REPORT.md index 20718b218..d01beb8c6 100644 --- a/docs/RUGNUX_REPORT.md +++ b/docs/RUGNUX_REPORT.md @@ -898,9 +898,11 @@ in: a crystal whose two halves are nearly alike (a pseudo-translation) is descri spots of further lattice domains can land on the half-integer positions too. A `TRUE` is also a warning under the `SUPERCELL_POSSIBLE` flag, and the summary's `Supercell` line carries the same advice. -**Both cells merged.** Where the class stands clear of the six empty ones out to the limit, the run -integrates and merges the doubled cell as well, on the same orientation and geometry, writes both, and -decides with both merges in hand which one is the answer. Clear means: in at least three shells most of +**Both cells merged.** Where the class stands clear of the six empty ones out to the limit and the probe +reads it rising with resolution, or the sweep is too weak for the probe to read it, the run integrates +and merges the doubled cell as well, on the same orientation and geometry, writes both, and decides with +both merges in hand which one is the answer. A class that stands clear but does not rise on the probe +keeps the half cell without a second merge: the doubled cell could only have been the other answer. Clear means: in at least three shells most of the class's reflections are resolved from the lattice's and it stands at more than twice the strongest of the six in standard errors, and either the lattice's own reflections are measured there on the probe's frames ( 1) with the class above its noise, or the class reads five of its own standard errors - @@ -936,15 +938,16 @@ the translation test decide. Such a sweep has too few added reflections to read shell (the probe arm needs at least 1000), so there the share it modulates is read over all shells at once and taken at its lower bound: it has to be at least half two standard errors down. **`DOUBLED_CELL_RISE_READ_ON=`** says which (`PROBE` or `MERGE`). **`DOUBLED_CELL_ADOPTED=`** says which was written as the answer and **`DOUBLED_CELL_DECISION=`** why; +**`DOUBLED_CELL_OTHER_CELL=`** is the other hypothesis's cell and **`DOUBLED_CELL_OTHER_MERGED=`** whether +it was merged. Where the probe had already refused the doubled cell (no rise read on it, and none to be +read on the merge) it could only have been the other answer, never adopted, and it is not merged: the +decision and the cell are reported and no `_doubled` files are written. Where it was merged, **`DOUBLED_CELL_OTHER_FILE=`** names the other hypothesis's merged file (`_doubled.mtz`, or `_halfcell.mtz` where the doubled cell was adopted, with the rest of its files under the same -prefix), and **`DOUBLED_CELL_OTHER_CELL=`**, **`DOUBLED_CELL_OTHER_SPACE_GROUP=`**, -**`DOUBLED_CELL_OTHER_D_MIN=`**, **`DOUBLED_CELL_OTHER_CC_HALF=`** and, with `--model`, -**`DOUBLED_CELL_OTHER_R_FREE=`** describe it. Compare the two in refinement. -**`DOUBLED_CELL_OTHER_ANALYSED=`** is `FALSE` where the probe had already refused the doubled cell (no -rise read on it, and none to be read on the merge): that cell is merged and written as the other answer -only - its pass makes no analyses and no model validation or molecular replacement, so its `_doubled` -files are the reflection files alone and it has no R-free. +prefix), and **`DOUBLED_CELL_OTHER_SPACE_GROUP=`**, **`DOUBLED_CELL_OTHER_D_MIN=`**, +**`DOUBLED_CELL_OTHER_CC_HALF=`** and, with `--model`, **`DOUBLED_CELL_OTHER_R_FREE=`** describe it. +Compare the two in refinement. **`DOUBLED_CELL_OTHER_ANALYSED=`** says whether that pass made the +analyses and the model validation (it always does). ## Further lattices diff --git a/rugnux/ResultReport.cpp b/rugnux/ResultReport.cpp index 8958b5230..f2235baaa 100644 --- a/rugnux/ResultReport.cpp +++ b/rugnux/ResultReport.cpp @@ -2219,7 +2219,7 @@ ReportDocument BuildReportDocument(const std::string &output_prefix, "large - or the crystal's two halves are nearly alike and either cell describes it{}. {}", sc.h, sc.k, sc.l, sc.occupancy_pct, sc.rock_pct, domains ? ", or spots of the further lattice domains found land on those positions" : "", - result.doubled_cell + result.doubled_cell && !result.doubled_cell->other_suffix.empty() ? fmt::format("Both cells were merged; the other one is in {}.mtz - compare them in refinement", output_prefix + result.doubled_cell->other_suffix) : fmt::format("The doubled cell {:.2f} {:.2f} {:.2f} {:.2f} {:.2f} {:.2f} was not merged", @@ -2227,17 +2227,21 @@ ReportDocument BuildReportDocument(const std::string &output_prefix, sc.doubled_cell.alpha, sc.doubled_cell.beta, sc.doubled_cell.gamma))); if (result.doubled_cell) { const auto &h = *result.doubled_cell; + const bool other_merged = !h.other_suffix.empty(); Add(s, KeyBool("DOUBLED_CELL_ADOPTED", h.adopted)); Add(s, KeyEnum("DOUBLED_CELL_RISE_READ_ON", h.rise_on_merge ? "MERGE" : "PROBE", {"PROBE", "MERGE"})); Add(s, KeyText("DOUBLED_CELL_DECISION", h.decision)); - Add(s, KeyText("DOUBLED_CELL_OTHER_FILE", output_prefix + h.other_suffix + ".mtz")); Add(s, KeyText("DOUBLED_CELL_OTHER_CELL", CellString(h.other_cell))); - Add(s, KeyText("DOUBLED_CELL_OTHER_SPACE_GROUP", h.other_space_group)); - Add(s, KeyReal("DOUBLED_CELL_OTHER_D_MIN", h.other_d_min_A, "{:.2f}")); - Add(s, KeyReal("DOUBLED_CELL_OTHER_CC_HALF", h.other_cc_half, "{:.4f}")); - Add(s, KeyBool("DOUBLED_CELL_OTHER_ANALYSED", h.other_analysed)); - if (std::isfinite(h.other_r_free)) - Add(s, KeyReal("DOUBLED_CELL_OTHER_R_FREE", h.other_r_free, "{:.4f}")); + Add(s, KeyBool("DOUBLED_CELL_OTHER_MERGED", other_merged)); + if (other_merged) { + Add(s, KeyText("DOUBLED_CELL_OTHER_FILE", output_prefix + h.other_suffix + ".mtz")); + Add(s, KeyText("DOUBLED_CELL_OTHER_SPACE_GROUP", h.other_space_group)); + Add(s, KeyReal("DOUBLED_CELL_OTHER_D_MIN", h.other_d_min_A, "{:.2f}")); + Add(s, KeyReal("DOUBLED_CELL_OTHER_CC_HALF", h.other_cc_half, "{:.4f}")); + Add(s, KeyBool("DOUBLED_CELL_OTHER_ANALYSED", h.other_analysed)); + if (std::isfinite(h.other_r_free)) + Add(s, KeyReal("DOUBLED_CELL_OTHER_R_FREE", h.other_r_free, "{:.4f}")); + } } Add(s, Blank()); Add(s, Prose( diff --git a/rugnux/Rugnux.h b/rugnux/Rugnux.h index 58f2b3522..bdcffe7ba 100644 --- a/rugnux/Rugnux.h +++ b/rugnux/Rugnux.h @@ -944,12 +944,14 @@ struct ProcessResult { bool adopted = false; // the answer is the doubled cell, the other one the probed cell bool rise_on_merge = false; // the class's rise was read on the doubled merge, not the probe std::string decision; // why, in the words the run reports it in - std::string other_suffix; // _halfcell or _doubled: the other cell's files are + // _halfcell or _doubled: the other cell's files are . Empty where the other + // cell was not merged (the probe refused the doubled cell): then only other_cell is set. + std::string other_suffix; std::shared_ptr other_outputs; UnitCell other_cell{}; std::string other_space_group; double other_d_min_A = NAN, other_cc_half = NAN, other_r_free = NAN; - bool other_analysed = true; // false: the other cell was merged and written only, not analysed or validated + bool other_analysed = true; // false: the other cell was not analysed or validated }; std::optional doubled_cell; // The merged reflections as written, kept only where the run asks for them (the doubled-cell pass, @@ -1361,10 +1363,6 @@ class Rugnux { std::optional last_rotation_result_; // Keep the merged reflections on the result (ProcessResult::merged_reflections). bool keep_merged_reflections_ = false; - // The doubled cell's pass is the other answer only - the probe had already refused the doubled cell - // before it ran - so it merges and writes the cell and leaves out what serves a report it never makes: - // the analyses, the model validation and the molecular replacement. - bool other_answer_pass_ = false; // What the image sink is told the output pass is (RugnuxImageSink::Start): "_doubled" for the doubled // cell's pass, empty otherwise. std::string output_label_; diff --git a/rugnux/RugnuxPasses.cpp b/rugnux/RugnuxPasses.cpp index 7981ffd1f..3158276c9 100644 --- a/rugnux/RugnuxPasses.cpp +++ b/rugnux/RugnuxPasses.cpp @@ -2401,29 +2401,47 @@ ProcessResult Rugnux::DoubledCellHypothesis(RugnuxObserver *observer, ProcessRes }); doubled.extra_lattices.clear(); doubled.unconstrained.reset(); + const std::string lattice_text = fmt::format( + "lattice {} ({}-centred {}) doubled to {} ({}-centred {}){}", + CellText(last_rotation_result_->lattice.GetUnitCell()), last_rotation_result_->search_result.centering, + gemmi::crystal_system_str(last_rotation_result_->search_result.system), + CellText(doubled.lattice.GetUnitCell()), doubled.search_result.centering, + gemmi::crystal_system_str(doubled.search_result.system), + offered ? "; the first pass found this doubled cell as the larger of an axis-harmonic pair" : ""); + // Where the probe has already refused the doubled cell (no rise read on it and none to be read on the + // merge), a pass in it could only be the other answer: a merge of the doubled cell written beside the + // answer, never adopted. It is not run - on the battery that pass was 42 of 47 doubled passes, 3-80 s + // each, for a file nothing had read - and the report carries the probe's decision and the doubled + // cell without the files. + const bool settled = !on_merge && rises.empty() && lattice_class.empty(); + if (settled) { + logger.Info("Doubled-cell hypothesis: the half-integer class {} {} {} stands clear of the other classes out " + "to the limit - {}", sc.h, sc.k, sc.l, lattice_text); + ProcessResult::DoubledCell h; + h.decision = !on_probe + ? std::string("the probed cell stands: the added class stands clear of its null, but the probe's " + "frames do not measure the lattice in enough shells to read how it grows with " + "resolution") + : std::string("the probed cell stands: the added class, read on the probe, does not grow with " + "resolution to a quarter of the lattice's intensity, so the half cell describes the " + "crystal at high resolution too"); + h.other_cell = doubled.lattice.GetUnitCell(); + h.other_analysed = false; + logger.Info("Doubled-cell hypothesis: {} - the doubled cell is not merged", h.decision); + half.doubled_cell = h; + half.pass_decision = fmt::format("doubled-cell hypothesis refused on the probe ({}); {}", h.decision, + half.pass_decision); + return half; + } logger.Info("Doubled-cell hypothesis: the half-integer class {} {} {} stands clear of the other classes out " - "to the limit, so the run integrates and merges the doubled cell as well - lattice {} ({}-centred " - "{}) doubled to {} ({}-centred {}){}", sc.h, sc.k, sc.l, - CellText(last_rotation_result_->lattice.GetUnitCell()), last_rotation_result_->search_result.centering, - gemmi::crystal_system_str(last_rotation_result_->search_result.system), - CellText(doubled.lattice.GetUnitCell()), doubled.search_result.centering, - gemmi::crystal_system_str(doubled.search_result.system), - offered ? "; the first pass found this doubled cell as the larger of an axis-harmonic pair" : ""); + "to the limit, so the run integrates and merges the doubled cell as well - {}", sc.h, sc.k, sc.l, + lattice_text); if (observer) observer->OnStep("Doubled-cell hypothesis"); output_label_ = "_doubled"; force_rotation_result_ = doubled; keep_merged_reflections_ = true; - // Where the probe has already refused the doubled cell (no rise read on it and none to be read on the - // merge), the pass can only be the other answer: it is merged and written, not analysed or validated. - const bool settled = !on_merge && rises.empty() && lattice_class.empty(); - other_answer_pass_ = settled; - if (settled) - logger.Info("Doubled-cell hypothesis: the probe has refused the doubled cell already, so its pass merges " - "and writes it as the other answer only - no analyses, no model validation, no molecular " - "replacement"); - // The quality guard compares a refined pass against the header pass in the same cell; this pass is // in another cell and is judged here instead. quality_guard_pass1_.reset(); @@ -2436,7 +2454,6 @@ ProcessResult Rugnux::DoubledCellHypothesis(RugnuxObserver *observer, ProcessRes } force_rotation_result_.reset(); keep_merged_reflections_ = false; - other_answer_pass_ = false; output_label_.clear(); if (!d.has_merge_statistics || !d.consensus_cell) { logger.Warning("Doubled-cell hypothesis: the doubled cell merged nothing - the probed cell stays the answer"); @@ -2554,7 +2571,6 @@ ProcessResult Rugnux::DoubledCellHypothesis(RugnuxObserver *observer, ProcessRes ProcessResult &answer = adopt ? d : half; const ProcessResult &other = adopt ? half : d; h.other_suffix = adopt ? "_halfcell" : "_doubled"; - h.other_analysed = !settled; h.other_outputs = other.outputs; h.other_cell = *other.consensus_cell; h.other_space_group = other.space_group ? other.space_group->xhm() : std::string(); diff --git a/rugnux/RugnuxScaleMerge.cpp b/rugnux/RugnuxScaleMerge.cpp index 6ef876cd1..30009486c 100644 --- a/rugnux/RugnuxScaleMerge.cpp +++ b/rugnux/RugnuxScaleMerge.cpp @@ -2329,8 +2329,7 @@ bool Rugnux::ScaleMergeAndSymmetry(PipelineLocals &p) { size_t model_rotations = 0; std::optional model_group; gemmi::UnitCell model_cell; - // The doubled cell's other-answer pass runs without the model (Rugnux::other_answer_pass_). - const bool with_model = config_.model && !other_answer_pass_; + const bool with_model = config_.model != nullptr; if (with_model && write_output && !geometry_prepass) { const SearchModel m = PrepareSearchModel(*config_.model); model_predicted = m.failure_reason.empty() && m.predicted; @@ -4353,7 +4352,7 @@ bool Rugnux::ScaleMergeAndSymmetry(PipelineLocals &p) { // beside the molecular replacement too (finish_analyses), so it takes its own copy of the group: the // enantiomorph relabelling there changes the experiment's. std::future anisotropy; - if (!geometry_prepass && !superseded && !other_answer_pass_ && result.consensus_cell) { + if (!geometry_prepass && !superseded && result.consensus_cell) { AnisotropyRunInfo aniso_run; if (sm.statistics.sweep_quality.measured && sm.statistics.sweep_quality.sweep_deg > 0.0f) aniso_run.observed_rotation_deg = sm.statistics.sweep_quality.sweep_deg; @@ -4569,7 +4568,7 @@ bool Rugnux::ScaleMergeAndSymmetry(PipelineLocals &p) { // statistics text and its written reflections, and neither survives the run. The promotion flag // below is a different thing - it is what the SEARCH did, the second pass reads it, and it is // set either way. - if (!geometry_prepass && !superseded && !other_answer_pass_) { + if (!geometry_prepass && !superseded) { // Translational pseudo-symmetry first: its verdict is an input to the twinning analysis, // which must not read its own L-test when a non-half-integer pseudo-translation has biased // it. Reporting only - no reflection and no merge depends on the outcome, so a sweep of a joint