Repository navigation
feat(ProSE): delta score + rename ion counts + expanded Percolator features - #9175
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughReplaced b/y-ion counters with terminus-based Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp (1)
525-540:⚠️ Potential issue | 🟡 Minor
longest_peptide_ion_sequencestill only considers b/y — undermines the new ETD-focused Percolator feature.This PR wires
LONGEST_PEPTIDE_ION_SEQUENCEintoextra_features(line 652) as part of the broader prefix/suffix/ETD story, and ProSE exposes a/c/x/z toggles (ions:add_a/c/x/z_ions). But the ordinal collector here still filters onname[0] == 'b' || name[0] == 'y', so c/z runs (the primary ETD/EThcD series) never contribute. For ETD runs the feature will systematically under-report, partially defeating the HyperScore fix made in the same PR.♻️ Suggested extension
- if (name.size() >= 2 && (name[0] == 'b' || name[0] == 'y')) + const char t = name[0]; + const bool is_prefix = (t == 'a' || t == 'b' || t == 'c'); + const bool is_suffix = (t == 'x' || t == 'y' || t == 'z'); + if (name.size() >= 2 && (is_prefix || is_suffix)) { // Extract ordinal: "b5", "y3-H2O1+", "b12++" -> 5, 3, 12 Size pos = 1; while (pos < name.size() && name[pos] >= '0' && name[pos] <= '9') ++pos; if (pos > 1) { int ordinal = String(name.substr(1, pos - 1)).toInt(); - if (name[0] == 'b') b_ordinals.push_back(ordinal); - else y_ordinals.push_back(ordinal); + if (is_prefix) b_ordinals.push_back(ordinal); + else y_ordinals.push_back(ordinal); } }(Note: the variable names
b_ordinals/y_ordinalswould be worth renaming toprefix_ordinals/suffix_ordinalsfor consistency.)🤖 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 525 - 540, The ordinal extractor inside the annotation_longest_ion_run block currently only handles b/y ions; update the check on ion_names[theo_idx] to also accept ETD ion types (a, c, x, z) and route them to the correct ordinal vectors (treat prefix ions a/b/c like b_ordinals and suffix ions x/y/z like y_ordinals); ensure the same numeric-parsing logic (pos loop and toInt) is reused and keep ion_names, annotation_longest_ion_run, b_ordinals and y_ordinals as the referenced symbols to locate and modify the code.
🧹 Nitpick comments (3)
src/openms/include/OpenMS/ANALYSIS/ID/SimpleSearchEngineAlgorithm.h (1)
59-60: Comments still reference b-/y-ions after rename.The member names were generalized to prefix/suffix but the inline comments still say “number of matched b-ions” / “number of matched y-ions”, which re-introduces the same mismatch this PR is trying to eliminate. Consider aligning comments with the field semantics.
💡 Proposed doc refresh
- uint16_t matched_prefix_ions = 0; ///< number of matched b-ions - uint16_t matched_suffix_ions = 0; ///< number of matched y-ions + uint16_t matched_prefix_ions = 0; ///< number of matched prefix ions (a/b/c) + uint16_t matched_suffix_ions = 0; ///< number of matched suffix ions (x/y/z)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/include/OpenMS/ANALYSIS/ID/SimpleSearchEngineAlgorithm.h` around lines 59 - 60, Update the inline comments for the two members matched_prefix_ions and matched_suffix_ions in SimpleSearchEngineAlgorithm (currently referencing “b-ions” and “y-ions”) to match the generalized naming; replace the specific “number of matched b-ions” / “number of matched y-ions” text with a generic description such as “number of matched prefix fragment ions” and “number of matched suffix fragment ions” (or similar wording consistent with the new prefix/suffix terminology).src/openms/source/ANALYSIS/ID/HyperScore.cpp (2)
146-151: Local variabledshadows thePSMDetail& dout-parameter.Inside both branches (ppm / Da) the nested scope declares
const char d = name[p + 1];, which shadows the function'sPSMDetail& dparameter. It compiles because the innerdisn't used for the assignment back to the out-parameter, but it's confusing to read and will trigger-Wshadow. Renaming the local char avoids the clash.♻️ Proposed rename
else if (auto p = name.find('$'); p != String::npos && p + 1 < name.size()) { - const char d = name[p + 1]; - if (d == 'a' || d == 'b' || d == 'c') ++prefix_ion_count; - else if (d == 'x' || d == 'y' || d == 'z') ++suffix_ion_count; + const char ct = name[p + 1]; + if (ct == 'a' || ct == 'b' || ct == 'c') ++prefix_ion_count; + else if (ct == 'x' || ct == 'y' || ct == 'z') ++suffix_ion_count; }Also applies to: 165-170
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/ID/HyperScore.cpp` around lines 146 - 151, The local char named "d" inside the name.find() branches shadows the function parameter PSMDetail& d; rename that local variable (e.g., to ion_char or ch) in both occurrences (the block around the prefix/suffix ion counting and the similar block at the later location) so it no longer conflicts with the out-parameter; update only the local variable name where it's declared and used in the condition checks (d == 'a'/'b'/'c' and d == 'x'/'y'/'z') to the new name.
130-181: Document the intentional behavioral divergence betweencompute()andcomputeWithDetail()overloads.
computeWithDetail()now counts a/b/c + x/y/z ions, while all threecompute()overloads still only count b/y ions. For identical spectra with a/c/x/z peaks, the two methods return different scores. This divergence is intentional per the PR scope and is safe since distinct call sites use distinct methods (OpenNuXL usescompute(); search algorithms usecomputeWithDetail()). Consider adding a brief note to the class doxygen or tocompute()(which currently advertises "b- and y-ions") to clarify this intentional difference for future maintainers.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/ID/HyperScore.cpp` around lines 130 - 181, The compute() overloads count only b/y ions while computeWithDetail() counts a/b/c and x/y/z (intentional), so add a short clarifying note to the HyperScore class documentation or the compute() method comment indicating this deliberate behavioral divergence: mention that compute() (advertised as "b- and y-ions") only considers b/y ions whereas computeWithDetail() includes a/c/x/z as well, and that callers differ (e.g. OpenNuXL vs search algorithms); update the doxygen block for the HyperScore class or immediately above the compute() function to make this explicit for future maintainers.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp`:
- Around line 345-375: The code only sets hits[0].delta_score (spectrum-level
best-minus-second) so all other retained PSMs report delta=0; update the loop
that processes annotated_hits so delta_score is computed per retained rank:
after partial_sort/topn selection (using annotated_hits, hits, top_hits,
AnnotatedHit_::hasBetterScore), iterate the kept hits and set
hits[i].delta_score = hits[i].score - hits[i+1].score for i < topn-1 and for the
last kept hit set delta = hits[i].score (fallback to full score); ensure this
replaces the single hits[0] assignment and keeps behavior when only one
candidate, and be mindful that extra_features/report_top_hits_ will then carry
these per-PSM values.
---
Outside diff comments:
In `@src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp`:
- Around line 525-540: The ordinal extractor inside the
annotation_longest_ion_run block currently only handles b/y ions; update the
check on ion_names[theo_idx] to also accept ETD ion types (a, c, x, z) and route
them to the correct ordinal vectors (treat prefix ions a/b/c like b_ordinals and
suffix ions x/y/z like y_ordinals); ensure the same numeric-parsing logic (pos
loop and toInt) is reused and keep ion_names, annotation_longest_ion_run,
b_ordinals and y_ordinals as the referenced symbols to locate and modify the
code.
---
Nitpick comments:
In `@src/openms/include/OpenMS/ANALYSIS/ID/SimpleSearchEngineAlgorithm.h`:
- Around line 59-60: Update the inline comments for the two members
matched_prefix_ions and matched_suffix_ions in SimpleSearchEngineAlgorithm
(currently referencing “b-ions” and “y-ions”) to match the generalized naming;
replace the specific “number of matched b-ions” / “number of matched y-ions”
text with a generic description such as “number of matched prefix fragment ions”
and “number of matched suffix fragment ions” (or similar wording consistent with
the new prefix/suffix terminology).
In `@src/openms/source/ANALYSIS/ID/HyperScore.cpp`:
- Around line 146-151: The local char named "d" inside the name.find() branches
shadows the function parameter PSMDetail& d; rename that local variable (e.g.,
to ion_char or ch) in both occurrences (the block around the prefix/suffix ion
counting and the similar block at the later location) so it no longer conflicts
with the out-parameter; update only the local variable name where it's declared
and used in the condition checks (d == 'a'/'b'/'c' and d == 'x'/'y'/'z') to the
new name.
- Around line 130-181: The compute() overloads count only b/y ions while
computeWithDetail() counts a/b/c and x/y/z (intentional), so add a short
clarifying note to the HyperScore class documentation or the compute() method
comment indicating this deliberate behavioral divergence: mention that compute()
(advertised as "b- and y-ions") only considers b/y ions whereas
computeWithDetail() includes a/c/x/z as well, and that callers differ (e.g.
OpenNuXL vs search algorithms); update the doxygen block for the HyperScore
class or immediately above the compute() function to make this explicit for
future maintainers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2a75ac6c-f24f-4ce8-aa87-687cc5fe96b5
📒 Files selected for processing (7)
src/openms/include/OpenMS/ANALYSIS/ID/HyperScore.hsrc/openms/include/OpenMS/ANALYSIS/ID/ProSEAlgorithm.hsrc/openms/include/OpenMS/ANALYSIS/ID/SimpleSearchEngineAlgorithm.hsrc/openms/include/OpenMS/CONCEPT/Constants.hsrc/openms/source/ANALYSIS/ID/HyperScore.cppsrc/openms/source/ANALYSIS/ID/ProSEAlgorithm.cppsrc/openms/source/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cpp
66c398a to
4b7cafe
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/openms/include/OpenMS/ANALYSIS/ID/ProSEAlgorithm.h (1)
339-340:⚠️ Potential issue | 🟡 MinorStale Doxygen:
prefix_fraction/suffix_fractionare no longer b-/y-only.These comments still read "fraction of annotated b-ions" / "fraction of annotated y-ions", but — consistent with the rest of this PR — they now cover a/b/c (prefix) and x/y/z (suffix) ion types.
✏️ Suggested wording
- float prefix_fraction = 0; ///< fraction of annotated b-ions - float suffix_fraction = 0; ///< fraction of annotated y-ions + float prefix_fraction = 0; ///< fraction of annotated prefix ions (a/b/c) + float suffix_fraction = 0; ///< fraction of annotated suffix ions (x/y/z)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/include/OpenMS/ANALYSIS/ID/ProSEAlgorithm.h` around lines 339 - 340, The Doxygen comments for the members prefix_fraction and suffix_fraction in ProSEAlgorithm are stale (they say "fraction of annotated b-ions" / "fraction of annotated y-ions"); update those comments to reflect that these fields now represent the fraction of annotated prefix ions (a/b/c) and suffix ions (x/y/z) respectively—e.g., change to "fraction of annotated prefix ions (a/b/c)" for prefix_fraction and "fraction of annotated suffix ions (x/y/z)" for suffix_fraction so the docs match current behavior.src/openms/include/OpenMS/CONCEPT/Constants.h (1)
375-378:⚠️ Potential issue | 🟡 MinorUpdate the
DELTA_SCOREdocstring or introduce a distinct constant to clarify semantics.The constant's existing documentation describes "a score ratio between a rank x hit and the rank x+1 hit" — per-rank ratio semantics that OPXLHelper and XFDR both implement and expect. However, ProSEAlgorithm.cpp (lines 356–362) computes
best_score - second_best_score(a spectrum-level difference) and broadcasts this single value to all retained ranks from that spectrum. These are incompatible interpretations of the same constant. Either:
- Update the docstring to clarify that ProSE uses spectrum-level difference semantics, or
- Create a separate constant (e.g.,
PROSE_DELTA_SCORE) for ProSE's distinct metric.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/include/OpenMS/CONCEPT/Constants.h` around lines 375 - 378, The DELTA_SCORE constant's docstring is ambiguous because OPXLHelper and XFDR expect a per-rank ratio while ProSEAlgorithm computes a spectrum-level difference; update the code to resolve this by either clarifying the docstring of DELTA_SCORE to state it may be used as a per-spectrum difference in ProSE or introduce a new distinct constant (e.g., PROSE_DELTA_SCORE) and update ProSEAlgorithm to use that new constant; ensure references to DELTA_SCORE remain for OPXLHelper and XFDR and that ProSEAlgorithm (the code computing best_score - second_best_score) is changed to set or log PROSE_DELTA_SCORE instead.src/openms/source/ANALYSIS/ID/HyperScore.cpp (1)
56-104:⚠️ Potential issue | 🔴 CriticalUpdate the
compute()overloads to classify ions consistently withcomputeWithDetail().The three
compute()overloads (lines 36–104, 183–277, 279–413) only count b/y ions for factorial weighting, butcomputeWithDetail()correctly counts all prefix (a/b/c) and suffix (x/y/z) ions. This inconsistency is not hypothetical: OpenNuXL.cpp explicitly enables a-ions in the partial loss spectrum generator (line 3274) and then callscompute()with that spectrum (line 6569), causing a-ions to be included in the dot product but excluded from the factorial term—a silent correctness issue identical to the ETD/EThcD undercounting this PR aimed to fix.Align all
compute()overloads to use the same prefix/suffix classification logic ascomputeWithDetail(), or document why these overloads are intentionally restricted to b/y-only spectra.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/ID/HyperScore.cpp` around lines 56 - 104, The compute() overloads (function compute in HyperScore.cpp) currently only increment y_ion_count and b_ion_count while computeWithDetail() classifies all prefix (a/b/c) and suffix (x/y/z) ions; update the ion classification in each compute() overload (the loops using MatchedIterator and variables y_ion_count, b_ion_count, i = it.refIdx(), and ion_names) to mirror computeWithDetail()’s logic (i.e., detect prefixes a/b/c as "prefix" and x/y/z as "suffix", including handling XL-MS annotations that include '$' like hasSubstring("$y")/$b/$a/$x/$z) so the factorial weighting counts the same set of ions as computeWithDetail(); ensure both PpmTrait and DaTrait branches are changed consistently.
🧹 Nitpick comments (2)
src/openms/source/ANALYSIS/ID/HyperScore.cpp (1)
142-170: Localdshadows the function'sPSMDetail& dparameter.
computeWithDetailtakesPSMDetail& d(line 110). Inside both branches the innerconst char d = name[p + 1];(lines 148, 167) shadows it. No current bug — the assignments tod.matched_prefix_ionsetc. happen outside the loop — but it's a latent trap for future edits. Rename the char to e.g.nc/ch.♻️ Suggested rename
- else if (auto p = name.find('$'); p != String::npos && p + 1 < name.size()) - { - const char d = name[p + 1]; - if (d == 'a' || d == 'b' || d == 'c') ++prefix_ion_count; - else if (d == 'x' || d == 'y' || d == 'z') ++suffix_ion_count; - } + else if (auto p = name.find('$'); p != String::npos && p + 1 < name.size()) + { + const char nc = name[p + 1]; + if (nc == 'a' || nc == 'b' || nc == 'c') ++prefix_ion_count; + else if (nc == 'x' || nc == 'y' || nc == 'z') ++suffix_ion_count; + }(apply to both the ppm and Da branches)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/ID/HyperScore.cpp` around lines 142 - 170, The local char variable named "d" inside the matched-ion loops shadows the function parameter PSMDetail& d in computeWithDetail; rename that inner variable (e.g. to ch or nc) in both branches (the ppm branch where const char d = name[p + 1]; and the Da branch with the same line) so the parameter PSMDetail& d is not shadowed and future edits won't be vulnerable to this latent bug.src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp (1)
494-494:DELTA_SCOREis written unconditionally — diverges from the gatedannotate:PSMpattern.Every other new annotation in this function is gated on a flag derived from
annotate_psm_(e.g.annotation_num_matched_peaks,annotation_matched_prefix_ions, …) so users can opt out via-annotate:PSM.DELTA_SCOREis always stamped onto each PeptideHit and always pushed intoextra_features(line 649). If the intent is "always on", that's fine — but consider adding it to theannotate:PSMvalid strings so the annotation surface stays discoverable/uniform, or gate it symmetrically.🤖 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` at line 494, The code unconditionally sets the DELTA_SCORE meta on each PeptideHit (ph.setMetaValue(Constants::UserParam::DELTA_SCORE, delta_scores[scan_index])) and always pushes it to extra_features, but all other annotations respect the annotate_psm_ gating; make this symmetric by gating the DELTA_SCORE write and its push into extra_features behind the same flag (annotate_psm_ or the same string-set used for other annotations), or if you intend it to be always-on, add "DELTA_SCORE" to the annotate:PSM valid strings so it is discoverable; update the block around ph, delta_scores[scan_index], extra_features and the use of annotate_psm_ to implement the chosen approach.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openms/include/OpenMS/CONCEPT/Constants.h`:
- Around line 347-351: Update the test to use the renamed user-parameter
constants: replace all occurrences of Constants::UserParam::MATCHED_B_IONS with
Constants::UserParam::MATCHED_PREFIX_IONS and
Constants::UserParam::MATCHED_Y_IONS with
Constants::UserParam::MATCHED_SUFFIX_IONS, and change the assertion that
currently checks num_matched == b_ions + y_ions to use the new variable names
(e.g., num_matched == matched_prefix_ions + matched_suffix_ions) so the test
compiles against the updated Constants::UserParam symbols.
---
Outside diff comments:
In `@src/openms/include/OpenMS/ANALYSIS/ID/ProSEAlgorithm.h`:
- Around line 339-340: The Doxygen comments for the members prefix_fraction and
suffix_fraction in ProSEAlgorithm are stale (they say "fraction of annotated
b-ions" / "fraction of annotated y-ions"); update those comments to reflect that
these fields now represent the fraction of annotated prefix ions (a/b/c) and
suffix ions (x/y/z) respectively—e.g., change to "fraction of annotated prefix
ions (a/b/c)" for prefix_fraction and "fraction of annotated suffix ions
(x/y/z)" for suffix_fraction so the docs match current behavior.
In `@src/openms/include/OpenMS/CONCEPT/Constants.h`:
- Around line 375-378: The DELTA_SCORE constant's docstring is ambiguous because
OPXLHelper and XFDR expect a per-rank ratio while ProSEAlgorithm computes a
spectrum-level difference; update the code to resolve this by either clarifying
the docstring of DELTA_SCORE to state it may be used as a per-spectrum
difference in ProSE or introduce a new distinct constant (e.g.,
PROSE_DELTA_SCORE) and update ProSEAlgorithm to use that new constant; ensure
references to DELTA_SCORE remain for OPXLHelper and XFDR and that ProSEAlgorithm
(the code computing best_score - second_best_score) is changed to set or log
PROSE_DELTA_SCORE instead.
In `@src/openms/source/ANALYSIS/ID/HyperScore.cpp`:
- Around line 56-104: The compute() overloads (function compute in
HyperScore.cpp) currently only increment y_ion_count and b_ion_count while
computeWithDetail() classifies all prefix (a/b/c) and suffix (x/y/z) ions;
update the ion classification in each compute() overload (the loops using
MatchedIterator and variables y_ion_count, b_ion_count, i = it.refIdx(), and
ion_names) to mirror computeWithDetail()’s logic (i.e., detect prefixes a/b/c as
"prefix" and x/y/z as "suffix", including handling XL-MS annotations that
include '$' like hasSubstring("$y")/$b/$a/$x/$z) so the factorial weighting
counts the same set of ions as computeWithDetail(); ensure both PpmTrait and
DaTrait branches are changed consistently.
---
Nitpick comments:
In `@src/openms/source/ANALYSIS/ID/HyperScore.cpp`:
- Around line 142-170: The local char variable named "d" inside the matched-ion
loops shadows the function parameter PSMDetail& d in computeWithDetail; rename
that inner variable (e.g. to ch or nc) in both branches (the ppm branch where
const char d = name[p + 1]; and the Da branch with the same line) so the
parameter PSMDetail& d is not shadowed and future edits won't be vulnerable to
this latent bug.
In `@src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp`:
- Line 494: The code unconditionally sets the DELTA_SCORE meta on each
PeptideHit (ph.setMetaValue(Constants::UserParam::DELTA_SCORE,
delta_scores[scan_index])) and always pushes it to extra_features, but all other
annotations respect the annotate_psm_ gating; make this symmetric by gating the
DELTA_SCORE write and its push into extra_features behind the same flag
(annotate_psm_ or the same string-set used for other annotations), or if you
intend it to be always-on, add "DELTA_SCORE" to the annotate:PSM valid strings
so it is discoverable; update the block around ph, delta_scores[scan_index],
extra_features and the use of annotate_psm_ to implement the chosen approach.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d9dcee41-d8aa-4202-b222-d3fd65e4ada3
📒 Files selected for processing (7)
src/openms/include/OpenMS/ANALYSIS/ID/HyperScore.hsrc/openms/include/OpenMS/ANALYSIS/ID/ProSEAlgorithm.hsrc/openms/include/OpenMS/ANALYSIS/ID/SimpleSearchEngineAlgorithm.hsrc/openms/include/OpenMS/CONCEPT/Constants.hsrc/openms/source/ANALYSIS/ID/HyperScore.cppsrc/openms/source/ANALYSIS/ID/ProSEAlgorithm.cppsrc/openms/source/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cpp
✅ Files skipped from review due to trivial changes (1)
- src/openms/include/OpenMS/ANALYSIS/ID/SimpleSearchEngineAlgorithm.h
🚧 Files skipped from review as they are similar to previous changes (2)
- src/openms/include/OpenMS/ANALYSIS/ID/HyperScore.h
- src/openms/source/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cpp
…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]>
4b7cafe to
fdafb4a
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp`:
- Around line 646-649: The code is exporting LONGEST_PEPTIDE_ION_SEQUENCE even
when the run detector only examines b/y ions (causing wrong values for c/z or
a/x rich data); update the logic in the block that builds feature_set (around
annotation_longest_ion_run and related run-detection code) to only push
Constants::UserParam::LONGEST_PEPTIDE_ION_SEQUENCE when the spectrum contains
the corresponding ion-series family or when the run detector has been
generalized to handle both a/c/x/z and b/y families; alternatively, extend the
run-detection routine to consider a/b/c and x/y/z series so
LONGEST_PEPTIDE_ION_SEQUENCE is computed correctly for ETD/EThcD, and ensure
annotation_matched_prefix_ions / annotation_matched_suffix_ions remain
compatible with the chosen approach.
- Around line 345-362: The delta computation incorrectly initializes best_score
and second_best_score to 0.0, which underestimates deltas when h.score can be
negative; in the loop that fills delta_scores for each
annotated_hits[scan_index] (inside the OpenMP parallel for), initialize
best_score and second_best_score to negative infinity (use
std::numeric_limits<double>::lowest()) or otherwise seed them from the first
one/two hits, and handle the empty-hits case so delta_scores[scan_index] is set
to 0.0 (or another defined sentinel) when there are no hits; update the logic
that compares h.score to best/second_best accordingly to produce correct best -
second_best values for negative scores.
In `@src/tests/class_tests/openms/source/ProSEAlgorithm_test.cpp`:
- Around line 1177-1189: The test only checks legacy b/y-style meta-values
(NUM_MATCHED_PEAKS, MATCHED_PREFIX_IONS, MATCHED_SUFFIX_IONS,
LONGEST_PEPTIDE_ION_SEQUENCE) but doesn't assert the new delta_score behavior or
the prefix/suffix aggregation when a/c/x/z ions are enabled; update
ProSEAlgorithm_test.cpp to add assertions that (1) a computed delta_score
meta-value exists and meets expected threshold (check
hit.metaValueExists("delta_score") and its numeric value) and (2) when ETD/EThcD
or a/c/x/z-ion mode is exercised, prefix_ions and suffix_ions reflect
aggregation across a/c/x/z ion matches (create or reuse the test fixture that
enables a/c/x/z, run the matching, then assert prefix_ions + suffix_ions ==
NUM_MATCHED_PEAKS and that prefix_ions/suffix_ions > 0 for that mode). Ensure
you reference and update checks around Constants::UserParam::NUM_MATCHED_PEAKS,
MATCHED_PREFIX_IONS, MATCHED_SUFFIX_IONS, LONGEST_PEPTIDE_ION_SEQUENCE and
validate the new "delta_score" meta key so the ETD/EThcD path is covered.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7016bda0-7ce6-4d4b-9ce4-1b5a88e30dce
📒 Files selected for processing (13)
src/openms/include/OpenMS/ANALYSIS/ID/HyperScore.hsrc/openms/include/OpenMS/ANALYSIS/ID/ProSEAlgorithm.hsrc/openms/include/OpenMS/ANALYSIS/ID/SimpleSearchEngineAlgorithm.hsrc/openms/include/OpenMS/CONCEPT/Constants.hsrc/openms/source/ANALYSIS/ID/HyperScore.cppsrc/openms/source/ANALYSIS/ID/ProSEAlgorithm.cppsrc/openms/source/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cppsrc/tests/class_tests/openms/source/ProSEAlgorithm_test.cppsrc/tests/topp/ProSE_1_out.idXMLsrc/tests/topp/ProSE_2_out.idXMLsrc/tests/topp/ProSE_4_out.idXMLsrc/tests/topp/SimpleSearchEngine_1_out.idXMLsrc/tests/topp/SimpleSearchEngine_2_out.idXML
✅ Files skipped from review due to trivial changes (1)
- src/openms/include/OpenMS/ANALYSIS/ID/SimpleSearchEngineAlgorithm.h
🚧 Files skipped from review as they are similar to previous changes (4)
- src/openms/include/OpenMS/ANALYSIS/ID/ProSEAlgorithm.h
- src/openms/source/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cpp
- src/openms/include/OpenMS/ANALYSIS/ID/HyperScore.h
- src/openms/source/ANALYSIS/ID/HyperScore.cpp
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]>
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp (1)
357-363:⚠️ Potential issue | 🟠 MajorNegative-score regression in delta_score still unaddressed.
Initializing
best_score/second_best_scoreto0.0breaks the PR's own "single candidate → delta = full score" convention whenln(hyperscore)is negative: a single negative hit yieldsdelta = 0(not its score), and two negative hits yielddelta = 0instead ofbest - second_best. Seed from the first hit's score (orstd::numeric_limits<double>::lowest()) and track whether a second was seen.♻️ Proposed fix
- // O(N) pass: find top-2 scores for delta. Leaves partial_sort unchanged. - double best_score = 0.0, second_best_score = 0.0; - for (const auto& h : hits) - { - if (h.score > best_score) { second_best_score = best_score; best_score = h.score; } - else if (h.score > second_best_score) { second_best_score = h.score; } - } - delta_scores[scan_index] = static_cast<float>(best_score - second_best_score); + // O(N) pass: find top-2 scores for delta. Leaves partial_sort unchanged. + if (!hits.empty()) + { + double best_score = hits[0].score; + double second_best_score = 0.0; + bool has_second = false; + for (Size i = 1; i < hits.size(); ++i) + { + const double s = hits[i].score; + if (s > best_score) { second_best_score = best_score; best_score = s; has_second = true; } + else if (!has_second || s > second_best_score) { second_best_score = s; has_second = true; } + } + delta_scores[scan_index] = static_cast<float>(has_second ? (best_score - second_best_score) : best_score); + }🤖 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 357 - 363, The current loop in ProSEAlgorithm.cpp that computes best_score/second_best_score initializes them to 0.0 which incorrectly handles negative ln(hyperscore) values; change the logic in the block that iterates "for (const auto& h : hits)" to initialize best/second properly (either seed best_score from the first hit's h.score and use a boolean/ counter to detect if a second hit was seen, or initialize to std::numeric_limits<double>::lowest()), update second_best only after a real value is seen, and when writing delta_scores[scan_index] preserve the "single candidate → delta = full score" behavior by computing best_score - second_best only when a second hit exists (otherwise set delta to best_score). Ensure you update the variables referenced (best_score, second_best_score, delta_scores[scan_index]) and any local counters in ProSEAlgorithm.cpp accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/tests/topp/ProSE_1_out.idXML`:
- Line 7: Update the FuzzyDiff whitelist so the dynamic search_engine_version
attribute is ignored: locate the whitelist pattern that currently contains
"IdentificationRun date" in the CMakeLists whitelist block and add a new pattern
"IdentificationRun search_engine_version" alongside it so branches with
different search_engine_version values (e.g., feat-prose-percolator-features) no
longer cause test failures.
---
Duplicate comments:
In `@src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp`:
- Around line 357-363: The current loop in ProSEAlgorithm.cpp that computes
best_score/second_best_score initializes them to 0.0 which incorrectly handles
negative ln(hyperscore) values; change the logic in the block that iterates "for
(const auto& h : hits)" to initialize best/second properly (either seed
best_score from the first hit's h.score and use a boolean/ counter to detect if
a second hit was seen, or initialize to std::numeric_limits<double>::lowest()),
update second_best only after a real value is seen, and when writing
delta_scores[scan_index] preserve the "single candidate → delta = full score"
behavior by computing best_score - second_best only when a second hit exists
(otherwise set delta to best_score). Ensure you update the variables referenced
(best_score, second_best_score, delta_scores[scan_index]) and any local counters
in ProSEAlgorithm.cpp accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 23018467-685c-48e2-9ab9-565eb10d170f
📒 Files selected for processing (9)
src/openms/include/OpenMS/CONCEPT/Constants.hsrc/openms/source/ANALYSIS/ID/ProSEAlgorithm.cppsrc/openms/source/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cppsrc/tests/class_tests/openms/source/ProSEAlgorithm_test.cppsrc/tests/topp/ProSE_1_out.idXMLsrc/tests/topp/ProSE_2_out.idXMLsrc/tests/topp/ProSE_4_out.idXMLsrc/tests/topp/SimpleSearchEngine_1_out.idXMLsrc/tests/topp/SimpleSearchEngine_2_out.idXML
🚧 Files skipped from review as they are similar to previous changes (5)
- src/tests/topp/ProSE_2_out.idXML
- src/openms/include/OpenMS/CONCEPT/Constants.h
- src/tests/topp/SimpleSearchEngine_2_out.idXML
- src/tests/topp/SimpleSearchEngine_1_out.idXML
- src/tests/topp/ProSE_4_out.idXML
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]>
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]>
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]>
Summary
Three tightly-related improvements to ProSE's Percolator feature set, bundled because they touch the same code paths (HyperScore, ProSEAlgorithm, SSE, Constants.h).
1. Rename
matched_b_ions/matched_y_ions→matched_prefix_ions/matched_suffix_ionsWith PR #9167 enabling a/b/c/x/y/z ion types, the old names were misleading — these counters track ALL prefix (a/b/c) and suffix (x/y/z) ions, not just b/y. Renamed across HyperScore, ProSE, SimpleSearchEngine, and Constants.h. MetaValue strings also renamed (
"matched_prefix_ions"/"matched_suffix_ions"). No backward compatibility concern — ProSE is unreleased.2. Fix HyperScore to count all prefix/suffix ion types
Previously
HyperScore::computeWithDetail()only counted'b'and'y'ions in the factorial terms (lines 147-154). With c/z ions enabled, those ions contributed to the dot_product (intensity matching) but NOT to the ion-count factorial boost — silently penalizing ETD/EThcD searches.Fixed: the fast path checks
a/b/c(prefix) andx/y/z(suffix) via single-char comparison — O(1) per ion, zero regression for CID/HCD. XL-MS$-prefix fallback preserved for NuXL: falls through tofind('$')only when first char doesn't match any ion letter.3. Delta score (new Percolator feature)
Score difference between the best and second-best PSM for each spectrum. The single most discriminative Percolator feature after the primary score — used by Comet (deltaCN), Sage (delta_next), and MSFragger (delta_hyperscore).
Implementation: O(N) running-max pass over candidates BEFORE
partial_sort— zero change to the existing sort (stillk=top_hits). When only one candidate exists, delta = full score (same convention as Sage/MSFragger). Wired unconditionally intoextra_featuresfor Percolator.Also wires
longest_peptide_ion_sequenceandmatched_prefix/suffix_ionsintoextra_features— these were already computed bypostProcessHits_()but previously not passed to Percolator.Files changed (7)
HyperScore.h/.cpp— rename + all-ion-type countingProSEAlgorithm.h/.cpp— rename + delta_score field + extra_features wiringSimpleSearchEngineAlgorithm.h/.cpp— rename (SSE shares the same struct/constants)Constants.h— rename MetaValue string constantsTest Plan
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Refactor
Tests