Skip to content

[FIX] ANALYSIS/ID: signal unknown target_decoy; NeighborSeq owns its peptides (#9488 ANID-10, ANID-34) - #9613

Merged
timosachsenberg merged 6 commits into
OpenMS:developfrom
timosachsenberg:fix/9488-analysis-id-targetdecoy
Jul 16, 2026
Merged

timosachsenberg merged 6 commits into
OpenMS:developfrom
timosachsenberg:fix/9488-analysis-id-targetdecoy

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Part of #9488 (POLS high-severity checklist — ANALYSIS/ID).

[ANID-10] IDBoostGraph — missing target_decoy silently treated as decoy

Six sites used getMetaValue("target_decoy").toString()[0] == 't'. When the key is absent, toString() is "" and ""[0] is '\0', so a hit with unknown target/decoy status was silently classified as a decoy (score 0) instead of being flagged.

Fix: use the existing getTargetDecoyType() API and throw Exception::MissingInformation on UNKNOWN — the same contract FalseDiscoveryRate already enforces. The four .cpp sites share a small isTargetProteinOrThrow_() helper; the two header visitor overloads inline the check.

[ANID-34] NeighborSeq — rvalue-ref ctor stored a dangling const-reference

The constructor takes std::vector<AASequence>&& (promising ownership) but the member was const std::vector<AASequence>&, so std::move(...) merely aliased the argument; passing a temporary (which && invites) dangled immediately and every later call was UB.

Fix: make the member an owning std::vector<AASequence>. The init-list std::move(...) now genuinely moves; no call site changes. Stale @note corrected.

ABI: ANID-10 none; ANID-34 changes a private member type (class layout) — ABI-breaking, but no source/signature change.
Tests: IDBoostGraph_test — getProteinScores_ throws on missing target_decoy and labels targets correctly; NeighborSeq_test — construct-from-temporary is safe and correct.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Breaking Changes

    • NeighborSeq now owns the peptide data passed in, preventing issues when constructed from temporaries, but it changes the class’s behavior for C++ consumers.
  • Bug Fixes

    • Protein target/decoy handling is now stricter: missing or unknown target/decoy annotations are detected and reported as errors instead of being silently treated as decoys.
  • Tests

    • Added coverage to ensure the new target/decoy validation behavior and NeighborSeq ownership semantics.

…peptides (OpenMS#9488 ANID-10, ANID-34)

Part of OpenMS#9488 (POLS high-severity checklist — **ANALYSIS/ID**).

### [ANID-10] `IDBoostGraph` — missing `target_decoy` silently treated as decoy
Six sites used `getMetaValue("target_decoy").toString()[0] == 't'`. When the key is absent, `toString()` is `""` and `""[0]` is `'\0'`, so a hit with **unknown** target/decoy status was silently classified as a **decoy** (score 0) instead of being flagged.

**Fix:** use the existing `getTargetDecoyType()` API and throw `Exception::MissingInformation` on `UNKNOWN` — the same contract `FalseDiscoveryRate` already enforces. The four `.cpp` sites share a small `isTargetProteinOrThrow_()` helper; the two header visitor overloads inline the check.

### [ANID-34] `NeighborSeq` — rvalue-ref ctor stored a dangling const-reference
The constructor takes `std::vector<AASequence>&&` (promising ownership) but the member was `const std::vector<AASequence>&`, so `std::move(...)` merely aliased the argument; passing a temporary (which `&&` invites) dangled immediately and every later call was UB.

**Fix:** make the member an owning `std::vector<AASequence>`. The init-list `std::move(...)` now genuinely moves; no call site changes. Stale `@note` corrected.

**ABI:** ANID-10 none; ANID-34 changes a private member type (class layout) — **ABI-breaking**, but no source/signature change.
**Tests:** `IDBoostGraph_test` — `getProteinScores_` throws on missing `target_decoy` and labels targets correctly; `NeighborSeq_test` — construct-from-temporary is safe and correct.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9abf534b-d09f-4aa5-af2d-e9acdbdf442d

📥 Commits

Reviewing files that changed from the base of the PR and between 4d81036 and 82413d2.

📒 Files selected for processing (3)
  • CHANGELOG
  • src/openms/include/OpenMS/ANALYSIS/ID/IDBoostGraph.h
  • src/openms/source/ANALYSIS/ID/IDBoostGraph.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/openms/include/OpenMS/ANALYSIS/ID/IDBoostGraph.h

📝 Walkthrough

Walkthrough

IDBoostGraph now uses typed target/decoy annotations and throws on unknown protein or peptide status. NeighborSeq now owns its moved peptide vector, with tests covering temporary-vector construction and missing annotation handling.

Changes

IDBoostGraph: Strongly-Typed Target/Decoy Classification

Layer / File(s) Summary
Enum-based hit classification
src/openms/include/OpenMS/ANALYSIS/ID/IDBoostGraph.h
Uses getTargetDecoyType() for peptide and protein hits and throws Exception::MissingInformation for UNKNOWN status.
Protein validation and scoring integration
src/openms/source/ANALYSIS/ID/IDBoostGraph.cpp
Validates annotations before parallel processing and uses typed classification for grouping, scores, and target fractions.
Missing annotation test coverage
src/tests/class_tests/openms/source/IDBoostGraph_test.cpp
Verifies target labels and the exception raised when annotations are removed.
Release note
CHANGELOG
Records the breaking behavior change for missing target/decoy annotations.

NeighborSeq: Owned Vector Lifetime Fix

Layer / File(s) Summary
Owned peptide vector and lifetime validation
src/openms/include/OpenMS/ANALYSIS/ID/NeighborSeq.h, src/tests/class_tests/openms/source/NeighborSeq_test.cpp
Changes peptide storage to an owned vector, updates move-semantics documentation, and tests construction from a temporary vector.

Sequence Diagram(s)

sequenceDiagram
  participant Resolver as resolveGraphPeptideCentric
  participant Validator as validateTargetDecoyAnnotations_
  participant Protein as ProteinHit
  participant Scoring as Protein scoring
  Resolver->>Validator: validate protein annotations
  Validator->>Protein: getTargetDecoyType()
  Validator-->>Resolver: continue or throw MissingInformation
  Resolver->>Scoring: compute groups, scores, and fractions
Loading

Suggested reviewers: jpfeuffer, cbielow

Poem

A rabbit hops through graphs so bright,
Typed enums guide the path just right.
Unknown marks now raise a sound,
Peptides safely stay homebound.
No dangling hops, no hidden fright—
Clean targets gleam in morning light!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 reflects the two main changes: handling unknown target_decoy values and making NeighborSeq own its peptides.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown
Contributor Author

Adversarial review result: no blocking behavioral issue found in this pass.

Required source cleanup before merge: the added Doxygen/test comments include tracker references. Please remove those references from source comments and keep the comments focused on the missing target/decoy contract and owned-vector lifetime fix. I did not run the tests locally.

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

@jpfeuffer false positive?

@jpfeuffer

Copy link
Copy Markdown
Contributor

yes in the sense that an absent metavalue throws in OpenMS

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

Actually the single-arg getMetaValue(const std::string&) doesn't throw on a missing key — it returns DataValue::EMPTY (MetaInfoInterface.cpp:124 → MetaInfo::getValue returns the default, and MetaInfoRegistry::getIndex returns UInt(-1) for unknown names). So for these six sites the chain really is absent → "" → ""[0] == '\0' → != 't' → treated as decoy, silently. None of the four getMetaValue overloads throw.

If target_decoy is meant to always be present here (set upstream by PeptideIndexer/FDR), then throwing on UNKNOWN — which is what this PR does via getTargetDecoyType() — is exactly the right contract: it turns a silent misclassification into a hard error. So the finding stands; happy to keep the fix as-is.

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

To clarify the "throws" point: it's the DataValue type-conversion operators that throw on an absent (EMPTY) value, not getMetaValue itself. operator double()/float()/int()/… all throw Exception::ConversionError on EMPTY_VALUE (DataValue.cpp:451-555), and operator std::string() throws on anything that isn't STRING_VALUE (DataValue.cpp:626-636). So the implicit-conversion idiom — e.g. double td = hit.getMetaValue("target_decoy"); — would indeed throw on a missing key, which matches the intuition.

The catch is that these six sites don't convert — they call .toString(), which is the one accessor that explicitly does not throw on EMPTY (case EMPTY_VALUE: break; → returns "", DataValue.cpp:707-708). So they take the single non-throwing path: EMPTY → "" → ""[0] == '\0' → != 't' → decoy, silently. Switching to getTargetDecoyType() + throw on UNKNOWN restores the throwing contract these sites were accidentally bypassing.

@jpfeuffer

Copy link
Copy Markdown
Contributor

Interesting. Not a great intuitive API. But then this PR is obviously valid.

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

yeah the API is not great. I will look into a better one for the future

Keep the comments focused on the missing target/decoy contract and the
owned-vector lifetime fix.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Validate protein target/decoy annotations before parallel graph resolution so exceptions remain catchable. Make the NeighborSeq ownership regression deterministic and document the accepted ABI break.
@timosachsenberg
timosachsenberg merged commit f48cc2d into OpenMS:develop Jul 16, 2026
38 checks passed
timosachsenberg added a commit that referenced this pull request Jul 17, 2026
* docs(changelog): add entries for #9492, #9752

Backfills two CHANGELOG entries for recently merged PRs that landed
without their own entry:
- #9752: new BUILD_TOPP_TOOLS / INSTALL_OPENMS_EXAMPLES CMake options
  enabling a core-only OpenMS SDK build
- #9492: null-dereference guards in TargetedExperiment::get*ByRef and
  ReactionMonitoringTransition::getPrediction

All other PRs merged since the last CHANGELOG update (#9613, #9750,
#9738) already carried their own entries; #9572 is test-only and
follows the existing convention of not adding a changelog entry for
test-only PRs in this series.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QcFv1tmBLzroCNJFjoqhZt

* Update CHANGELOG

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
jcharkow pushed a commit to jcharkow/OpenMS that referenced this pull request Aug 12, 2026
…S#9753)

* docs(changelog): add entries for OpenMS#9492, OpenMS#9752

Backfills two CHANGELOG entries for recently merged PRs that landed
without their own entry:
- OpenMS#9752: new BUILD_TOPP_TOOLS / INSTALL_OPENMS_EXAMPLES CMake options
  enabling a core-only OpenMS SDK build
- OpenMS#9492: null-dereference guards in TargetedExperiment::get*ByRef and
  ReactionMonitoringTransition::getPrediction

All other PRs merged since the last CHANGELOG update (OpenMS#9613, OpenMS#9750,
OpenMS#9738) already carried their own entries; OpenMS#9572 is test-only and
follows the existing convention of not adding a changelog entry for
test-only PRs in this series.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QcFv1tmBLzroCNJFjoqhZt

* Update CHANGELOG

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
jcharkow added a commit to jcharkow/OpenMS that referenced this pull request Oct 9, 2026
…S#9753)

* docs(changelog): add entries for OpenMS#9492, OpenMS#9752

Backfills two CHANGELOG entries for recently merged PRs that landed
without their own entry:
- OpenMS#9752: new BUILD_TOPP_TOOLS / INSTALL_OPENMS_EXAMPLES CMake options
  enabling a core-only OpenMS SDK build
- OpenMS#9492: null-dereference guards in TargetedExperiment::get*ByRef and
  ReactionMonitoringTransition::getPrediction

All other PRs merged since the last CHANGELOG update (OpenMS#9613, OpenMS#9750,
follows the existing convention of not adding a changelog entry for
test-only PRs in this series.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QcFv1tmBLzroCNJFjoqhZt

* Update CHANGELOG

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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