diff --git a/docs/CPU_DATA_ANALYSIS_DECISIONS.md b/docs/CPU_DATA_ANALYSIS_DECISIONS.md index 2ed92e620..ca447997e 100644 --- a/docs/CPU_DATA_ANALYSIS_DECISIONS.md +++ b/docs/CPU_DATA_ANALYSIS_DECISIONS.md @@ -30,7 +30,7 @@ The converted cut lies strictly below $\mathrm{ISa}$ for every $\mathrm{ISa}$, s The candidates are enumerated in **every setting the refined cell can host**, not only in the settings the International Tables call the reference one. A setting is a statement about direction — $P112_1$ puts its $2_1$ on $c$ where $P12_11$ puts it on $b$, and both are space group 4 — so a search restricted to reference settings can only ever put a screw or a centring on the axis the convention chose, whatever the data say. Two things bound the widened set. The cell's own metric is asked once, when a point group's rotation set is chosen — a set whose rotations it does not host ($\alpha=\beta=90^\circ$ for a $2$-fold on $c$) is not offered — and every setting of a chosen set is then offered without asking again, because a cell refined free after integration sits a few tenths of a degree off $90^\circ$ and asking per setting kept only the reference one; and a candidate predicting exactly the absences another candidate already predicts is dropped as the same hypothesis under a second name. A non-reference setting is additionally refused when its centring class holds no reflection in this merge, since there is then nothing to confirm it with. Because the candidates of a point group all share its rotations, this cannot raise the symmetry: it decides *which axes* carry the screws and the centring, never how many operators there are. The setting found this way is the one the *decisions* are made in. The files are then written in the ITA standard setting (as XDS and POINTLESS write it: $P2_12_12$ with the pure axis on $c$ and $a, <|E²-1|> and N(0.1), each calibrated against acentric and centric intensities simulated with the reflections' own sigmas, every reading lies in the range a Wilson population can produce, the reflections centric in both groups read centric, and the lattice excludes twinning (the metric admits no rotation beyond the Laue class and no twin-domain lattice was found), because a twinned centrosymmetric crystal reads exactly like an untwinned acentric one. Between two groups without a centre, the lowest-numbered is written. diff --git a/docs/RUGNUX_REPORT.md b/docs/RUGNUX_REPORT.md index 3906013af..dbda5737a 100644 --- a/docs/RUGNUX_REPORT.md +++ b/docs/RUGNUX_REPORT.md @@ -469,10 +469,15 @@ relative, or where a glide group was written. as one or more of `a`, `b`, `c`; when every screw the data could show was judged it reads `NONE` and, like the other keys whose answer is "nothing to report", is written only with `--developer`. It fires when the axial row a screw lives on was never recorded — it lay in the spindle's blind cone, -or outside the resolution range — so nothing was measured that could confirm or refuse the screw. +or outside the resolution range — so nothing was measured that could confirm or refuse the screw; and +when the row was recorded but could not have shown the screw either way: were the reflections the screw +would extinguish truly extinct, they would still read their measurement noise, and on a short or weakly +measured row that noise alone falls short of the evidence a screw needs. A pseudo-translation along +the row counts the same way: it holds the class a screw would extinguish at a fraction of the rest of +the row whether or not the screw is there, and the noise is read against that fraction. On such an axis `SPACE_GROUP_NAME=` is not an answer: the answer is that group **or** any of `SPACE_GROUP_ALTERNATIVES`, and no measurement in the run chooses between them. What is written to -the `.mtz`/`.cif`/`.hkl` is unchanged — the member claiming no screw, because a reflection file must +the `.mtz`/`.cif`/`.hkl` is unchanged — the member claiming no screw on that axis, because a reflection file must carry one group — and the report prints the axis, why the row could not be judged, and what the alternatives are. To settle it, record the missing row: a different crystal orientation, or a sweep that reaches it. With `--developer` the space-group section names the same axes in prose beside the diff --git a/image_analysis/scale_merge/SearchSpaceGroup.cpp b/image_analysis/scale_merge/SearchSpaceGroup.cpp index 37f800716..24d4c67c4 100644 --- a/image_analysis/scale_merge/SearchSpaceGroup.cpp +++ b/image_analysis/scale_merge/SearchSpaceGroup.cpp @@ -4,6 +4,7 @@ #include "SearchSpaceGroup.h" #include "TwinningAnalysis.h" #include "gemmi/twin.hpp" +#include "../../common/JFJochMath.h" #include "../../common/ParallelFor.h" #include @@ -788,6 +789,7 @@ RowModulation FindRowModulation(const gemmi::UnitCell& cell, const std::array key; std::vector pass_absence, pass_cc; std::vector Esq; // normalised over pass_absence - for the absence tests + std::vector EsqSigma; // the merged sigma on Esq's scale std::vector Ecc; // normalised over pass_cc - for the operator correlation // The equal-count resolution shell each reflection of the absence set fell in, low resolution // first, and how many there were; -1 outside the set. The pseudo-translation test measures its @@ -850,7 +852,8 @@ RowModulation FindRowModulation(const gemmi::UnitCell& cell, const std::array& subset, - std::vector* shell_out = nullptr, int* bins_out = nullptr) { + std::vector* shell_out = nullptr, int* bins_out = nullptr, + std::vector* sigma_out = nullptr) { std::vector E(n, 0.0); std::vector order; order.reserve(n); @@ -873,6 +876,8 @@ RowModulation FindRowModulation(const gemmi::UnitCell& cell, const std::array lo) ? sum / static_cast(hi - lo) : 0.0; for (size_t j = lo; j < hi; ++j) { E[order[j]] = mean > 0.0 ? I[order[j]] / mean : 0.0; + if (sigma_out) + (*sigma_out)[order[j]] = mean > 0.0 ? Sigma[order[j]] / mean : 0.0; if (shell_out) (*shell_out)[order[j]] = static_cast(b); } @@ -886,7 +891,8 @@ RowModulation FindRowModulation(const gemmi::UnitCell& cell, const std::array absence_shell(n, -1); int absence_shell_count = 0; - std::vector Esq = shell_normalised(pass_absence, &absence_shell, &absence_shell_count); + std::vector EsqSigma(n, 0.0); + std::vector Esq = shell_normalised(pass_absence, &absence_shell, &absence_shell_count, &EsqSigma); // Overlap guard (Stage A / correlation only): drop the extreme resolution-normalised-E tail, which // on a two-lattice crystal is the one-sided overlap contamination that poisons the operator CC. @@ -931,7 +937,8 @@ RowModulation FindRowModulation(const gemmi::UnitCell& cell, const std::array screw_absent_refl; std::map> row_present_esq; // The candidate's mirror directions, and the zone of each: the reflections it fixes, split @@ -2517,7 +2526,8 @@ SearchSpaceGroupResult SearchSpaceGroup( IoverSigma[i]}); else screw_absent_refl.push_back({RowOf(H[i], K[i], L[i]), Esq[i], - Esq[i] / tncs_expected[i], IoverSigma[i]}); + Esq[i] / tncs_expected[i], IoverSigma[i], + EsqSigma[i] / tncs_expected[i]}); } else { present_n += 1; present_sum += IoverSigma[i]; @@ -2593,7 +2603,7 @@ SearchSpaceGroupResult SearchSpaceGroup( // row is, so it contributes no evidence either way rather than being judged against the shell // mean; it is carried as an undetermined zone so the report can say so. struct ZoneSums { double sum_u = 0; double max_u = 0; int n_absent = 0; int n_control = 0; - int n_violations = 0; }; + int n_violations = 0; double sum_dead = 0; double max_dead = 0; }; std::map zones; for (const auto& a : screw_absent_refl) { const auto it = row_median.find(a.row); @@ -2655,6 +2665,11 @@ SearchSpaceGroupResult SearchSpaceGroup( if (!(violation && a.e_squared >= mit->second)) z.max_u = std::max(z.max_u, u); z.n_control = static_cast(row_present_esq.at(a.row).size()); + // What the reflection would read were it extinct: its measurement noise alone, of which + // the statistic keeps the positive part, E max(0, N(0, sigma)) = sigma / sqrt(2 pi). + const double dead = a.sigma_expected / std::sqrt(2.0 * PI) / mit->second; + z.sum_dead += dead; + z.max_dead = std::max(z.max_dead, dead); } } // Each zone is scored on its OWN evidence, and the strongest one speaks for the group. Pooling @@ -2699,7 +2714,9 @@ SearchSpaceGroupResult SearchSpaceGroup( for (const auto& [row, z] : zones) { const double sum_u = TrimmedZoneSum(z.sum_u, z.max_u, z.n_absent); const double ev = z.n_control > 0 ? ScrewZoneEvidence(sum_u, z.n_absent) : 0.0; - s.screw_zones.push_back({row, z.n_absent, z.n_control, ev}); + const double sum_dead = TrimmedZoneSum(z.sum_dead, z.max_dead, z.n_absent); + s.screw_zones.push_back({row, z.n_absent, z.n_control, ev, sum_dead, + z.n_control > 0 ? ScrewZoneEvidence(sum_dead, z.n_absent) : 0.0}); if (z.n_control > 0) { screw_sum_u += sum_u; screw_scored += z.n_absent; @@ -3089,35 +3106,49 @@ SearchSpaceGroupResult SearchSpaceGroup( } } - // A screw no axial reflection here could have confirmed (unreached_screws). The winner claims no - // screw and no glide; the candidate differs from it only by screws - same centring class, no glide - - // no reflection of its absent classes is a violation, and its evidence could not have reached the - // claim bar even with every predicted-absent reflection at the floor. - if (result.best_space_group.has_value() && result.candidates.front().screw_absent == 0 - && result.candidates.front().glide_absent == 0) { + // A screw no axial reflection here could have confirmed (unreached_screws). The candidate claims every + // screw the winner claims, on the same evidence, and more - same centring class, no glide - no + // reflection of its absent classes is a violation, and the rows it adds could not have reached the + // claim bar even were every predicted-absent reflection on them extinct: such a reflection still + // reads its measurement noise, divided by the pseudo-translation's modulation where one holds the + // row (ScrewZone::reach). Read at a floor instead of the noise, a short row looked able to decide: + // six weak h00 beside a control row itself at 2-8 could not have reached the bar of 8 nats + // even if extinct, and the screw was written as absent with no alternative; and a row whose odd class a + // pseudo-translation along it holds at 0.07 of the even one reads that class as present whether or + // not a screw extinguishes it. + if (result.best_space_group.has_value() && result.candidates.front().glide_absent == 0) { const SpaceGroupCandidateScore& w = result.candidates.front(); + const auto winner_zone = [&](const auto& z) { + return std::any_of(w.screw_zones.begin(), w.screw_zones.end(), [&](const auto& wz) { + return wz.row == z.row && wz.n_absent == z.n_absent && wz.evidence == z.evidence; + }); + }; for (const auto& s : result.candidates) { - if (s.selected || !s.consistent || s.screw_absent == 0 + if (s.selected || !s.consistent || s.screw_absent <= w.screw_absent || s.glide_absent != 0 || s.space_group.centring_type() != w.space_group.centring_type() - || s.centering_absence_evidence != w.centering_absence_evidence) + || s.centering_absence_evidence != w.centering_absence_evidence + || std::count_if(s.screw_zones.begin(), s.screw_zones.end(), winner_zone) + != static_cast(w.screw_zones.size())) continue; int scored = 0; - double reach = 0.0; + double sum_dead = 0.0, reach = 0.0; for (const auto& z : s.screw_zones) - if (z.n_control > 0) { + if (!winner_zone(z) && z.n_control > 0) { scored += z.n_absent; - reach = std::max(reach, ScrewZoneEvidence(0.0, z.n_absent)); + sum_dead += z.sum_dead; + reach = std::max(reach, z.reach); } - reach = std::max(reach, ScrewZoneEvidence(0.0, scored)); + reach = std::max(reach, ScrewZoneEvidence(sum_dead, scored)); if (reach >= opt.min_screw_absence_evidence) continue; result.unreached_screw_groups.push_back(s.space_group); result.unreached_screw_groups.insert(result.unreached_screw_groups.end(), s.same_absences.begin(), s.same_absences.end()); - const gemmi::GroupOps g = s.space_group.operations(); + const gemmi::GroupOps g = s.space_group.operations(), wg = w.space_group.operations(); for (const AxialRow& row : {RowOf(1, 0, 0), RowOf(0, 1, 0), RowOf(0, 0, 1)}) { const gemmi::Op::Miller hkl{{row[0], row[1], row[2]}}; if (!g.is_systematically_absent(hkl) || CenteringAbsent(g, hkl) + || (wg.is_systematically_absent(hkl) && !CenteringAbsent(wg, hkl)) || std::any_of(result.unreached_screws.begin(), result.unreached_screws.end(), [&](const auto& u) { return u.row == row; })) continue; diff --git a/image_analysis/scale_merge/SearchSpaceGroup.h b/image_analysis/scale_merge/SearchSpaceGroup.h index 3279adb63..18a63b6a3 100644 --- a/image_analysis/scale_merge/SearchSpaceGroup.h +++ b/image_analysis/scale_merge/SearchSpaceGroup.h @@ -81,6 +81,12 @@ struct SpaceGroupCandidateScore { int n_absent = 0; int n_control = 0; // 0 = undetermined: this row has no control class in the merge double evidence = 0.0; // nats; meaningless when n_control is 0 + // What the row could show at best: the zone's sum, and its evidence, were every predicted-absent + // reflection extinct and read at its measurement noise alone (divided, like the evidence, by a + // pseudo-translation's modulation where one holds the row). Below min_screw_absence_evidence the + // row cannot confirm the screw whatever the crystal is (see unreached_screws). + double sum_dead = 0.0; + double reach = 0.0; }; std::vector screw_zones; // Of the three axial rows, how many this group's screws extinguish while the merge holds no @@ -899,12 +905,13 @@ struct SearchSpaceGroupResult { int n_control = 0; // ...and the rest of the row, which an absence is judged against }; std::vector undetermined_screws; - // A screw the symmorphic winner claims no screw against only because nothing here could have shown - // one: a candidate whose absences no axial reflection contradicts, refused for want of evidence that - // its axial rows could not have reached however dead they were (one predicted-absent reflection - // reaches 6.9 nats, under min_screw_absence_evidence; one without a control class reaches nothing). - // Its rows, and the candidate with the groups that predict its absences. Report-only: kept apart - // from undetermined_screws and alternatives, which decisions downstream read. + // A screw the winner claims no screw against only because nothing here could have shown one: a + // candidate that adds screws to the winner's, whose absences no axial reflection contradicts, refused + // for want of evidence that its added rows could not have reached were every predicted-absent + // reflection extinct - read at its measurement noise, under a pseudo-translation's modulation where + // one holds the row (ScrewZone::reach); a row without a control class reaches nothing. Its rows, and + // the candidate with the groups that predict its absences. Report-only: kept apart from + // undetermined_screws and alternatives, which decisions downstream read. std::vector unreached_screws; std::vector unreached_screw_groups; diff --git a/rugnux/ResultReport.cpp b/rugnux/ResultReport.cpp index cfa6a1c73..c4160c2a0 100644 --- a/rugnux/ResultReport.cpp +++ b/rugnux/ResultReport.cpp @@ -1550,8 +1550,8 @@ ReportDocument BuildReportDocument(const std::string &output_prefix, " SPACE_GROUP_SCREW_UNDETERMINED names the axes whose SCREW these data could not\n" " decide at all:{}\n" " On those axes SPACE_GROUP_NAME is not an answer - the answer is it or any of\n" - " SPACE_GROUP_ALTERNATIVES, and no measurement here chooses. The lowest-numbered\n" - " group, the one claiming no screw, is what the .mtz/.cif/.hkl carry, because a\n" + " SPACE_GROUP_ALTERNATIVES, and no measurement here chooses. The group claiming no\n" + " screw on those axes is what the .mtz/.cif/.hkl carry, because a\n" " reflection file must name one group. To settle it, collect the missing row: a\n" " different crystal orientation, or a sweep that reaches it.", why))); } diff --git a/rugnux/RugnuxScaleMerge.cpp b/rugnux/RugnuxScaleMerge.cpp index 4939efa36..a6afe40f0 100644 --- a/rugnux/RugnuxScaleMerge.cpp +++ b/rugnux/RugnuxScaleMerge.cpp @@ -3936,9 +3936,11 @@ bool Rugnux::ScaleMergeAndSymmetry(PipelineLocals &p) { alts += " or " + g.xhm(); sg_search.alternatives.push_back(g); } - logger.Warning("The screw along {} is UNDETERMINED: its axial row holds too few reflections a screw would " - "extinguish to show one, however weak they are, and none that contradicts it. These data " - "say {}{}; {} is written because a reflection file must carry one group.", + logger.Warning("The screw along {} is UNDETERMINED: its axial row could not show one - were the reflections a " + "screw would extinguish extinct, their measurement noise (against a pseudo-translation's " + "modulation where one holds the row) would still read short of the evidence a screw needs - " + "and none contradicts it. These data say {}{}; {} is written because a reflection file must " + "carry one group.", axes, result.space_group->xhm(), alts, result.space_group->xhm()); } result.space_group_search = sg_search;