Skip to content

[FIX] OpenNuXL: score every same-formula adduct and cross-linkable nucleotide (#10746 + updated test references) - #10761

Merged
timosachsenberg merged 4 commits into
developfrom
claude/openms-pr-10746-failures-1922dv
Oct 28, 2026
Merged

timosachsenberg merged 4 commits into
developfrom
claude/openms-pr-10746-failures-1922dv

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #10739. This is #10746 by Tom Smith (TomSmithCGAT): its three commits, unchanged, plus one commit (a135b0c) that updates the TOPP_OpenNuXL_4 and TOPP_OpenNuXL_6 references. #10746 couldn't regenerate those from its 3.6.0 build, and they are its only CI failures: TOPP_OpenNuXL_4_out1/out2 and TOPP_OpenNuXL_6_out1/out2, identical on all three Linux jobs.

What #10746 changes

The full description, reasoning and measurements are in #10746.

  • Slow scoring: for (auto & l = low_it; ...) → for (auto l = low_it; ...). The reference advanced low_it, so only the first adduct of a sum formula and the first cross-linkable nucleotide were ever scored. The total-loss part is now scored once per spectrum, and nr_candidates is counted once per peptide, sum formula and spectrum, as on develop.
  • Fast scoring (rescoreFastHits_): each copy made for an ambiguous adduct gets the nucleotides of its own adduct. Each hit is rescored only with its own adduct.
  • Hit selection: NuXLAnnotatedHit::hasBetterScore breaks score ties deterministically. keepTopUniqueHits_ keeps at most one hit per peptide, peptide modification, sum formula and isotope error.
  • Localisation: findPrecursorAdduct looks up a hit's adduct with bounds checks. annotateAndLocate_ uses the hit's own adduct instead of the first adduct of the formula. This fixes the std::length_error abort that appears once second adducts are scored.
  • New test: TOPP_OpenNuXL_7 covers second-adduct and second-nucleotide hits, the candidate count and tie resolution.

Reference update (a135b0c)

Every changed hit is an exact score tie that the new tie-breaker resolves differently from std::partial_sort's unspecified order on develop:

  • TOPP_OpenNuXL_4 (fast scoring, top 2): at RT 31.812, IIGNENFVVAAR (CU-H2O1) and LVQPFGWENPR (GU-H3O4P1) tie at fast score 4.95275402 for the second slot. IIGNENFVVAAR is now kept, and rescores to 11.37 instead of 8.77.
  • TOPP_OpenNuXL_6 (precursor tolerance 1e9 ppm, top 2):
    • In 7 spectra, ranks 1 and 2 swap between UU-H2O1 and UU-H3O4P1 (or U-H2O1 and U-H1O3P1), at identical scores.

    • In 3 more spectra, a tie for rank 2 or 4 goes to the other candidate: UU-H3O4P1 instead of UU-H2O1 twice, and unmodified MATSGMMTELGK instead of its Met-oxidised form once.

    • The changed rank-1 hits have different precursor errors. That shifts the precursor-error mean and SD of the 20 best IDs, which filter_pc_mass_error uses as its cutoff, so the EDIAAIR peptide hit is now removed:

      mean ppm 5×SD EDIAAIR |ppm|−|mean| removed
      develop 34,789 786,491 784,898 no
      this PR 43,371 731,308 776,317 yes

Only the lines whose output differs between develop and this branch were replaced. All other lines, including the run date and version, are the previous reference unchanged.

Verification

Built on Linux x64 with g++ 13.3 (the CI compiler), Release, system dependencies and Arrow 26:

  • develop at the PR base (31e6d9d): all existing TOPP_OpenNuXL tests pass against the old references, so the setup reproduces them. Only the new TOPP_OpenNuXL_7_ambiguous_adducts fails.
  • This branch: all 34 TOPP_OpenNuXL tests pass, including the definitions and idparquet tests.
  • Outputs of tests 1, 2, 3 and 5 are identical between develop and this branch.
  • The test 4 tie was checked with a temporary debug print of the scores at the top-hit cutoff, which isn't committed.

Checklist

  • Make sure that you are listed in the AUTHORS file (per [FIX] OpenNuXL: score every same-formula adduct and cross-linkable nucleotide #10746)
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
    Only the 34 TOPP_OpenNuXL tests were run locally. Class tests were not built; relying on CI.
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

No need to edit the CHANGELOG file: entries are generated automatically once per week from merged changes.

How can I get additional information on failed tests during CI

Click to expand If your PR is failing you can check out

Generated by Claude Code

Summary by CodeRabbit

  • Improvements
    • OpenNuXL now handles ambiguous nucleotide adducts more consistently when scoring and reporting peptide identifications.
    • Duplicate hits are filtered more reliably, and tied scores are resolved consistently.
    • When adduct or nucleotide information cannot be resolved, the software now warns and avoids unreliable localization rather than failing unexpectedly.
  • Tests
    • Added coverage for ambiguous adduct identification and updated expected output for an existing test.

TomSmithCGAT and others added 4 commits October 27, 2026 10:46
…cleotide in slow scoring

The spectrum loops in the main scoring loop iterate over a copy of
low_it (`auto l`), so every adduct sharing a precursor sum formula and
every cross-linkable nucleotide is scored against the matching spectra.

annotateAndLocate_ localises each hit against its own precursor adduct
(NA_adduct_amb_index), as fillSpectrumID_ does, so the nucleotide
lookup finds the hit's nucleotide for second and later adducts of a
sum formula.

See #10739.
…duct

In rescoreFastHits_, the loop that copies each hit per ambiguous
precursor adduct advances NA_adduct_it with NA_adduct_amb_index, so
each copy takes its cross-linkable nucleotides from its own adduct.

The rescoring loop skips adducts other than the hit's
NA_adduct_amb_index, so partial-loss and marker-ion scores come from
the hit's adduct and total_MIC is incremented once per hit.

See #10739.
…re total loss once

- NuXLAnnotatedHit::hasBetterScore: deterministic tie-breaker on
  sequence, peptide modification, NA modification, adduct index,
  cross-linked nucleotide and isotope error
- slow scoring: nr_candidates counted once per peptide, sum formula
  and spectrum; adducts of a sum formula collected first, total-loss
  part scored once per spectrum, partial-loss part per adduct and
  nucleotide with the total-loss b/y templates
- keepTopUniqueHits_: at most one hit per peptide, peptide
  modification, sum formula and isotope error, in the inline XL trim
  and filterTopNAnnotations_
- rescoreFastHits_: direct adduct lookup, parallel rescoring loop
- NuXLModificationMassesResult::findPrecursorAdduct: bounds-checked
  lookup of a hit's sum formula and adduct, used in rescoreFastHits_,
  fillSpectrumID_ and annotateAndLocate_
- annotateAndLocate_: explicit checks for unresolvable adducts and
  nucleotides (warning, hit left unlocalised); header docs updated
- TOPP_OpenNuXL_7: RNA-UV (UCGA) search checking second adducts,
  second nucleotides, nr_candidates and tie resolution
…ic tie-breaking

NuXLAnnotatedHit::hasBetterScore now breaks score ties on sequence,
peptide_mod_index, NA_mod_index, ... instead of leaving them to
std::partial_sort's unspecified order. Every changed hit is an exact score
tie that now resolves the other way:

- OpenNuXL_4 (fast scoring, top 2): at RT 31.812 IIGNENFVVAAR (CU-H2O1) and
  LVQPFGWENPR (GU-H3O4P1) tie at fast score 4.95275402 for the second slot;
  IIGNENFVVAAR is now kept (rescored to 11.37 instead of 8.77).
- OpenNuXL_6 (precursor tolerance 1e9 ppm, top 2): rank 1/2 ties between
  UU-H2O1 and UU-H3O4P1 (and U-H2O1/U-H1O3P1, MATSGMMTELGK with/without
  Met oxidation) now go to the lower sum-formula/modification index. The
  changed rank-1 hits shift the precursor-error mean/SD of the 20 best IDs
  (mean 34789 -> 43371 ppm, 5*sd 786491 -> 731308 ppm), so the
  filter_pc_mass_error cutoff now removes the EDIAAIR peptide hit
  (|ppm| - |mean| = 776317 ppm).

Only the lines that differ between develop and this branch's output were
replaced; all other lines are unchanged. Generated on Linux x64, g++ 13.3,
Release. All 34 TOPP_OpenNuXL tests pass; on develop, the same build passes
all OpenNuXL tests except the new TOPP_OpenNuXL_7_ambiguous_adducts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0149aXmZp4ZWSMDF4PaXvwak
@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d6e850e7-89dd-41c1-850d-1113cf1321d4
Commits

Reviewing files that changed from the base of the PR and between f940a46 and a135b0c.

Files ignored due to path filters: 2
  • src/tests/topp/OpenNuXL_4_output2.tsv is excluded by !**/*.tsv
  • src/tests/topp/OpenNuXL_6_output2.tsv is excluded by !**/*.tsv
Files selected for processing: 9
  • src/tests/topp/CMakeLists.txt
  • src/tests/topp/OpenNuXL_4_output.idXML
  • src/tests/topp/OpenNuXL_6_output.idXML
  • src/tests/topp/OpenNuXL_7_ambiguous_adducts_test.cmake
  • src/topp/OpenNuXL/OpenNuXL.cpp
  • src/topp/OpenNuXL/include/NuXLAnnotateAndLocate.h
  • src/topp/OpenNuXL/include/NuXLAnnotatedHit.h
  • src/topp/OpenNuXL/include/NuXLModificationsGenerator.h
  • src/topp/OpenNuXL/source/NuXLAnnotateAndLocate.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

Walkthrough

OpenNuXL now resolves precursor adducts using both stored indices, scores slow-scoring candidates across matching spectra, and filters duplicate hits with deterministic tie-breaking. Localization handles unresolved entries with warnings. A TOPP test checks ambiguous-adduct results.

Changes: OpenNuXL scoring and reporting

Layer / File(s) Summary
Resolve precursor adducts and localization
src/topp/OpenNuXL/include/NuXLModificationsGenerator.h, src/topp/OpenNuXL/OpenNuXL.cpp, src/topp/OpenNuXL/source/NuXLAnnotateAndLocate.cpp, src/topp/OpenNuXL/include/NuXLAnnotateAndLocate.h
findPrecursorAdduct resolves the formula and adduct from both indices. Rescoring, reporting, and localization use this lookup. Missing adduct or nucleotide entries produce warnings and skip localization.
Score adducts and select unique hits
src/topp/OpenNuXL/OpenNuXL.cpp, src/topp/OpenNuXL/include/NuXLAnnotatedHit.h
Slow scoring counts candidates once per spectrum and sum formula, shares total-loss scoring, and scores partial losses per adduct and nucleotide. Hit selection removes duplicates and breaks score ties deterministically.
Validate ambiguous-adduct results
src/tests/topp/CMakeLists.txt, src/tests/topp/OpenNuXL_7_ambiguous_adducts_test.cmake, src/tests/topp/OpenNuXL_4_output.idXML
A new TOPP test checks adduct and nucleotide assignments, candidate count, and duplicate hits. The test setup and stored idXML output are updated.

Sequence Diagram(s)

sequenceDiagram
  participant OpenNuXL as OpenNuXL slow scoring
  participant Spectra as matching spectra
  participant Adducts as XLAdduct entries
  participant Hits as per-spectrum hit buffer
  OpenNuXL->>Adducts: collect feasible adducts and marker-ion spectra
  OpenNuXL->>Spectra: calculate shared total-loss scores
  loop Each adduct and cross-linkable nucleotide
    OpenNuXL->>Spectra: score partial-loss ions
    OpenNuXL->>Hits: retain unique hit
  end
Loading

Possibly related issues

  • OpenMS/OpenMS issue 10739, “OpenNuXL: slow scoring only scores the first adduct and first cross-linkable nucleotide for each precursor sum formula”: the PR updates slow scoring to process adducts and cross-linkable nucleotides and adds a regression test for ambiguous adducts.

Possibly related PRs

  • OpenMS/OpenMS#10746: It updates the same OpenNuXL scoring, precursor-adduct lookup, hit filtering, and localization behavior.

Suggested reviewers: jpfeuffer

Priority: Normal

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to a135b

This change makes OpenNuXL score every same-formula adduct and cross-linkable nucleotide, and makes the choice among tied hits deterministic. It adds a test for the ambiguous-adduct case. No concrete merge-blocking risk was found; the updated test references rely on CI to confirm them.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main fix: scoring every same-formula adduct and cross-linkable nucleotide in OpenNuXL. It is specific and related to the changeset.
Linked Issues check Passed The PR addresses the coding requirements in #10739. Slow scoring now copies the spectrum iterator, so each matching spectrum can be scored for every same-formula adduct and cross-linkable nucleotide. …
Out of Scope Changes check Passed The changes stay within the OpenNuXL defect scope from #10739. Deterministic tie ordering, unique-hit filtering, adduct-index validation, localisation safeguards, test wiring, and reference updates su…
Full details: Linked Issues check

Explanation

The PR addresses the coding requirements in #10739. Slow scoring now copies the spectrum iterator, so each matching spectrum can be scored for every same-formula adduct and cross-linkable nucleotide. Candidate counting and total-loss scoring use the shared spectrum/formula scope. Fast scoring copies retain their own adduct and rescoring uses that adduct. Hit-specific, bounds-checked adduct lookup is used during reporting and localisation. The new TOPP_OpenNuXL_7 test checks second-adduct, second-nucleotide, candidate-count, and tie behavior. The reported 34 OpenNuXL tests pass on this branch.

Full details: Out of Scope Changes check

Explanation

The changes stay within the OpenNuXL defect scope from #10739. Deterministic tie ordering, unique-hit filtering, adduct-index validation, localisation safeguards, test wiring, and reference updates support correct handling of the newly scored hits and their reproducible outputs. No unrelated product area or unrelated feature is identified in the reviewed change summary.

Full details: Docstring Coverage

Explanation

Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 11 functions across 5 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the adduct list,
Each formula gets its indexed fit.
Shared spectra score, then branches run,
Unique hits line up when scoring’s done.
The test finds copies that should not persist,
And hops away with the results in its fist.

Comment @coderabbitai help to get the list of available commands.

Comment thread src/tests/topp/OpenNuXL_4_output2.tsv Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenNuXL: slow scoring only scores the first adduct and first cross-linkable nucleotide for each precursor sum formula

3 participants