Skip to content

[FIX] Percolator features: protein terminus in enzN/enzC; in-process parity (CalcMass, -cpos) - #10717

Merged
timosachsenberg merged 2 commits into
developfrom
claude/keen-franklin-awmnl1
Oct 25, 2026
Merged

timosachsenberg merged 2 commits into
developfrom
claude/keen-franklin-awmnl1

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

1. A protein terminus counts as a cleavage site in enzN/enzC

The .pin enzyme features (enzN, enzC) never counted a protein terminus as a cleavage site. This affects -out_pin of ProSE and PercolatorAdapter and the in-process Percolator rescoring.

  • OpenMS marks a protein terminus as [ / ] (PeptideEvidence::N_TERMINAL_AA / C_TERMINAL_AA).
  • The enzyme rules, adapted from Percolator's converters, expect - and count it as enzymatic.
  • stampPinFeaturesOnHits() mapped [/] to - only for the Peptide column, after enzN/enzC were computed. So a peptide at a protein's N-terminus got enzN = 0, and one at its C-terminus enzC = 0.

The mapping now happens before the features are computed. Found while reviewing #10713.

2. In-process Percolator: two differences from the executable

With correct enzN/enzC, the "realistic idXML" sections of Percolator_subprocess_parity_test and PercolatorAdapter_parity_test failed: in-process vs executable r = 0.955 / 0.90, threshold 0.99.

Why they had passed before:

  • Their fixture (THIRDPARTY/CometAdapter_4_out.idXML, fully tryptic) had 37 N-terminal and 30 C-terminal PSMs with the wrong enzN/enzC = 0.
  • With those, training failed in both implementations (0 test-set PSMs at q < 0.5) and both reset to the same default vector.
  • So the sections compared that fallback, not trained models.

Now training succeeds, which exposed two in-process differences:

  • CalcMass was a training feature in Percolator::rescorePSMs(). The executable reads it from the .pin as metadata, as the parity test's own helper does. It is now passed only as RescoreInput::calc_masses. This affects in-process PercolatorAdapter and ProSE rescoring.
  • PercolatorAdapter -cpos 0 ("Set by cross validation") was ignored in-process. The in-process path kept the library default c_pos = 0.1, while the executable selects Cpos by cross-validation when no -p is given. The adapter now passes c_pos = 0, which cross-validates.

With both, PercolatorAdapter_parity_test matches exactly (r = 1.000000); each fix alone gives r = 0.78 / 0.89. The library-layer section compared in-process with c_pos 0.1 against the executable without -p; it now passes -p 0.1.

3. Percolator_test

The rescorePSMs check counted targets at q ≤ 0.01 (more than 100). Without CalcMass as a feature, 93 of 300 reach that, and all 300 reach q ≤ 0.05. The check now counts targets at q ≤ 0.05 (more than 250) and decoys at q ≤ 0.01 (fewer than 10). On that data, in-process q-values differ from the executable's even after these fixes; that is tracked separately in #10718.

Tests (local Release build on Linux, without GUI, OpenTIMS and Thermo RAW; Percolator 3.06 from THIRDPARTY):

  • PercolatorInfile_test: features with [ before / ] after, by a Percolator rule and a ProteaseDB rule. Fails without fix 1.
  • Percolator/PercolatorInfile/ProSE tests (219, including both parity tests): all pass.
  • Full suite: all pass apart from StopWatch_test, which failed once under -j4 load and passes alone.
  • No reference output changes: the ProSE tests with protein-terminal PSMs run with -Search:rescore false.

Checklist

  • Make sure that you are listed in the AUTHORS file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

🤖 Generated with Claude Code

https://claude.ai/code/session_01EERt1z5XLKf5zx7xXpXGg9

Summary by CodeRabbit

  • Bug Fixes
    • Protein-terminal peptide evidence is now handled consistently when formatting peptides and calculating enzyme features, including for Trypsin/P, Lys-C, and Lys-C/P.
    • Percolator rescoring no longer uses calculated mass as a numeric training feature.
    • The in-process Percolator backend now applies the configured -cpos value even when it is zero.
    • Rescoring confidence thresholds now distinguish target and decoy identifications.

…in the enzyme features

OpenMS marks a protein terminus as '[' / ']' (PeptideEvidence), the enzyme rules (adapted from Percolator's
converters) as '-': it was mapped to '-' only for the Peptide column, after enzN/enzC were computed, so a
protein-terminal peptide never had enzN or enzC set. The terminus is now mapped before.

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

Copy link
Copy Markdown
Contributor Author

CI red: Percolator_subprocess_parity_test and PercolatorAdapter_parity_test. Both fail their "realistic idXML" sections: in-process vs executable scores reach r = 0.955 against the required 0.99. Both tests need the bundled Percolator executable, so they didn't run in my first local test run. I reproduced them locally with the THIRDPARTY binary.

Cause. The fixture (THIRDPARTY/CometAdapter_4_out.idXML) is a fully tryptic Comet search with 712 PSMs.

  • Before this fix, its 37 protein-N-terminal and 30 protein-C-terminal PSMs were the only ones with enzN/enzC = 0.
  • With those wrong values, training failed in both implementations: 0 test-set PSMs at q < 0.5, then Resetting score vector, using default vector.
  • Both fell back to the same default direction, so in-process and executable scores matched exactly (r = 1.0). The sections passed on that fallback, which the test's own header comment calls unsuitable for parity.
  • With the fix, enzN and enzC are correctly 1 for all 712 PSMs. The executable gives them weight 0, and training succeeds (11–17 PSMs at q < 0.5).
  • The vendored 3.08 in-process code and the bundled 3.06 executable then train different models on this small set: r = 0.955 at the adapter layer and 0.90 when comparing the PercolatorAdapter outputs. Each path's own scores change completely (r ≈ 0.17 against its pre-fix scores), because the fallback is gone.

The fix itself stays: the enzyme features were wrong for protein-terminal peptides. What has to change is the parity tests' realistic fixture, which needs one that trains without the fallback. DatabaseSuitability_in_id.idXML with -generic_feature_set also falls back, so it doesn't fit either. I'm checking with the author how to proceed rather than relaxing thresholds.


Generated by Claude Code

…olatorAdapter -cpos 0 selects Cpos by cross-validation

With correct enzN/enzC (previous commit), the realistic sections of the Percolator parity tests no longer pass on
the fallback both implementations took on their fixture (training failed, both reset to the default vector), and
in-process and executable training diverged (r 0.955 / 0.90). Two in-process differences from the executable:

- Percolator::rescorePSMs() trained on the CalcMass column, which the executable reads as metadata (as the
  parity test's own helper does). It now passes it only as RescoreInput::calc_masses.
- PercolatorAdapter -cpos 0 ("set by cross validation") left the library default c_pos 0.1 in-process; the
  executable selects Cpos by cross-validation without -p. It now passes c_pos 0, which does the same.

With both, the adapter parity test matches exactly (r = 1.0; each fix alone: 0.78 / 0.89). The library parity
test's realistic section compared in-process with c_pos 0.1 against the executable without -p; it passes -p 0.1.

Percolator_test's rescorePSMs check counted targets at q <= 0.01 (> 100); without CalcMass as a feature 93 reach
it, all 300 reach q <= 0.05. The check counts targets at q <= 0.05 now; the q-value difference from the
executable on that data is #10718.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EERt1z5XLKf5zx7xXpXGg9
@timosachsenberg timosachsenberg changed the title [FIX] PercolatorInfile: a protein terminus counts as a cleavage site in enzN/enzC [FIX] Percolator features: protein terminus in enzN/enzC; in-process parity (CalcMass, -cpos) Oct 25, 2026
@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a9571c9e-fe60-4ab8-8f7b-51c2324ddd39
Commits

Reviewing files that changed from the base of the PR and between 8e514b7 and a11dde3.

Files selected for processing: 4
  • src/openms/source/ANALYSIS/ID/Percolator.cpp
  • src/tests/class_tests/openms/source/Percolator_subprocess_parity_test.cpp
  • src/tests/class_tests/openms/source/Percolator_test.cpp
  • src/topp/PercolatorAdapter.cpp

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

Walkthrough

Percolator now normalizes protein-terminal flank markers before enzyme-feature calculations and peptide formatting. The in-process backend excludes CalcMass from numeric training features and always applies the configured c_pos value. Tests cover terminal enzyme features, subprocess parity settings, and rescore confidence counts.

Changes: Percolator behavior and validation

Layer / File(s) Summary
Normalize terminal flanks and verify enzyme features
src/openms/source/FORMAT/PercolatorInfile.cpp, src/tests/class_tests/openms/source/PercolatorInfile_test.cpp
Terminal flank markers are normalized before enzyme-feature calculations and peptide formatting. Tests cover N- and C-terminal markers for Trypsin/P, Lys-C, and Lys-C/P.
Align in-process training inputs and parameters
src/openms/source/ANALYSIS/ID/Percolator.cpp, src/topp/PercolatorAdapter.cpp, src/tests/class_tests/openms/source/Percolator_subprocess_parity_test.cpp, src/tests/class_tests/openms/source/Percolator_test.cpp
CalcMass is excluded from numeric training features, and the in-process backend always sets c_pos from -cpos. Tests set the subprocess -p value and update target and decoy q-value count expectations.

Possibly related PRs

  • OpenMS/OpenMS#10713: This PR changes the same enzyme-feature code path and tests terminal flank handling.

Suggested reviewers: jpfeuffer

Priority: Normal

Change: Bug fix

Merge Risk: Minimal · up to a11dd

No actionable merge-blocking risk is established by the reviewed changes.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the two main parts of the change: protein-terminus handling for the enzN/enzC Percolator features, and in-process parity via CalcMass and -cpos. The raw summary shows the terminus norm…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two main parts of the change: protein-terminus handling for the enzN/enzC Percolator features, and in-process parity via CalcMass and -cpos. The raw summary shows the terminus normalization in PercolatorInfile.cpp, the CalcMass exclusion in Percolator.cpp, and the c_pos assignment in PercolatorAdapter.cpp, so the title matches the changeset. It is long at 93 characters, and the parenthetical tokens are dense, but it is specific and accurate.

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

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

❤️ Share

A rabbit checks the flank markers in a row,
Then watches enzyme-feature values flow.
CalcMass steps outside the training set,
While c_pos follows the value it gets.
Tests count targets, decoys, and the trail,
The rabbit hops along the Percolator trail.

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

@timosachsenberg
timosachsenberg merged commit 78f108d into develop Oct 25, 2026
13 checks passed
@timosachsenberg
timosachsenberg deleted the claude/keen-franklin-awmnl1 branch October 25, 2026 15:18
timosachsenberg added a commit that referenced this pull request Oct 26, 2026
…otein N-terminal in enzN (#10730)

Since #10717 a protein terminus ('[') counts as a cleavage site in enzN/enzC. In a fully specific search the only
PSMs left with enzN = 0 are then the N-terminal peptides after initial-Met clipping (flank 'M', start 1). Target
proteins nearly all start with M, reversed decoy proteins rarely do, so enzN = 0 became a near target-only label:
Percolator learns it and accepts Met-clipped random matches with no decoys to pay for them (#10726).

The peptide after the initial Met is now protein N-terminal for enzN as well, as FragmentIndex (isProteinNTerminal_)
and PeptideIndexer (allow_nterm_protein_cleavage) already treat it. The Peptide column keeps the M.

Co-authored-by: Claude Opus 5.5 <[email protected]>
okohlbacher added a commit to okohlbacher/OpenMS that referenced this pull request Nov 3, 2026
… and develop; the coded matchIons overload skips series codes other than 0 and 1; precursorCharges 'search' mode tested

Review (CodeRabbit): the static rescoreWithPercolator() default-constructs PercolatorTraining, whose calc_mass_feature
defaulted to true while the tool parameter and OpenMS develop (OpenMS#10717) default to false, so library callers trained
with CalcMass as a feature. The coded FragmentIonLikelihoodModel::matchIons overload counted any series code other
than 0 as a suffix ion where HyperScore's codeSeries() rejects it; such ions are skipped now, as parseIonName() skips
unknown names. FragmentIndex_test covers precursorCharges() with search_outside_range true (recorded charges outside
the range are searched, an unknown charge gives the range). ProSEAlgorithm_test, FragmentIndex_test,
FragmentIonLikelihoodModel_test, HyperScore_test and the TOPP ProSE tests pass (247).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
okohlbacher added a commit that referenced this pull request Nov 4, 2026
…estriction with mono correction

The merge of develop (9695fe5) resolved two hunks to this branch's older version, because
#10740's last commit a5cbb87 was never in it: PercolatorTraining::calc_mass_feature went
back to true (library callers of rescoreWithPercolator() trained on CalcMass again, unlike
the tool and develop since #10717), and the coded matchIons overload lost the guard that
skips series codes other than 0 and 1. Both are develop's again, and two tests pin them:
PercolatorTraining{}.calc_mass_feature is false, and ions with a series code of 2 are not
scored.

restrictIndexToSpectra_() is false with precursor:mono_correction: the single-use index was
restricted to windows around the recorded precursors, which the correction then moved by up
to two 13C spacings, so a precursor moved from the second trace found no peptide when the
isotope range did not reach -2 (the library default).

The mono-correction TOPP test now requires at least one moved precursor; it accepted zero.

Review comments by @timosachsenberg on #10804.

Co-Authored-By: Claude Fable 5.1 <[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.

2 participants