Repository navigation
[FIX] IsobaricWorkflow: explicitly prune empty consensus features before merge (#9823) - #9824
Conversation
…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]>
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/topp/IsobaricWorkflow.cpp (1)
736-737: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFormat the lambda braces according to the C++ guidelines.
The new
remove_iflambda 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
📒 Files selected for processing (1)
src/topp/IsobaricWorkflow.cpp
| // 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; | ||
| } | ||
|
|
There was a problem hiding this comment.
📐 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.
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]>
Fixes #9823.
Problem
IsobaricWorkflowpre-sizes its per-fileConsensusMapto 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-constructedConsensusFeaturewith zeroFeatureHandles (rt/mz/charge = 0, empty sequence, no map association). Three branches do this:What this PR changes
Adds an explicit prune of zero-
FeatureHandlefeatures fromcur_cmapright before the per-file merge, with aLOG_INFOcount.fillConsensusFeature_always inserts ≥1FeatureHandleper channel, socf.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 intensity0.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
cmake --build ... --target IsobaricWorkflow, exit 0).ConsensusFeature::empty() == handles_.empty(); every valid isobaric method (itraq4plex…tmt35plex) has ≥4 channels, so quantified features always have ≥1 handle.IsobaricWorkflowTOPP test harness (src/tests/topp/CMakeLists.txthas only a commented TODO).Related latent issues found during review (NOT fixed here — follow-ups)
spec_refand 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.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