Skip to content

[FIX] IsobaricWorkflow: explicitly prune empty consensus features before merge (#9823) - #9824

Merged
timosachsenberg merged 1 commit into
developfrom
fix/9823-isobaric-empty-features
Jul 29, 2026
Merged

timosachsenberg merged 1 commit into
developfrom
fix/9823-isobaric-empty-features

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9823.

Problem

IsobaricWorkflow pre-sizes its per-file ConsensusMap to one feature per peptide ID (cur_cmap.resize(pep_ids.size())) and only fills the features it can quantify. Peptide IDs it cannot quantify leave their slot as a default-constructed ConsensusFeature with zero FeatureHandles (rt/mz/charge = 0, empty sequence, no map association). Three branches do this:

  • an identified MS2 with no corresponding MS3 (routine for SPS-MS3 TMT; the ID is moved to unassigned),
  • an identified spectrum not found in the mzML,
  • a PSM with an empty spectrum reference.

What this PR changes

Adds an explicit prune of zero-FeatureHandle features from cur_cmap right before the per-file merge, with a LOG_INFO count. fillConsensusFeature_ always inserts ≥1 FeatureHandle per channel, so cf.empty() selects exactly the unfilled placeholders and no legitimately quantified feature is ever pruned. Stale comments (the "Remember to remove it later" note and the downstream filter comment) are corrected.

Why (and why there is no output change)

The empties were, until now, removed only implicitly — as a side effect of the downstream getIntensity() <= 0. filter, since a default feature has intensity 0.0f. That masking means the empties never actually reached the consensusXML/mzTab/QPX output, but the mechanism is fragile: it couples a structural invariant to an intensity proxy that also silently drops real identified features whose reporter channels are all zero. This PR makes the structural removal explicit, local, observable, and independent of the intensity filter, so the merged map is clean regardless of later filtering.

Verification

  • Full build passes (cmake --build ... --target IsobaricWorkflow, exit 0).
  • Reviewed for false-removal safety: ConsensusFeature::empty() == handles_.empty(); every valid isobaric method (itraq4plex…tmt35plex) has ≥4 channels, so quantified features always have ≥1 handle.
  • No output-diff regression test is added because the output is unchanged (the pre-existing intensity filter already removed the empties) and there is currently no enabled IsobaricWorkflow TOPP test harness (src/tests/topp/CMakeLists.txt has only a commented TODO).

Related latent issues found during review (NOT fixed here — follow-ups)

  • Gap A (edge cases): the empty-spec_ref and spectrum-not-found branches drop the placeholder without moving the peptide ID to unassigned, so those IDs are silently lost (only the missing-MS3 branch preserves them). Malformed/mismatched-input cases.
  • Gap B (routine): the getIntensity() <= 0. filter also silently drops real, identified features that have zero total reporter signal (scans with no detectable reporter ions), and their peptide IDs are not sent to unassigned either. Fixing B is a behavior change to the ID output and warrants a dedicated test.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Removed empty placeholder features from consensus results when corresponding spectra are missing from the input data.
    • Prevented invalid empty entries from being merged into global consensus maps.
    • Improved logging to indicate how many empty features were removed.

…ore merge (#9823)

IsobaricWorkflow pre-sizes its per-file ConsensusMap to one feature per
peptide ID (resize) and only fills the features it can quantify. Peptide
IDs it cannot quantify - an identified MS2 without a corresponding MS3, an
identified spectrum missing from the mzML, or one without a spectrum
reference - leave their slot as a default-constructed ConsensusFeature
with zero FeatureHandles (rt/mz/charge = 0, empty sequence, no map
association).

Until now these placeholders were removed only implicitly, as a side
effect of the downstream `getIntensity() <= 0.` filter (a default feature
has intensity 0). That is fragile: it couples a structural invariant to an
intensity proxy that also drops real, identified features whose reporter
channels are all zero. This adds an explicit prune of zero-FeatureHandle
features right before the per-file merge, with a LOG_INFO count, so the
merged map is structurally clean regardless of the intensity filter.
fillConsensusFeature_ always inserts at least one FeatureHandle per
channel, so no legitimately quantified feature is ever pruned.

No output change (the empties were already removed downstream); this makes
the removal explicit, local, observable, and independent of the intensity
proxy. The stale ":700" and ":802" comments are updated accordingly.

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

@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

🧹 Nitpick comments (1)
src/topp/IsobaricWorkflow.cpp (1)

736-737: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Format the lambda braces according to the C++ guidelines.

The new remove_if lambda places braces on the same line; repository guidance requires braces on their own aligned lines.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/topp/IsobaricWorkflow.cpp` around lines 736 - 737, Reformat the lambda
passed to remove_if in the cur_cmap cleanup so its opening and closing braces
appear on their own properly aligned lines, without changing the empty-feature
predicate or surrounding behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/topp/IsobaricWorkflow.cpp`:
- Around line 727-744: Add regression tests covering the pruning logic around
cur_cmap.erase/remove_if: missing MS3, missing mzML spectra, and empty spectrum
references must remove empty placeholders while retaining their peptide
identifications in unassigned IDs; populated consensus features with zero
reporter intensity must remain. Update the relevant test suite for
IsobaricWorkflow and assert both the resulting consensus features and preserved
unassigned identifications.
- Around line 727-744: Ensure peptide identifications from empty
spectrum-reference and missing-mzML paths are preserved in cmap’s unassigned IDs
before the empty ConsensusFeature pruning near cur_cmap.erase. Reuse the
existing copy, tagging, and critical-section handling used by the missing-MS3
path, updating the relevant workflow symbols rather than only removing the empty
slots.

---

Nitpick comments:
In `@src/topp/IsobaricWorkflow.cpp`:
- Around line 736-737: Reformat the lambda passed to remove_if in the cur_cmap
cleanup so its opening and closing braces appear on their own properly aligned
lines, without changing the empty-feature predicate or surrounding behavior.
🪄 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 Plus

Run ID: f59b5c7b-c614-4ddc-b93c-1ac03016d17b

📥 Commits

Reviewing files that changed from the base of the PR and between 23a557a and 5a64cd0.

📒 Files selected for processing (1)
  • src/topp/IsobaricWorkflow.cpp

Comment on lines +727 to +744
// cur_cmap was pre-sized to one ConsensusFeature per peptide ID (resize above) and only the
// features we could actually quantify were filled in - fillConsensusFeature_ always inserts at
// least one FeatureHandle per channel. Peptide IDs we could not quantify (an identified MS2 with
// no corresponding MS3, an identified spectrum missing from the mzML, or one without a spectrum
// reference) leave their slot as a default-constructed feature with zero FeatureHandles
// (rt/mz/charge = 0, empty sequence, no map association). Their identifications are preserved in
// the unassigned peptide IDs, so drop these empty placeholders here instead of merging them into
// the output map.
const Size before_prune = cur_cmap.size();
cur_cmap.erase(remove_if(cur_cmap.begin(), cur_cmap.end(),
[](const ConsensusFeature& cf) { return cf.empty(); }),
cur_cmap.end());
if (const Size pruned = before_prune - cur_cmap.size(); pruned > 0)
{
OPENMS_LOG_INFO << "Removed " << pruned << " unquantified consensus feature(s) without reporter "
<< "channels (their peptide identifications are kept in the unassigned IDs)." << std::endl;
}

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add regression tests for the pruning paths.

Cover missing MS3, missing mzML spectra, empty spectrum references, and populated features with zero reporter intensity. Assert that placeholders are removed while unassigned identifications remain available.

As per coding guidelines, src/**/*.cpp changes must add or update relevant tests.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/topp/IsobaricWorkflow.cpp` around lines 727 - 744, Add regression tests
covering the pruning logic around cur_cmap.erase/remove_if: missing MS3, missing
mzML spectra, and empty spectrum references must remove empty placeholders while
retaining their peptide identifications in unassigned IDs; populated consensus
features with zero reporter intensity must remain. Update the relevant test
suite for IsobaricWorkflow and assert both the resulting consensus features and
preserved unassigned identifications.

Source: Coding guidelines


🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Preserve all unquantified peptide IDs before pruning.

Only the missing-MS3 path appends IDs to unassigned_pep_ids; empty spectrum references and missing mzML spectra merely leave an empty slot. This erase therefore drops those identifications instead of preserving them in cmap’s unassigned IDs. Add the same copy/tag/critical-section handling for both paths, or narrow this comment and the PR contract.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/topp/IsobaricWorkflow.cpp` around lines 727 - 744, Ensure peptide
identifications from empty spectrum-reference and missing-mzML paths are
preserved in cmap’s unassigned IDs before the empty ConsensusFeature pruning
near cur_cmap.erase. Reuse the existing copy, tagging, and critical-section
handling used by the missing-MS3 path, updating the relevant workflow symbols
rather than only removing the empty slots.

@timosachsenberg
timosachsenberg merged commit 193b2e7 into develop Jul 29, 2026
40 checks passed
@timosachsenberg
timosachsenberg deleted the fix/9823-isobaric-empty-features branch July 29, 2026 20:21
timosachsenberg added a commit that referenced this pull request Jul 30, 2026
Audited recently merged develop PRs against CHANGELOG (last backfill
attempt was #9811/#9806, covering up to #9803). Four merged PRs since
then were missing entries: #9824 (IsobaricWorkflow empty-feature
pruning fix), #9523 (new CI build/release workflows), #9812 (pyOpenMS
docstring fixes) and #9798 (Bioconda nightly deploy fix, whose two
prior backfill attempts were closed unmerged). #9821 (internal
TODO-comment correction, no behavior/doc change) and #9805/#9803
(test-only / already covered by the #9792 write-up) were left out,
consistent with this repo's convention of not logging
test-infrastructure-only or already-documented changes.


Claude-Session: https://claude.ai/code/session_01WU21QuzvxLH5BuSxatVikX

Co-authored-by: Claude <[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.

IsobaricWorkflow leaves default-initialized ConsensusFeatures in its output when an identified MS2 has no MS3

1 participant