Repository navigation
Add diagnostic-supported RNA routes and optional route scoring - #10913
Conversation
timosachsenberg
left a comment
There was a problem hiding this comment.
Focused review of the newly split route-scoring code. One previously reported P2 regression remains in this PR (superseded #10906). I compiled and ran a standalone C++20 extraction of the current DP with g++ -O2: for four matched ion interpretations, it produces no route at min_nodes=3, even though a valid three-node, no-reused-peak path exists. This validates the DP failure, not the complete OpenMS build; no full OpenMS tests were run.
| && paths[j].weighted_intensity + current.weighted > paths[i].weighted_intensity)) | ||
| { | ||
| paths[i] = paths[j]; | ||
| paths[i].matches.push_back(current); |
There was a problem hiding this comment.
P2 — Preserve alternative prefixes with distinct used peaks. This is still the bug reported on the now-superseded #10906 review. The DP keeps only the longest/heaviest prefix ending at i, but whether it can be extended depends on all observed peaks already used. A shorter/lighter alternative at the same i can avoid a peak needed later, so discarding it loses a valid route.
I compiled and executed a standalone C++20 reproduction of the current loop (g++ -std=c++20 -O2), with sorted (position, peak, neutral, weight) matches (2,0,601,10), (2,1,601.001,2), (3,2,901,3), (4,0,1202,8) and max_step=2. The current DP chooses peak0 → peak2 at position 3 and cannot append peak0 at position 4. It returns 0 qualifying routes at min_nodes=3, although peak1 → peak2 → peak0 is a valid three-node path. This is a targeted algorithm test, not an OpenMS integration test. Please retain non-dominated alternatives distinguished by used-peak identities (or use a bounded path search), and add a regression covering alternative charge hypotheses of one observed peak.
There was a problem hiding this comment.
Written by an AI agent using GPT-6.
Addressed in dda2671. The scorer now keeps alternative prefixes distinguished by still-relevant used peak identities. It merges equivalent states only after retaining the longest/heaviest prefix, and forgets an identity only after that peak's last possible rung. Backpointers preserve the complete route for scoring.
The regression uses real poly-A c-ion theory with an ambiguous c2/charge-1 versus c4/charge-2 peak, in both polarities: the previous implementation returns no qualifying route; the fix finds the three-node alternative. A separate shorter-prefix regression and 576 exhaustive-path comparisons also pass. The existing routes:max_states bounds the exact search; exhaustion fails without exporting partial identifications.
Both GCC 13 and Clang 18/OpenMP pass the five affected C++ test executables and all 15 NASE TOPP/fixture checks. The review thread remains open for your verification.
timosachsenberg
left a comment
There was a problem hiding this comment.
AI-generated initial review
This is an automated, AI-generated first review. It looks only for high- and medium-priority issues (no nits) and checks whether the PR has tests and measurements. Please double-check anything before acting on it; a maintainer will follow up. I reviewed 3511afc3 against its base codex/nase-stack/06-graph-tags (d607c431).
What I ran:
-
Build: current develop (
65851d70) with the whole stack merged on top (#10909–#10913, which merge cleanly). The stack changes no library sources compared with develop. Release, Linux, GCC 13.3,OPENMS_USE_VCPKG=OFFwith system packages. -
Tests:
RNASensitivity_test,NASEDigestion_test,RNASpectrumGraph_test,ModifiedNASequenceGenerator_test,SpectrumAnnotator_testand all 15TOPP_NucleicAcidSearchEngine*tests pass. -
CI: because the PR is stacked, only cppcheck ran;
build-and-testdid not run. So far this local build is the only full build and test of this code. -
Real data (PXD016328, HAP1 tRNA,
HAP1_tRNA_clone1_rep1, with the target/decoy FASTA from the same PRIDE project):- Settings: RNase T1, 2 missed cleavages, 3 ppm / 3 ppm, 13 variable modifications (D m1A m5C m7G Cm Gm Um m1G m2G t6A I m5U i6A),
fdr:decoy_pattern DECOY_, 4 threads. - "Raised limits" are the HAP1 profile's:
routes:max_supports 20000000,max_states 1000000,max_candidates 5000000,max_completion_nodes 1000000000. - Columns: target PSMs at q ≤ 1 / 5 / 10 %, one per spectrum.
input settings target PSMs spectra with a q-value wall time RT 35–39 min (943 MS2) enumeration, HyperScore (default)109 / 143 / 154 611 37 s graph_routes, all route defaults (completion labile)63 / 95 / 99 254 25 s graph_routes,completion bounded, default limitsaborts after 15 s: support_limitat scan 6669, 675 spectra unattempted– – graph_routes,completion bounded, raised limits109 / 143 / 154 (same spectra and labels as enumeration) 529 75 s same + scoring:method route169 / 181 / 191 530 76 s graph_routesdefaults,-digestfrom the previous run (finding 1)87 / 107 / 129 151 25 s whole run (10,992 MS2) enumeration, HyperScore546 / 1,154 / 1,711 6,076 74 s graph_routes, all route defaultsaborts after 29 s: route_state_limitat scan 2714, 8,317 spectra unattempted– – graph_routes, route defaults (completion labile), raised limits455 / 726 / 1,312 (451 at 1 % identical to enumeration, 0 new) 3,057 6 min 11 s graph_routes,completion bounded, raised limits546 / 1,178 / 1,710 (all 546 at 1 % identical to enumeration) 5,724 20 min 12 s - Settings: RNase T1, 2 missed cleavages, 3 ppm / 3 ppm, 13 variable modifications (D m1A m5C m7G Cm Gm Um m1G m2G t6A I m5U i6A),
Verdict:
- High priority: one. A cached digest silently drops all missed-cleavage candidates in
graph_routes. - Medium priority: three:
- fixed terminal modifications remove all interior products;
- the export step undoes the parent-match filtering;
- with the defaults,
graph_routeseither loses many modified identifications or aborts on real data.
- The earlier route-scorer finding is fixed:
dda2671holds (details below), and the open thread onRNARouteScorer.cppcan be resolved.
High priority
1. graph_routes with -digest validates cleavage with missed_cleavages = 0
-
Where:
NucleicAcidSearchEngine.cpp:2743callsvalidator.setMissedCleavages(search_param.missed_cleavages). -
The cause:
search_param.missed_cleavagesis only set in the fresh-digest branch (l. 1995). The cached branch copies the enzyme (l. 2138) and stores the cached count incurrent_search(l. 2171), but never insearch_param. TheDBSearchParamdefault of 0 therefore stays in place, and every product that spans an internal cut fails the modification-aware check. -
Confirmed on real data (the slice above, route defaults, 2 missed cleavages):
fresh, -database … -digest_out d.omscached, -digest d.omshits with an internal G (≥ 1 missed T1 cleavage) 108 0 spectra with a q-value 254 151 target PSMs at q ≤ 1 / 5 / 10 % 63 / 95 / 99 87 / 107 / 129 - 103 spectra lose their hit; 90 of those were missed-cleavage products.
- 20 of the remaining spectra change label.
- The q-values shift because the decoy population changes (71 → 18 decoy best hits).
-
Why the tests miss it:
NASEDigestion_testcompares cached with fresh only foroligo:cleavage_model canonical. Its parentACUACUAGalso has no internal T1 site. -
Mitigation: set
search_param.missed_cleavages = search_ref->missed_cleavages;next to l. 2138, or reject a mismatch. Then add a cached-vs-freshmodification_awaretest on a parent with an internal cut site.
Medium priority
2. A fixed terminal modification plus the default routes:terminal_states enzyme removes every interior product
- Where:
NucleicAcidSearchEngine.cpp:2064–2069andRNARouteCandidateGenerator.cpp:554–556. - The cause:
- The route digest strips the termini of interior products and then applies all fixed modifications, terminal ones included. So every product is stored with the fixed terminal group.
- The generator keeps a pair only if
five/threematch the stored termini (hasFivePrimeMod() && five != 1…). - The enzyme mask for interior positions uses the RNase's own termini instead, so the two never agree.
- Enumeration instead applies the enzyme's termini first and fills only a missing end with the fixed modification.
- Confirmed on real data (slice,
-modifications:fixed "5'-p"): enumeration returns 5,678 hits, 5,524 of them interior products.graph_routesreturns 12 hits, none of them interior. - Mitigation: derive the termini as enumeration does (the enzyme's termini first, then the fixed terminal modification only where no terminus is set), or reject fixed terminal modifications in
graph_routeswith a clear error. Add a test.
3. The parent-match filtering of graph_routes is undone at export
- Where:
NucleicAcidSearchEngine.cpp:1335–1339. - The cause:
postProcessHits_copies the filteredhit.parent_override, sets the sequence, and callsregisterIdentifiedOligo().- The route digest stores products with stripped termini (l. 2064–2066). So for a candidate whose termini are also "none" (5'-OH/3'-OH), the sequence equals an existing digest entry.
insertIntoMultiIndex_then merges into that entry, andIdentifiedSequence::mergetakes the union of parent matches. The termini/cleavage filtering is lost.
- Failing case: a sequence
Sthat is the 3'-terminal product of a decoy (3'-OH) and an interior product of a target. The digest stores it as one entry with parents {target, decoy}. The 3'-OH hit is correctly narrowed to {decoy}, but after the merge it maps to {target, decoy}.allParentsAreDecoys()is then false, so a decoy-only PSM counts as a target and makes the FDR too optimistic. Enumeration keepsSandSpas separate oligos and gets this right. - Evidence: confirmed by reading the code only. I checked all graph_routes outputs above, and no 3'-OH hit maps to a parent where it is interior. That configuration doesn't arise with this FASTA (T1 cuts, reversed decoys and
oligo:min_size 5), but it can with other decoy schemes, enzymes or databases. - Mitigation: keep the deferred digest outside the output
IdentificationData, or register products with concrete termini. Add a test where a target and a decoy share a sequence at different termini.
4. With the defaults, graph_routes either loses modified identifications or aborts on real data
- Slice: with all route defaults (
completion labile), 47 of the 109 enumeration identifications at 1 % are lost, and all 47 are modified. 46 carry t6A: a labile modification is completed only with diagnostic support, anddiagnostic:fixed_ionsis empty by default. The HAP1 profile setst6A=279.08418. completion bounded, which recovers all 109 with identical labels, aborts with the defaultroutes:max_supports.- Whole run:
- Even the default
labilecompletion aborts with the defaultroutes:max_states. - With raised limits it completes, but finds 455 instead of 546 PSMs at 1 % (−17 %) and 726 instead of 1,154 at 5 % (−37 %), in 6 min instead of 74 s. 86 of the 91 PSMs lost at 1 % carry t6A.
- With
boundedand raised limits it matches enumeration (all 546 at 1 %, +24 at 5 %), but takes 20 min instead of 74 s.
- Even the default
- The abort message (
Incomplete route search for … : support_limit/route_state_limit) doesn't name the option to raise. - The mode is opt-in and documented as experimental, but as shipped it doesn't complete one real tRNA run.
- Mitigation:
- size the default limits so that a typical tRNA run completes;
- name the parameter in the error (e.g.
support_limit (raise routes:max_supports)); - warn when a labile variable modification is searched with
completion labilebut no diagnostic ion is configured.
Checked and fine
dda2671(alternative prefixes): correct.- The state key (end match plus the used peaks that can still recur) captures everything that affects later extensions.
- Identities expire only once their last possible rung has passed.
- Keeping the best prefix per state is safe, because node counts and weights add up along the route.
- The tie-break gives a strict total order, so the result is deterministic.
- Comparison: I extracted the scorer and compared it with brute-force path enumeration on 400k random instances: peaks reused across charges, non-monotone masses,
max_step1–3,min_nodes1–3, integer weights to force ties. There were 0 mismatches, tie-breaks included. The pre-fix version gave more than 5,000 mismatches on the same instances. This was a standalone extraction, not a NASE run. max_statesexhaustion is caught inside both OpenMP loops and fails the run without writing output.
3511afc, cheaper cleavage check: equivalent to the old full-parent re-digestion in 300k random cases (cuts-after/cuts-before patterns, missed cleavages 0–2, products at the parent ends, modified residues inside the product), with 0 differences.- One difference from enumeration remains, possibly intended but worth a sentence in the docs: modification-aware validation also counts cuts created by a modification (T1 after inosine). So inosine products that already use the full missed-cleavage budget are dropped in
graph_routesbut kept by enumeration.
- One difference from enumeration remains, possibly intended but worth a sentence in the docs: modification-aware validation also counts cuts created by a modification (T1 after inosine). So inosine products that already use the full missed-cleavage budget are dropped in
- Terminal states: the enzyme masks match
RNaseDigestion's terminal gains for T1, A, U2, H, unspecific and no cleavage. Targets and decoys go through the same code. - Linkage modifications: they are rejected in the generator constructor, outside OpenMP, with a clear error.
- Defaults: HyperScore and enumeration stay the defaults.
scoreNativeSpectrum_makes the same HyperScore/MVH calls as before, and no TOPP reference file changes. The route score goes through the same competition and FDR path for targets and decoys.
Tests
- You added: route-scorer regressions (shorter/lighter extendable prefixes, a real charge-ambiguity case in both polarities, 576 exhaustive comparisons, identity expiry, exhaustion), generator tests for terminal masks and linkage rejection, and end-to-end route tests.
- Missing:
- a cached-vs-fresh
modification_awareroute test on a parent with an internal cut site (finding 1); - fixed terminal modifications in
graph_routes(finding 2); - a target/decoy pair sharing a sequence at different termini (finding 3);
- the end-to-end
terminal_states=enzymecheck only asserts properties of the hits it finds, so it would still pass with zero hits. Please assert that an interior product (e.g. a T1 product ending in 3'-p) is actually found.
- a cached-vs-fresh
Measurements
-
You provided:
- the HAP1 profile (
doc/benchmarking/nase/…json): 9 files, 10 decoy seeds; - a replay of three clone-1 files after the reuse refactor, with identical assignments.
You say clearly that these are not an independent accuracy benchmark, and that the profile (with
terminal_states=all) was not rerun after3511afc. - the HAP1 profile (
-
What the numbers show:
- The 1 % count depends heavily on the decoy seed: 6,369 to 15,548 PSMs across the ten seeds (2.4×). At 5 % the range is 19,924–21,648 and at 10 % it is 23,454–25,001.
- No baseline: the JSON has no comparison with enumeration + HyperScore on the same files and decoys.
-
Added above:
- On the slice, route scoring reports 169 target PSMs at 1 % against 109 for enumeration/HyperScore.
- All 109 enumeration spectra are kept, but 27 of them get a different label: 16 differ only in modification positions, and 11 in isobaric modifications or sequence (e.g.
m5C→Cm,m5U+m1A→Um+Cm). - Of the 60 additional spectra, enumeration had the same label at a lower confidence for 39 and a different one for 21.
- Without ground truth, more PSMs at a nominal q-value doesn't show they are correct.
-
Suggestion: before route scoring is recommended to users:
- compare against enumeration + HyperScore on the same files and decoys;
- report the 5 % level (or the spread over seeds) rather than the single 1 % count;
- ideally add an entrapment database (e.g. tRNAs of a distant species) to check that the extra identifications are not false positives.
Description
- The AI use is disclosed, and the commits carry
Co-authored-by:trailers. The template's confirmation box ("I have read the OpenMS AI Policy, and I understand, have reviewed and tested every change …") is not in the description yet. The description says human review is still pending.
Generated by Claude Code
|
Written by an AI agent using GPT-6. Addressed the remaining code findings from your review in e50af35:
Fresh GCC 13 and Clang 18/OpenMP builds against the installed core each pass five affected C++ executables and all 15 NASE TOPP/fixture checks. I also reran a paired baseline with your 13-modification panel and 3 ppm tolerances, the same PRIDE FASTA, and no route/diagnostic/limit overrides. On the slice, enumeration and default graph routes with HyperScore both yield 109/143/154 with identical accepted calls. On the whole recording they yield 546/1154/1711 and 546/1177/1708; all baseline accepted calls at 1% and 5% are retained. Whole-run times were 15/136 seconds at 16 threads here. The machine-readable profile records inputs, shared mappings, assignment overlap and limitations. The optional route score reproduces 169/181/191 on the slice, including the 27 changed baseline assignments at 1%. This does not establish their correctness. No entrapment or new seed sweep was performed; route scoring remains experimental, and the earlier nine-file results were not rerun. The description now includes the exact human-policy confirmation box, left unchecked for the human contributor to attest. Review threads remain open. |
Co-authored-by: OpenAI Codex (GPT-6) <[email protected]>
Retain prefixes with distinct future-relevant used peaks instead of selecting a single path at each endpoint. Expire identities after their last possible rung and reconstruct full routes through backpointers. Reuse routes:max_states to bound exact scoring and fail without partial identifications on exhaustion, including OpenMP enumeration. Add charge-ambiguity regressions and an exhaustive small-path oracle. Co-authored-by: OpenAI Codex (GPT-6) <[email protected]>
…cleavage checks - Reject linkage modifications (codes ending in '*') in RNARouteCandidateGenerator with a clear error; they previously failed on the first spectrum with "map::at". - Add routes:terminal_states (default: enzyme). Products now carry the terminal groups of the configured RNase at their parent position, as in enumeration; "all" restores the six terminal assignments. The generator takes an optional per-entry terminal-state mask, and parent matches whose termini disagree with a candidate are dropped. - Validate cleavage on the product plus the neighbouring residues the enzyme patterns need, against parents parsed once, instead of re-digesting the full parent for every candidate. - Report the spectrum, candidate and scorer message when route scoring fails in enumeration mode, for any OpenMS exception. - Add missing standard includes and a null check on the RNase cast. Tests: new generator regression for masks and linkage rejection; the two end-to-end route tests that rely on non-enzymatic termini now request routes:terminal_states all, and one also covers the enzyme default. The HAP1 benchmark profile records routes:terminal_states=all; it was not rerun. Co-Authored-By: Claude Fable 5.2 <[email protected]>
… modifications Addresses the review of 3511afc. - A cached digest (-digest) left the missed-cleavage budget at 0 for the modification-aware validation, which dropped every product spanning a cleavage site. The budget is now taken from the cached search parameters. - With routes:terminal_states=enzyme, a fixed terminal modification removed all interior products: the stored product carried the fixed group, while the enzyme mask expected an unmodified end. As in enumeration, an end now takes the RNase group and a fixed terminal modification fills only an end without one. A terminal mask replaces the generator's stored-termini check. - A resource-limit abort names the routes:max_* option to raise, and labile completion without any diagnostic:fixed_ions rule logs a warning. - New end-to-end test: an interior product with a missed cleavage, fresh and cached, and a fixed 5' phosphate. It fails without the two fixes. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ifications Keep deferred digest scaffolds outside the output molecule registry so export cannot union terminally incompatible target and decoy parents back into a validated hit. Reject matched search results as route digest inputs. Default route completion to bounded configured modifications and size the explicit failure bounds for the reviewed HAP1 run. Cover both regressions end to end, including fresh/cached target-decoy role reversal. Record the paired HyperScore baseline, assignment overlap and limitations. Co-authored-by: OpenAI Codex (GPT-6) <[email protected]>
e50af35 to
1e92a60
Compare
Written by an AI agent using GPT-6.
Add experimental spectrum-specific route generation, modification diagnostics, the optional RNA route score, and best-coherent-scaffold native scoring. Reuse the tag graph and shared ordinal statistic. Enumeration and HyperScore remain the default workflow.
Stacked on #10912 (
codex/nase-stack/06-graph-tags); supersedes the corresponding portion of #10906. Rebased onto its current head24018884c8: five route commits form a linear series ending at1e92a601d3. The rebased tree matches the previously validated combined graph/route checkpoint exactly.Route products follow the RNase's terminal gains and parent position by default. Fixed terminal groups fill only ends without an enzyme gain;
routes:terminal_states=allexplicitly searches the six physical terminal assignments. Linkage modifications are rejected up front. Modification-aware validation uses cached parent context and the recorded missed-cleavage budget, including with-digest. Modification-created cuts count against that budget, as documented.Deferred digest scaffolds are held outside the output molecule registry. Registering a validated hit therefore cannot merge incompatible target/decoy parent mappings back into it.
graph_routesaccepts unmatcheddigest_outfiles and rejects search-result files containing observation matches.routes:completionnow defaults tobounded: up to two configured variable modifications may be completed without intact graph placements or a diagnostic reporter. Explicitlabile/bounded_labilemodes remain available and warn if no labile reporter is configured. Default failure bounds are one million states, five million candidates, twenty million supports and one billion completion nodes. Exhaustion fails without exporting partial identifications and names the relevant option. These are bounds, not preallocated buffers; graph generation can be substantially slower than enumeration.The route scorer retains alternative prefixes distinguished by future-relevant used peaks, expires identities only after their last possible rung, and reconstructs full routes with backpointers. It preserves deterministic longest/heaviest ties and fails explicitly on state exhaustion.
Validation of rebased head
1e92a601d3: fresh out-of-tree Debug builds against the installed OpenMS 3.7 core with GCC 13 and Clang 18/OpenMP each pass five C++ suites (ModifiedNASequenceGenerator_test,NASEDigestion_test,RNASpectrumGraph_test,RNASensitivity_test,SpectrumAnnotator_test) and all 15 NASE TOPP/fixture checks. Tests cover the inherited #10912 query-budget, randomized domain-completion, modification-placement, graph-cache and parameter regressions alongside the route prefix/oracle, cached-cleavage, terminal, parent-mapping and completion regressions. Rebase conflicts preserve graph-option validation, prefilter verification and diagnostic filtering together. The four route review-fix commits replay without patch changes; the final tree is identical to the combined checkpoint. Whitespace checks pass. Full repository and pyOpenMS builds were not performed for this rebase. The HAP1 measurements below predate this rebase and were not rerun.A paired HAP1 check is recorded in
doc/benchmarking/nase/hap1_route_defaults_review_2026.json, using the same recording, decoy FASTA, modification panel and tolerances:Counts are target-containing spectra at 1% / 5% / 10% native q, including shared parent mappings reported separately in the JSON. The slice preserves every accepted assignment at all three cutoffs; the whole run preserves all baseline accepted calls at 1% and 5%. Both graph runs complete without route/diagnostic/limit overrides. Whole-run wall times were 15 versus 136 seconds with 16 threads on this machine. Optional route scoring on the slice gives 169 / 181 / 191, with 27 of the 109 baseline 1% assignments changed. These are yield measurements, not independent accuracy validation. No entrapment or new seed sweep was done, and the earlier nine-file/ten-seed sensitivity results were not rerun. Route scoring remains experimental; interpret historical seed spread and 5%/10% yields together.
Co-authored-by:trailers; design intent and limitations are described above. Human confirmation remains pending.