Skip to content

[FIX] ConsensusMapMergerAlgorithm: throw instead of segfault when there are no ID runs to merge - #10618

Merged
timosachsenberg merged 1 commit into
developfrom
fix/mergeallidruns-empty-idruns
Oct 18, 2026
Merged

timosachsenberg merged 1 commit into
developfrom
fix/mergeallidruns-empty-idruns

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

ConsensusMapMergerAlgorithm::mergeAllIDRuns() returned early only when there was exactly one protein identification run. With zero runs it fell through to getProteinIdentifications()[0], where it reads the search settings for the merged run, and read past the end of the empty vector. ProteomicsLFQ, ProteinInference, Epifany and MS1LabeledWorkflow all call it before protein inference, so such a ConsensusMap made them segfault with no hint at the cause.

That is how ProteomicsLFQ crashed on FAIMS data while FeatureOverlapFilter::mergeFAIMSFeatures still dropped the runs: exit 139 right after "Size of consensus fraction". #10001 fixed the cause; the crash was reported downstream as bigbio/quantms#741, where it still occurs with the 2026.07.02 container.

This PR makes the function throw Exception::MissingInformation instead, the same way BayesianProteinInferenceAlgorithm::inferPosteriorProbabilities already does for this condition. The TOPP tools then exit through TOPPBase's handler with Error: Unexpected internal error (The ConsensusMap has no protein identification runs to merge. ...) and UNKNOWN_ERROR, not a segfault. Behaviour changes only for input that crashed before, so no previously working input is affected.

Changes:

  • ConsensusMapMergerAlgorithm.cpp: guard against an empty run list before the size() == 1 early return.
  • ConsensusMapMergerAlgorithm.h: document the new @throws case.
  • ConsensusMapMergerAlgorithm_test.cpp: new section mergeAllIDRuns (no IdentificationRuns), a ConsensusMap with a PSM whose run is missing.
  • CHANGELOG: one FIX entry.

Verification (local, Release build, GCC 13)

ConsensusMapMergerAlgorithm_test
develop's ConsensusMapMergerAlgorithm.cpp (control) SIGSEGV (exit 139) in the new section
this PR all 4 sections pass (ctest -R ConsensusMapMergerAlgorithm_test)

TOPP tests were not built locally.

Found along the way, not changed here

The existing section mergeProteinsAcrossFractionsAndReplicates asserts the order of the merged runs' file lists (BSA1_F1 before BSA1_F2). ConsensusXMLHandler gives each loaded run the identifier <engine>_<date>_<UniqueIdGenerator id>, and mergeProteinIDRuns orders by that identifier (std::map). Runs with the same date, as in BSA.consensusXML, are therefore ordered by the random part. The test is deterministic only because of the fixed test seed and the number of ids drawn before it. A first version of the new section loaded BSA.consensusXML too, and that alone swapped F1/F2 in the later section. The new section therefore builds its map by hand and draws no ids. In production, with a time-based seed, this means the file order of the merged run can differ between executions for runs with equal dates (id_merge_index stays consistent).

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG 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.)

No signatures changed and mergeAllIDRuns is not bound in pyOpenMS, so no binding updates were needed. AUTHORS left for a maintainer to decide.


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Merging identification runs now reports missing information when a consensus map has no protein identification runs, instead of proceeding without available runs.

…re are no ID runs to merge

mergeAllIDRuns() returned early only for exactly one protein identification
run. With none, it fell through to getProteinIdentifications()[0] to take the
merged run's search settings from, reading past the end of the empty vector.
ProteomicsLFQ, ProteinInference, Epifany and MS1LabeledWorkflow call it before
protein inference, so such a ConsensusMap made them segfault without any hint
at the cause. That is how ProteomicsLFQ crashed on FAIMS data while
FeatureOverlapFilter::mergeFAIMSFeatures still dropped the runs (fixed in
#10001; reported downstream as bigbio/quantms#741).

Throw Exception::MissingInformation instead, as
BayesianProteinInferenceAlgorithm::inferPosteriorProbabilities already does
for the same condition, so the TOPP tools exit with an error message.

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

coderabbitai Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8bc30a9c-e460-4527-84d7-948a6377c827
📥 Commits

Reviewing files that changed from the base of the PR and between bfdbe62 and 94289f0.

📒 Files selected for processing: 4
  • CHANGELOG
  • src/openms/include/OpenMS/ANALYSIS/ID/ConsensusMapMergerAlgorithm.h
  • src/openms/source/ANALYSIS/ID/ConsensusMapMergerAlgorithm.cpp
  • src/tests/class_tests/openms/source/ConsensusMapMergerAlgorithm_test.cpp

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

📝 Walkthrough

mergeAllIDRuns now throws Exception::MissingInformation when a ConsensusMap has no protein identification runs. The exception documentation, test coverage, and changelog describe this case.

Changes: Missing identification runs

Layer / File(s) Summary
Reject empty run lists
src/openms/include/OpenMS/ANALYSIS/ID/ConsensusMapMergerAlgorithm.h, src/openms/source/ANALYSIS/ID/ConsensusMapMergerAlgorithm.cpp, src/tests/class_tests/openms/source/ConsensusMapMergerAlgorithm_test.cpp, CHANGELOG
mergeAllIDRuns throws Exception::MissingInformation when no protein identification runs are available. The test checks this case, and the documentation and changelog describe the exception.

Suggested reviewers: cbielow

Priority: ➖ Normal

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 94289

The empty-run case now produces an explicit error instead of an invalid access, and the added test covers that behavior. No merge-blocking risk is apparent.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 3 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: throwing an exception instead of segfaulting when no identification runs are available.
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: Docstring Coverage

Explanation

Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 3 files. (1 skipped: 1 unsupported.)

Resolution

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

  • Fix all pre-merge checks with AI
✨ 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 run list with care,
No protein runs? An exception is there.
The test confirms what the method will do,
The changelog records the behavior, too.
Then hops away through a field of dew.

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

@timosachsenberg timosachsenberg left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed 94289f04 for substantive regressions. No new actionable findings. The empty-run guard executes before both first-run dereferences, preserves the existing single-run fast path, and has a targeted exception regression test. Build and Test and the pyOpenMS wheel workflow passed on this head. Review was static; I did not build locally.

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

Correct

@timosachsenberg
timosachsenberg merged commit c981105 into develop Oct 18, 2026
33 checks passed
@timosachsenberg
timosachsenberg deleted the fix/mergeallidruns-empty-idruns branch October 18, 2026 05:51
timosachsenberg pushed a commit that referenced this pull request Oct 19, 2026
…#10301, #10611, #10606, #10608, #10609, #10617, #10610, #10578 ProSE Percolator rescoring, #10628)

Only CHANGELOG conflicted; both entries are kept. Develop's changes to FalseDiscoveryRate,
IDScoreGetterSetter, ConsensusMapMergerAlgorithm, FileInfo and ProSE work on the established
classes, which this branch keeps as they are.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B51nRFoHvZuVXD7cT8XZav
timosachsenberg pushed a commit that referenced this pull request Oct 19, 2026
#10612, #10301, #10578 ProSE, #10628)

Develop's changes to the map-level identification code are ported to identification data:

- FalseDiscoveryRate::applyBasicPeptideLevel(ConsensusMap&) (#10617): in the scope, an identification
  keeps its best match and the matches tied with it whose peptide has an FDR; the others are removed
  (they would keep their search score under the FDR score type). Without decoys it keeps only targets,
  and nothing if its best match is not a target, as before. The best match is the first of the best
  score, as develop's sort makes it; q-values on a map were already lower-is-better (the FDR score
  definition). Develop's two test sections are rewritten for identification data.
- ConsensusMapMergerAlgorithm::mergeAllIDRuns() (#10618) throws Exception::MissingInformation for a
  map without runs. Identification data has no identification without its run, so the test uses a
  map without identifications.
- FileInfo (#10612) counts the occurrences per map id on the linked identifications (auto-merged).
- IsobaricWorkflow_hyperscore_peptide_out.consensusXML (#10617): one identification whose best match
  is a decoy loses its matches, as on develop; develop leaves it the score type of the search
  (hyperscore, higher is better), identification data the score type of its run (peptide q-value).
  Features, matches and values are the same as develop's.
- FeatureFinderIdentificationAlgorithm_test (#10628): the peptide identifications of the new section
  have a score type and scores, which the conversion to identification data needs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B51nRFoHvZuVXD7cT8XZav
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