Skip to content

fix(ProSE): honor ions:add_* parameters in scoring path - #9167

Merged
timosachsenberg merged 2 commits into
developfrom
fix/prose-ion-series-params
Apr 17, 2026
Merged

timosachsenberg merged 2 commits into
developfrom
fix/prose-ion-series-params

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix a silent bug where ProSE's ions:add_a/b/c/x/y/z_ions parameters were declared but never read — making the index and scoring paths inconsistent for non-default ion types (ETD, EThcD).

Closes item 12 in #9108.

The bug

ProSEAlgorithm constructor (line 185-196) declares 6 ion-series toggle parameters with defaults (b/y on, a/c/x/z off). However:

  • updateMembers_() never reads them — no param_.getValue("ions:add_*") calls
  • FragmentIndex receives the params via setParameters() and correctly builds the index with the user's ion selection ✅
  • TheoreticalSpectrumGenerator in the scoring loop (line 828-832) only sets add_first_prefix_ion and add_metainfo — always generates b/y regardless of user config ❌

Result: User sets -Search:ions:add_c_ions true for ETD data → index contains c-ion fragments → scorer generates b/y theoretical peaks → c-ions in the index never match → worse scores than expected. Silent data-quality issue.

The fix

  • Add 6 bool members to ProSEAlgorithm (header)
  • Read them in updateMembers_() (6 lines)
  • Forward to TheoreticalSpectrumGenerator in search() (6 lines)

Total: +23 lines, 2 files.

Usage after fix

# ETD search (c/z ions)
ProSE -in etd_data.mzML -database db.fasta -out_idxml etd.idXML \
  -Search:ions:add_c_ions true -Search:ions:add_z_ions true \
  -Search:ions:add_b_ions false -Search:ions:add_y_ions false

# EThcD search (all ion types)
ProSE -in ethcd_data.mzML -database db.fasta -out_idxml ethcd.idXML \
  -Search:ions:add_c_ions true -Search:ions:add_z_ions true

# Default (HCD/CID, unchanged behavior)
ProSE -in hcd_data.mzML -database db.fasta -out_idxml hcd.idXML

Test plan

  • Build clean on Linux
  • ProSE --helphelp shows all 6 ions:add_* params under -Search:ions: subsection
  • Default behavior unchanged (b/y on, a/c/x/z off — same as before the fix)
  • Regression: run ProSE with default params on existing test fixture, verify idXML output is identical to pre-fix (manual; no ion-series-specific test fixture in CI)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added configurable ion series selection in the ProSE algorithm, allowing users to control which ion types (a, b, c, x, y, z ions) are used during spectral analysis.

ProSE declared ions:add_a/b/c/x/y/z_ions parameters in its constructor
but updateMembers_() never read them. FragmentIndex received and used
them correctly (via setParameters in prepareContext), but
TheoreticalSpectrumGenerator in the scoring loop always used its
defaults (b/y only) — making the index and scorer inconsistent.

Fix: read the 6 ion toggles in updateMembers_() and forward them to
TheoreticalSpectrumGenerator alongside the existing add_first_prefix_ion
and add_metainfo settings. Users can now configure ETD-style searches
with -Search:ions:add_c_ions true -Search:ions:add_z_ions true
-Search:ions:add_b_ions false -Search:ions:add_y_ions false and have
both the index and scoring honor the setting.

Closes item 12 in #9108.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Added six configurable boolean member variables to ProSEAlgorithm for controlling ion series inclusion (a, b, c, x, y, z ions) in spectrum generation. These toggles are initialized from parameters and forwarded to TheoreticalSpectrumGenerator to ensure consistent ion type filtering between fragment indexing and scoring.

Changes

Cohort / File(s) Summary
Ion Series Member Variables
src/openms/include/OpenMS/ANALYSIS/ID/ProSEAlgorithm.h
Added six boolean member variables with default values to control which ion series are included during theoretical spectrum generation.
Ion Series Parameter Integration
src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp
Implemented parameter loading in updateMembers_() and updated search() to pass ion series toggles to TheoreticalSpectrumGenerator for consistent spectrum generation.

Suggested reviewers

  • jcharkow
  • jpfeuffer

Poem

🐰 Six ions dance in binary delight,
A, B, C, X, Y, Z—configured just right!
From params they spring, to spectrum they flow,
ProSE's precision continues to grow! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: ensuring that ion-series toggle parameters are honored in the scoring path of the ProSE algorithm.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/prose-ion-series-params

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp (2)

1552-1556: ⚠️ Potential issue | 🟡 Minor

Calibration-pass TSG also hardcoded to b/y defaults.

Same downstream concern as postProcessHits_: when non-default ion series are enabled, calibration scoring here will use only b/y theoretical ions, which for ETD/EThcD spectra yields fewer matches and noisier shift/spread estimates than the main scoring pass (which now correctly honors the toggles). Forwarding the six add_*_ions_ members here would keep the calibration pass consistent with the main search.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp` around lines 1552 - 1556,
The calibration-pass TSG is hardcoded to b/y defaults; update the setup for
TheoreticalSpectrumGenerator (tsg) in ProSEAlgorithm::... so it forwards the
algorithm's six add_*_ions_ toggles instead of fixed defaults: read the class
members (e.g. add_b_ions_, add_y_ions_, add_a_ions_, add_c_ions_, add_x_ions_,
add_z_ions_ — or the actual six add_*_ions_ member names present) and set the
corresponding Param keys on tsg_param (e.g. "add_b_ions", "add_y_ions",
"add_a_ions", "add_c_ions", "add_x_ions", "add_z_ions") before calling
tsg.setParameters(tsg_param) so the calibration scoring honors the same
ion-series configuration as the main search.

430-434: ⚠️ Potential issue | 🟡 Minor

Annotation-path TSG still hardcoded to defaults (b/y only) — same-class-of-bug as the scoring-path fix.

The scoring TSG now honors ions:add_*, but the TSG used here for alignment-based annotations (fragment_error_median_ppm, fragment_annotations, longest_peptide_ion_sequence, and the b/y ordinal extraction at lines 511-521) is still constructed with library defaults — i.e. b/y only. For ETD/EThcD runs with add_c_ions/add_z_ions=true, c/z peaks won't participate in alignment, so the annotations will under-report matches and fragment-error medians will be biased toward the subset of ions that happen to overlap b/y masses.

Consider forwarding the same six toggles here (and, if desired, re-scoping the b/y ordinal extraction at lines 511-524 to also collect c/z ordinals for the longest-run computation when those series are enabled). If intentionally out of scope for this PR, a TODO would help.

Suggested minimal forward of the toggles
             TheoreticalSpectrumGenerator tsg;
             Param tsg_param(tsg.getParameters());
             tsg_param.setValue("add_metainfo", "true");
             tsg_param.setValue("add_first_prefix_ion", "true");
+            tsg_param.setValue("add_a_ions", add_a_ions_ ? "true" : "false");
+            tsg_param.setValue("add_b_ions", add_b_ions_ ? "true" : "false");
+            tsg_param.setValue("add_c_ions", add_c_ions_ ? "true" : "false");
+            tsg_param.setValue("add_x_ions", add_x_ions_ ? "true" : "false");
+            tsg_param.setValue("add_y_ions", add_y_ions_ ? "true" : "false");
+            tsg_param.setValue("add_z_ions", add_z_ions_ ? "true" : "false");
             tsg.setParameters(tsg_param);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp` around lines 430 - 434, The
TheoreticalSpectrumGenerator used for annotation (TheoreticalSpectrumGenerator
instance "tsg" and its Param "tsg_param") is still using library defaults (b/y
only); forward the same six ions toggles from the scoring path by
reading/setting the "ions:add_*" parameters (e.g. "ions:add_b_ions",
"ions:add_y_ions", "ions:add_c_ions", "ions:add_z_ions", "ions:add_a_ions",
"ions:add_x_ions") into tsg_param before calling tsg.setParameters so
fragment-based features (fragment_error_median_ppm, fragment_annotations,
longest_peptide_ion_sequence) include the same ion series as scoring;
additionally, when c/z series are enabled, extend the b/y ordinal-collection
logic (the b/y ordinal extraction block used to compute longest-run) to also
collect c/z ordinals, or add a TODO comment if you prefer to defer that change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp`:
- Around line 1552-1556: The calibration-pass TSG is hardcoded to b/y defaults;
update the setup for TheoreticalSpectrumGenerator (tsg) in ProSEAlgorithm::...
so it forwards the algorithm's six add_*_ions_ toggles instead of fixed
defaults: read the class members (e.g. add_b_ions_, add_y_ions_, add_a_ions_,
add_c_ions_, add_x_ions_, add_z_ions_ — or the actual six add_*_ions_ member
names present) and set the corresponding Param keys on tsg_param (e.g.
"add_b_ions", "add_y_ions", "add_a_ions", "add_c_ions", "add_x_ions",
"add_z_ions") before calling tsg.setParameters(tsg_param) so the calibration
scoring honors the same ion-series configuration as the main search.
- Around line 430-434: The TheoreticalSpectrumGenerator used for annotation
(TheoreticalSpectrumGenerator instance "tsg" and its Param "tsg_param") is still
using library defaults (b/y only); forward the same six ions toggles from the
scoring path by reading/setting the "ions:add_*" parameters (e.g.
"ions:add_b_ions", "ions:add_y_ions", "ions:add_c_ions", "ions:add_z_ions",
"ions:add_a_ions", "ions:add_x_ions") into tsg_param before calling
tsg.setParameters so fragment-based features (fragment_error_median_ppm,
fragment_annotations, longest_peptide_ion_sequence) include the same ion series
as scoring; additionally, when c/z series are enabled, extend the b/y
ordinal-collection logic (the b/y ordinal extraction block used to compute
longest-run) to also collect c/z ordinals, or add a TODO comment if you prefer
to defer that change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fdf2a731-1046-4896-8a7d-d7f9bb167424

📥 Commits

Reviewing files that changed from the base of the PR and between 016d3e0 and 5874543.

📒 Files selected for processing (2)
  • src/openms/include/OpenMS/ANALYSIS/ID/ProSEAlgorithm.h
  • src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp

@timosachsenberg
timosachsenberg merged commit daded9d into develop Apr 17, 2026
15 checks passed
@timosachsenberg
timosachsenberg deleted the fix/prose-ion-series-params branch April 17, 2026 08:51
timosachsenberg added a commit that referenced this pull request Apr 17, 2026
…tures

Three changes bundled because they touch the same code paths:

1. Rename matched_b_ions / matched_y_ions → matched_prefix_ions /
   matched_suffix_ions across HyperScore, ProSE, SSE, and Constants.h.
   With PR #9167 enabling c/z/a/x ions, the old names were misleading —
   these counters track ALL prefix (a/b/c) and suffix (x/y/z) ions, not
   just b/y. MetaValue strings also renamed (no backward compat needed —
   ProSE is unreleased).

2. Fix HyperScore::computeWithDetail to count all prefix/suffix ion
   types in the factorial terms, not just b/y. Previously c/z ions
   contributed to the dot_product (intensity matching) but NOT to the
   ion-count factorial boost — penalizing ETD/EThcD searches. The fast
   path (first-char check, O(1) per ion) handles a/b/c/x/y/z; the
   XL-MS $-prefix fallback (single find('$'), O(N) on name length) is
   preserved for NuXL compatibility.

3. Add delta_score: score difference between best and second-best PSM
   per spectrum. Computed in a single O(N) pass over candidates BEFORE
   partial_sort — zero change to the existing sort (still k=top_hits).
   When only one candidate exists, delta = full score (same convention
   as Sage/MSFragger: no competition = maximum delta). Wired into
   extra_features for Percolator. Also wires longest_peptide_ion_sequence
   and matched_prefix/suffix_ions into extra_features (already computed
   but previously not passed to Percolator).

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
timosachsenberg added a commit that referenced this pull request Apr 17, 2026
…tures

Three changes bundled because they touch the same code paths:

1. Rename matched_b_ions / matched_y_ions → matched_prefix_ions /
   matched_suffix_ions across HyperScore, ProSE, SSE, and Constants.h.
   With PR #9167 enabling c/z/a/x ions, the old names were misleading —
   these counters track ALL prefix (a/b/c) and suffix (x/y/z) ions, not
   just b/y. MetaValue strings also renamed (no backward compat needed —
   ProSE is unreleased).

2. Fix HyperScore::computeWithDetail to count all prefix/suffix ion
   types in the factorial terms, not just b/y. Previously c/z ions
   contributed to the dot_product (intensity matching) but NOT to the
   ion-count factorial boost — penalizing ETD/EThcD searches. The fast
   path (first-char check, O(1) per ion) handles a/b/c/x/y/z; the
   XL-MS $-prefix fallback (single find('$'), O(N) on name length) is
   preserved for NuXL compatibility.

3. Add delta_score: score difference between best and second-best PSM
   per spectrum. Computed in a single O(N) pass over candidates BEFORE
   partial_sort — zero change to the existing sort (still k=top_hits).
   When only one candidate exists, delta = full score (same convention
   as Sage/MSFragger: no competition = maximum delta). Wired into
   extra_features for Percolator. Also wires longest_peptide_ion_sequence
   and matched_prefix/suffix_ions into extra_features (already computed
   but previously not passed to Percolator).

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
timosachsenberg added a commit that referenced this pull request Apr 17, 2026
…tures

Three changes bundled because they touch the same code paths:

1. Rename matched_b_ions / matched_y_ions → matched_prefix_ions /
   matched_suffix_ions across HyperScore, ProSE, SSE, and Constants.h.
   With PR #9167 enabling c/z/a/x ions, the old names were misleading —
   these counters track ALL prefix (a/b/c) and suffix (x/y/z) ions, not
   just b/y. MetaValue strings also renamed (no backward compat needed —
   ProSE is unreleased).

2. Fix HyperScore::computeWithDetail to count all prefix/suffix ion
   types in the factorial terms, not just b/y. Previously c/z ions
   contributed to the dot_product (intensity matching) but NOT to the
   ion-count factorial boost — penalizing ETD/EThcD searches. The fast
   path (first-char check, O(1) per ion) handles a/b/c/x/y/z; the
   XL-MS $-prefix fallback (single find('$'), O(N) on name length) is
   preserved for NuXL compatibility.

3. Add delta_score: score difference between best and second-best PSM
   per spectrum. Computed in a single O(N) pass over candidates BEFORE
   partial_sort — zero change to the existing sort (still k=top_hits).
   When only one candidate exists, delta = full score (same convention
   as Sage/MSFragger: no competition = maximum delta). Wired into
   extra_features for Percolator. Also wires longest_peptide_ion_sequence
   and matched_prefix/suffix_ions into extra_features (already computed
   but previously not passed to Percolator).

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
timosachsenberg added a commit that referenced this pull request Apr 17, 2026
…atures (#9175)

* feat(ProSE): delta score, renamed ion counts, expanded Percolator features

Three changes bundled because they touch the same code paths:

1. Rename matched_b_ions / matched_y_ions → matched_prefix_ions /
   matched_suffix_ions across HyperScore, ProSE, SSE, and Constants.h.
   With PR #9167 enabling c/z/a/x ions, the old names were misleading —
   these counters track ALL prefix (a/b/c) and suffix (x/y/z) ions, not
   just b/y. MetaValue strings also renamed (no backward compat needed —
   ProSE is unreleased).

2. Fix HyperScore::computeWithDetail to count all prefix/suffix ion
   types in the factorial terms, not just b/y. Previously c/z ions
   contributed to the dot_product (intensity matching) but NOT to the
   ion-count factorial boost — penalizing ETD/EThcD searches. The fast
   path (first-char check, O(1) per ion) handles a/b/c/x/y/z; the
   XL-MS $-prefix fallback (single find('$'), O(N) on name length) is
   preserved for NuXL compatibility.

3. Add delta_score: score difference between best and second-best PSM
   per spectrum. Computed in a single O(N) pass over candidates BEFORE
   partial_sort — zero change to the existing sort (still k=top_hits).
   When only one candidate exists, delta = full score (same convention
   as Sage/MSFragger: no competition = maximum delta). Wired into
   extra_features for Percolator. Also wires longest_peptide_ion_sequence
   and matched_prefix/suffix_ions into extra_features (already computed
   but previously not passed to Percolator).

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* fix(ProSE): address CR feedback + add matched_ion_current

CodeRabbit feedback on fdafb4a:
- #4: LONGEST_PEPTIDE_ION_SEQUENCE only counted b/y ordinals but was
  newly exported to Percolator, systematically biasing ETD/EThcD.
  Generalized the classifier to a/b/c (prefix) / x/y/z (suffix) in
  both ProSEAlgorithm and SSE. Ordinals merged via existing
  std::unique, so a3 and b3 collapse to one backbone position.
- #5: test coverage. Added DELTA_SCORE and MATCHED_ION_CURRENT
  assertions in the existing PSM-annotations section.
- #3 (init-with-0.0 vs negative scores): pushback. HyperScore output
  is log1p + non-negative factorial terms, and score == 0 is already
  filtered at the scoring site, so 0.0 init is safe.

New feature — matched_ion_current (MIC):
Sum of experimental intensities over matched peaks. Computed in the
existing postProcessHits_ alignment loop (no HyperScore changes),
emitted as UserParam, and added to Percolator extra_features (ProSE
only, matching how longest_peptide_ion_sequence is handled). SSE
annotates but does not export. Safe today because SpectrumAlignment's
default Da path produces 1-to-1 matches; documented inline.

Reference idXML files regenerated — they were already stale before
this branch due to float-precision drift from #9117 (matched_*_ions
stored as float since 2026-04-09). The regeneration also absorbs the
new delta_score and matched_ion_current UserParams.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs: update ion-series doc comments to prefix/suffix terminology

Stale ///< doc comments on `prefix_fraction`/`suffix_fraction` and
`matched_prefix_ions`/`matched_suffix_ions` (in ProSEAlgorithm.h and
SimpleSearchEngineAlgorithm.h) and on `LONGEST_PEPTIDE_ION_SEQUENCE`
(Constants.h) still referred to "b-ions"/"y-ions" after the rename.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
github-actions Bot pushed a commit that referenced this pull request Apr 18, 2026
Add missing entries for commits since the 2026-04-17 sync:
- CometAdapter #9168: Bruker native-ID rewrite covers mzML inputs too
- ProSE #9166: new -out_pin parameter for Percolator input file output
- ProSE #9167: fix ions:add_* parameters honored in scoring path
- ProSE #9175: BREAKING rename matched_b/y_ions → matched_prefix/suffix_ions; delta_score and matched_ion_current added; HyperScore ETD/EThcD fix
- ProSE #9177: database chunking (-Search:database:chunk_size); Percolator feature and calibration fixes

Co-authored-by: Copilot <[email protected]>
timosachsenberg pushed a commit that referenced this pull request Apr 18, 2026
Add missing entries for commits since the 2026-04-17 sync:
- CometAdapter #9168: Bruker native-ID rewrite covers mzML inputs too
- ProSE #9166: new -out_pin parameter for Percolator input file output
- ProSE #9167: fix ions:add_* parameters honored in scoring path
- ProSE #9175: BREAKING rename matched_b/y_ions → matched_prefix/suffix_ions; delta_score and matched_ion_current added; HyperScore ETD/EThcD fix
- ProSE #9177: database chunking (-Search:database:chunk_size); Percolator feature and calibration fixes

Co-authored-by: GitHub Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
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.

1 participant