Skip to content

feat: NumMatchedPeaks, longest ion run, fragment annotations - #9117

Merged
timosachsenberg merged 9 commits into
developfrom
feat/num-matched-peaks
Apr 9, 2026
Merged

timosachsenberg merged 9 commits into
developfrom
feat/num-matched-peaks

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Per-PSM annotations: num_matched_peaks, matched_b_ions, matched_y_ions, longest_peptide_ion_sequence, and full fragment_annotation (PeakAnnotation vector for TOPPView visualization)
  • Applied to both PeptideSearchEngineFIAlgorithm and SimpleSearchEngineAlgorithm
  • Fragment annotations exported to PSM and QPX parquet formats via dedicated mz_array, intensity_array, charge_array, ion_type_array columns
  • fragment_annotation metavalue excluded from parquet psm_metavalues bag to avoid duplication

Depends on #9112 (semi/non-specific digestion).

Addresses item #3 from #9108.

Bugfixes included

  • Decoy generation: use reverseProtein() (plain full reverse) when enzyme_specificity=none instead of enzyme-aware reversePeptides(), so decoy search space matches the non-specific target space
  • EnzymaticDigestion: semiSpecificDigestion_() returns (start, end) pairs but two digestUnmodified() callers consumed them as (start, length) — fixed at the call sites

Implementation details

  • HyperScore::PSMDetail already computed matched b/y counts during scoring — now propagated to AnnotatedHit_ as uint16_t fields
  • Fragment annotations built in postProcessHits_ for top-N hits only (not in the scoring hot loop) by reusing the existing TheoreticalSpectrumGenerator + SpectrumAlignment code path
  • Longest consecutive ion run computed from alignment ion names (parses "b5", "y3-H2O1+" etc.)
  • All new annotations gated behind the existing annotate:PSM parameter (included in "ALL")
  • Removed dead fragment_annotations field from AnnotatedHit_; struct shrunk from 72 to 40 bytes via field reordering + float for fraction/error fields

Test plan

  • New class test: synthetic spectrum from known peptide, verifies all new metavalues + PeakAnnotations
  • All 20 existing TOPP + class tests pass (reference files updated for new annotations)
  • ArrowSchemaRegistry test updated for new PSMSchema field count (25 → 29)
  • QPXFile test passes

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added detailed fragment ion matching metrics to peptide search results: matched b-ion and y-ion counts, total matched peaks, and longest consecutive ion series.
    • Introduced configurable enzyme specificity modes (full/semi/none) for controlling peptide generation during searches.
    • Fragment peak annotations now exported in search results with ion details.
  • Bug Fixes

    • Improved robustness in handling empty fragment indexes and short input sequences.

timosachsenberg and others added 6 commits April 9, 2026 14:18
…structs

Add constants for matched_b_ions, matched_y_ions, num_matched_peaks,
and longest_peptide_ion_sequence. Remove dead fragment_annotations
field from both AnnotatedHit_ structs and add matched_b_ions /
matched_y_ions counters in preparation for per-PSM ion statistics.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
… ion run, fragment annotations

Register new annotate:PSM options (num_matched_peaks, matched_b_ions,
matched_y_ions, longest_peptide_ion_sequence, fragment_annotation) and
implement their annotation logic in postProcessHits_. Refactors the
theoretical spectrum generation + alignment to be shared across all
alignment-dependent annotations (fragment error, fragment annotations,
longest ion run). Updates TOPP test reference files to include the new
annotation fields.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…n run, fragment annotations

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

Reorder struct members (doubles, floats, int, uint16_t) to minimize
padding and use float instead of double for prefix_fraction,
suffix_fraction, and mean_error (summary statistics where 7 significant
digits is sufficient). Reduces AnnotatedHit_ from 56 to 40 bytes
(excluding AASequence/StringView), down from 72 bytes before this PR.

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

coderabbitai Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This pull request adds configurable enzyme specificity support to peptide search algorithms and enhances PSM metrics tracking. It introduces digestion specificity parameters (full/semi/none) across FragmentIndex and search engines, adds new fragment ion matching metrics (matched b-ions, y-ions, and longest consecutive ion sequence), extends the Arrow schema for dedicated fragment annotation column storage, and updates EnzymaticDigestion to handle semi-specific and non-specific cleavage modes.

Changes

Cohort / File(s) Summary
Enzyme Specificity Configuration
OpenMS/ANALYSIS/ID/FragmentIndex.h, OpenMS/ANALYSIS/ID/FragmentIndex.cpp
Added enzyme_specificity_ member with peptide:enzyme_specificity parameter support; integrated specificity into digestion workflow; added early-exit guard for empty fragment indices to prevent bucketization errors.
Search Engine Specificity Integration
OpenMS/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.h, OpenMS/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp, OpenMS/ANALYSIS/ID/SimpleSearchEngineAlgorithm.h, OpenMS/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cpp
Added peptide_enzyme_specificity_ members and parameter wiring; refactored AnnotatedHit_ to replace double fractions with float and remove fragment_annotations vector; added matched_b_ions and matched_y_ions uint16_t fields; propagated specificity through digestion, search parameters, decoy generation, and peptide reindexing.
Fragment Metrics Constants
OpenMS/CONCEPT/Constants.h
Added four new UserParam constants: MATCHED_B_IONS, MATCHED_Y_IONS, NUM_MATCHED_PEAKS, and LONGEST_PEPTIDE_ION_SEQUENCE for PSM annotation output.
Arrow Schema and PSM Storage
OpenMS/FORMAT/ArrowSchemaRegistry.h, OpenMS/FORMAT/ArrowSchemaRegistry.cpp, OpenMS/FORMAT/QPXFile.cpp
Extended PSMSchema with four new array fields (mz_array, intensity_array, charge_array, ion_type_array); updated QPXFile to populate these dedicated fragment annotation columns from PeptideHit::getPeakAnnotations() and exclude legacy fragment annotation metadata.
Digestion Engine Enhancements
OpenMS/CHEMISTRY/EnzymaticDigestion.cpp
Added guards for underflow when sequence size < min_length; expanded non-specific cleavage condition to include SPEC_NONE specificity mode; implemented semi-specific digestion behavior by appending sequence-end position and generating start-end pairs.
Test Updates and Coverage
ArrowSchemaRegistry_test.cpp, EnzymaticDigestion_test.cpp, FragmentIndex_test.cpp, PeptideSearchEngineFIAlgorithm_test.cpp
Updated schema field count assertion; added tests for SPEC_NONE and SPEC_SEMI digestion modes with edge cases; added fragment index specificity variations test; added PSM annotation validation test with matched ion counts and peak annotations.
Test Output Files
PeptideDataBaseSearchFI_1_out.idXML, PeptideDataBaseSearchFI_2_out.idXML, SimpleSearchEngine_1_out.idXML, SimpleSearchEngine_2_out.idXML
Updated metadata timestamps and engine versions; added new UserParam fields to PeptideHit entries for fragment_annotation, num_matched_peaks, matched_b_ions, matched_y_ions, and longest_peptide_ion_sequence.

Sequence Diagram

sequenceDiagram
    participant Config as Search Config
    participant SE as Search Engine
    participant ED as EnzymaticDigestion
    participant SA as Search Algorithm
    participant PS as PSM Scoring
    participant AR as Arrow Storage
    
    Config->>SE: peptide:enzyme_specificity<br/>(full|semi|none)
    SE->>ED: setSpecificity(specificity_)
    ED->>ED: digest() with SPEC_FULL/<br/>SPEC_SEMI/SPEC_NONE
    ED-->>SA: peptides (varying cardinality)
    SA->>PS: match fragments<br/>count b/y ions<br/>compute longest run
    PS->>PS: calculate metrics:<br/>matched_b_ions<br/>matched_y_ions<br/>num_matched_peaks<br/>longest_peptide_ion_sequence
    PS->>PS: generate peak<br/>annotations
    PS->>AR: store in PSM
    AR->>AR: populate mz/intensity/<br/>charge/ion_type arrays
Loading

Possibly related issues

Possibly related PRs

Suggested reviewers

  • jpfeuffer
  • cbielow

🐰 Hops with glee, whiskers twitching—
Enzymes now bend to our will with specificity,
Fragments sing their b and y ion melody,
Longest runs of peptides stretch far and wide,
All safely nestled in Arrow's embrace! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% 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 pull request title accurately summarizes the main additions: num_matched_peaks, longest ion run, and fragment annotations for PSM outputs.

✏️ 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 feat/num-matched-peaks

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.

Actionable comments posted: 2

Caution

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

⚠️ Outside diff range comments (1)
src/tests/class_tests/openms/source/ArrowSchemaRegistry_test.cpp (1)

760-765: ⚠️ Potential issue | 🟡 Minor

Please assert the four new PSMSchema columns explicitly.

Bumping the field count to 29 alone will still pass if one of mz_array, intensity_array, charge_array, or ion_type_array is renamed, reordered, or given the wrong type. Add direct constant/type/nullability checks for those fields so the new schema contract is actually covered.

As per coding guidelines, "Write unit tests for new functionality and ensure existing tests pass before suggesting changes".

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

In `@src/tests/class_tests/openms/source/ArrowSchemaRegistry_test.cpp` around
lines 760 - 765, The test currently only checks PSMSchema::schema() is non-null
and has num_fields()==29; update the test block to also assert the four new
columns explicitly by locating the schema via PSMSchema::schema() and verifying
each field: check a field exists with the exact name "mz_array",
"intensity_array", "charge_array", and "ion_type_array" and assert each has the
expected data type and nullability (e.g., expected field->type() and
field->nullable() values) so renames, reordering, or wrong types will fail the
test instead of relying only on the field count.
🧹 Nitpick comments (3)
src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp (2)

448-451: Consider adding a defensive check for data array availability.

Accessing theoretical_spec.getStringDataArrays()[0] and getIntegerDataArrays()[0] assumes these arrays are populated. While TheoreticalSpectrumGenerator with add_metainfo=true should always create them, an empty theoretical spectrum (e.g., for a very short peptide) could potentially leave these arrays empty.

💡 Optional defensive check
           if (annotation_fragment_annotations || annotation_longest_ion_run)
           {
+            if (theoretical_spec.getStringDataArrays().empty() || theoretical_spec.getIntegerDataArrays().empty())
+            {
+              // Fallback: skip annotations if metainfo arrays are missing
+              continue;
+            }
             const auto& ion_names = theoretical_spec.getStringDataArrays()[0];
             const auto& ion_charges = theoretical_spec.getIntegerDataArrays()[0];
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp` around
lines 448 - 451, The code assumes theoretical_spec.getStringDataArrays()[0] and
getIntegerDataArrays()[0] exist when annotation_fragment_annotations or
annotation_longest_ion_run is true; add a defensive check on
theoretical_spec.getStringDataArrays().size() and
theoretical_spec.getIntegerDataArrays().size() (and that the first array is
non-empty) before indexing, and if missing skip the annotation block or fall
back to safe defaults so annotation_fragment_annotations /
annotation_longest_ion_run do not dereference empty arrays.

496-510: Consider extracting longestRun as a shared utility function.

This lambda is duplicated verbatim in SimpleSearchEngineAlgorithm.cpp (lines 458-469). Extracting it to a shared location (e.g., a helper in MathFunctions.h or a static method) would reduce duplication and ensure consistent behavior.

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

In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp` around
lines 496 - 510, The lambda longestRun used here (operating on vectors like
b_ordinals and y_ordinals and producing the value stored via ph.setMetaValue
with Constants::UserParam::LONGEST_PEPTIDE_ION_SEQUENCE) is duplicated in
SimpleSearchEngineAlgorithm.cpp; extract it into a shared utility (e.g., add a
function int longestConsecutiveRun(std::vector<int> v) in a common header like
MathFunctions.h or as a static helper in a shared class) and replace the local
lambda in both PeptideSearchEngineFIAlgorithm.cpp and
SimpleSearchEngineAlgorithm.cpp with calls to that new function to remove
duplication and keep behavior consistent.
src/openms/source/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cpp (1)

409-413: Same defensive check consideration as in PeptideSearchEngineFIAlgorithm.cpp.

The access to theoretical_spec.getStringDataArrays()[0] and getIntegerDataArrays()[0] has the same potential edge case as noted in the other algorithm file.

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

In `@src/openms/source/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cpp` around lines
409 - 413, The code reads theoretical_spec.getStringDataArrays()[0] and
getIntegerDataArrays()[0] without ensuring those arrays are non-empty, which can
crash if no data arrays exist; update the fragment-annotation block guarded by
the flags annotation_fragment_annotations and annotation_longest_ion_run to
first check that theoretical_spec.getStringDataArrays().size() > 0 and
theoretical_spec.getIntegerDataArrays().size() > 0 (or that the specific array
indices exist), and only then assign ion_names and ion_charges from [0]; if
missing, skip annotation logic or provide a safe fallback (e.g., empty arrays)
so functions using ion_names/ion_charges do not dereference out-of-range
elements.
🤖 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/FragmentIndex.cpp`:
- Around line 772-777: The early-return path in FragmentIndex::build leaves the
object marked built with bucketsize_ == 0 which breaks consumers iterating by
bucketsize_; update the empty-index branch to keep bucketsize_ non-zero (e.g.
set bucketsize_ = 1 instead of 0) while logging and setting is_build_ = true so
consumers that loop with fi_idx += bucketsize_ won’t hang; modify the block
referencing fi_fragments_, bucketsize_, and is_build_ accordingly.

In `@src/tests/class_tests/openms/source/FragmentIndex_test.cpp`:
- Around line 289-329: The cross-mode comparison uses semi_count computed with
peptide:min_size=2/max_size=100 but fi_none uses 8..12; recreate the
semi-specific baseline using the same length window before comparing: adjust the
FragmentIndex_test fi_semi parameters (via
fi_semi.getParameters()/p.setValue("peptide:min_size", 8) and
p.setValue("peptide:max_size", 12)) and rebuild fi_semi to set semi_count, or
alternatively drop the TEST_EQUAL(fi_none.getPeptides().size() > semi_count,
true) assertion; update the code around fi_semi, fi_semi.setParameters(p),
fi_semi.build(entries), and semi_count = fi_semi.getPeptides().size()
accordingly so both modes use the same 8..12 window.

---

Outside diff comments:
In `@src/tests/class_tests/openms/source/ArrowSchemaRegistry_test.cpp`:
- Around line 760-765: The test currently only checks PSMSchema::schema() is
non-null and has num_fields()==29; update the test block to also assert the four
new columns explicitly by locating the schema via PSMSchema::schema() and
verifying each field: check a field exists with the exact name "mz_array",
"intensity_array", "charge_array", and "ion_type_array" and assert each has the
expected data type and nullability (e.g., expected field->type() and
field->nullable() values) so renames, reordering, or wrong types will fail the
test instead of relying only on the field count.

---

Nitpick comments:
In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp`:
- Around line 448-451: The code assumes
theoretical_spec.getStringDataArrays()[0] and getIntegerDataArrays()[0] exist
when annotation_fragment_annotations or annotation_longest_ion_run is true; add
a defensive check on theoretical_spec.getStringDataArrays().size() and
theoretical_spec.getIntegerDataArrays().size() (and that the first array is
non-empty) before indexing, and if missing skip the annotation block or fall
back to safe defaults so annotation_fragment_annotations /
annotation_longest_ion_run do not dereference empty arrays.
- Around line 496-510: The lambda longestRun used here (operating on vectors
like b_ordinals and y_ordinals and producing the value stored via
ph.setMetaValue with Constants::UserParam::LONGEST_PEPTIDE_ION_SEQUENCE) is
duplicated in SimpleSearchEngineAlgorithm.cpp; extract it into a shared utility
(e.g., add a function int longestConsecutiveRun(std::vector<int> v) in a common
header like MathFunctions.h or as a static helper in a shared class) and replace
the local lambda in both PeptideSearchEngineFIAlgorithm.cpp and
SimpleSearchEngineAlgorithm.cpp with calls to that new function to remove
duplication and keep behavior consistent.

In `@src/openms/source/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cpp`:
- Around line 409-413: The code reads theoretical_spec.getStringDataArrays()[0]
and getIntegerDataArrays()[0] without ensuring those arrays are non-empty, which
can crash if no data arrays exist; update the fragment-annotation block guarded
by the flags annotation_fragment_annotations and annotation_longest_ion_run to
first check that theoretical_spec.getStringDataArrays().size() > 0 and
theoretical_spec.getIntegerDataArrays().size() > 0 (or that the specific array
indices exist), and only then assign ion_names and ion_charges from [0]; if
missing, skip annotation logic or provide a safe fallback (e.g., empty arrays)
so functions using ion_names/ion_charges do not dereference out-of-range
elements.
🪄 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: 6e9353e2-0ff9-478d-a19f-812ab5a54361

📥 Commits

Reviewing files that changed from the base of the PR and between abbc6c9 and 276a9f5.

📒 Files selected for processing (19)
  • src/openms/include/OpenMS/ANALYSIS/ID/FragmentIndex.h
  • src/openms/include/OpenMS/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.h
  • src/openms/include/OpenMS/ANALYSIS/ID/SimpleSearchEngineAlgorithm.h
  • src/openms/include/OpenMS/CONCEPT/Constants.h
  • src/openms/include/OpenMS/FORMAT/ArrowSchemaRegistry.h
  • src/openms/source/ANALYSIS/ID/FragmentIndex.cpp
  • src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp
  • src/openms/source/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cpp
  • src/openms/source/CHEMISTRY/EnzymaticDigestion.cpp
  • src/openms/source/FORMAT/ArrowSchemaRegistry.cpp
  • src/openms/source/FORMAT/QPXFile.cpp
  • src/tests/class_tests/openms/source/ArrowSchemaRegistry_test.cpp
  • src/tests/class_tests/openms/source/EnzymaticDigestion_test.cpp
  • src/tests/class_tests/openms/source/FragmentIndex_test.cpp
  • src/tests/class_tests/openms/source/PeptideSearchEngineFIAlgorithm_test.cpp
  • src/tests/topp/PeptideDataBaseSearchFI_1_out.idXML
  • src/tests/topp/PeptideDataBaseSearchFI_2_out.idXML
  • src/tests/topp/SimpleSearchEngine_1_out.idXML
  • src/tests/topp/SimpleSearchEngine_2_out.idXML

Wire up PeptideHit::getPeakAnnotations() to the mz_array, intensity_array,
charge_array, and ion_type_array columns in both PSMSchema and QPXPSMSchema
parquet exports. Exclude the fragment_annotation metavalue (idXML string
format) from the psm_metavalues bag to avoid duplication.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@timosachsenberg
timosachsenberg force-pushed the feat/num-matched-peaks branch from 276a9f5 to 754f3f5 Compare April 9, 2026 12:26
timosachsenberg and others added 2 commits April 9, 2026 14:37
…i-vs-none test

- FragmentIndex::build: set bucketsize_ to 1 instead of 0 for empty
  indexes to preserve bucket-walking loop invariants.
- FragmentIndex_test: compare semi vs none using the same 8..12 length
  window so the assertion is not dependent on mismatched parameters.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@timosachsenberg
timosachsenberg merged commit 248e51a into develop Apr 9, 2026
41 checks passed
@timosachsenberg
timosachsenberg deleted the feat/num-matched-peaks branch April 9, 2026 14:37
github-actions Bot pushed a commit that referenced this pull request Apr 10, 2026
Add missing entries for three features merged after last changelog sync:
- PeptideDataBaseSearchFI multi-file search with shared fragment index (#9109)
- Semi-tryptic and non-specific digestion in PeptideDataBaseSearchFI and
  SimpleSearchEngine via new peptide:enzyme_specificity parameter (#9112)
- New PSM annotation options (num_matched_peaks, matched_b_ions,
  matched_y_ions, longest_peptide_ion_sequence, fragment_annotation)
  in PeptideDataBaseSearchFI and SimpleSearchEngine, with parquet export (#9117)

Co-authored-by: Copilot <[email protected]>
timosachsenberg pushed a commit that referenced this pull request Apr 10, 2026
Add missing entries for three features merged after last changelog sync:
- PeptideDataBaseSearchFI multi-file search with shared fragment index (#9109)
- Semi-tryptic and non-specific digestion in PeptideDataBaseSearchFI and
  SimpleSearchEngine via new peptide:enzyme_specificity parameter (#9112)
- New PSM annotation options (num_matched_peaks, matched_b_ions,
  matched_y_ions, longest_peptide_ion_sequence, fragment_annotation)
  in PeptideDataBaseSearchFI and SimpleSearchEngine, with parquet export (#9117)

Co-authored-by: GitHub Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
timosachsenberg added a commit that referenced this pull request Apr 17, 2026
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]>
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]>
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