Repository navigation
[FIX] Handle empty ConsensusID searches and preserve run metadata - #10203
timosachsenberg merged 1 commit into
Conversation
Treat valid empty idXML searches as successful inputs, preserve their settings, and finalize per-spectrum metadata independently of peptide results. Guard unannotated maps and invalid input combinations. Require local builds and relevant tests before opening pull requests. Fixes OpenMS#1427
timosachsenberg
left a comment
There was a problem hiding this comment.
Review of df1f221. The core fix is sound and well-targeted — the per-file metadata finalization in particular is the right shape, and the new loop over mzml_to_new_run_idx is a strict superset of the old grouping_per_file keys, so no file loses settings it previously got.
I could not build or run ctest in this environment, so everything below is traced through the loader/writer sources rather than executed. Flagging that explicitly because it means I am not confirming the "all 48 tests passed" claim — only that the assertions are consistent with the code paths they exercise.
Verified as correct
- Enzyme guard (L495) — genuine crash fix.
DigestionEnzymeDB::getEnzyme("")throwsElementNotFound, andfinal_enzis""whenever every run reportsunknown_enzyme. Skipping the assignment leaves theSearchParametersdefault, which isProtease("unknown_enzyme", "")— so it really does preserve "unknown" rather than silently inventing an enzyme. - Charge guard (L513) — genuine.
min_chg/max_chgstart at10000/-10000andgetChargeRange()returns{0,0}for an emptychargesstring, so the old code emitted the sentinelcharges="10000--10000". unique_ptrconversion — fixes a real leak. The pre-existing!pep.hasRT()early return already skippeddelete consensus, and the two newreturn INCOMPATIBLE_INPUT_DATApaths would have added two more.prot_ids.size() < 2plus the addedreturns — bothOPENMS_LOG_FATAL_ERRORbranches previously logged and then kept executing. Clean exit code 11 is a real improvement.- Round-trip fixtures — the whitelist-free FuzzyDiff comparisons are sound:
IdXMLFile.cpp:107-113emits byte-identical stylesheet/version/schema lines to what the fixtures carry,FeatureXMLHandleremits no stylesheet line, and ConsensusID never callsaddDataProcessing_, so no extra block appears in the output. count_emptyassertions —n_other_ids = (count_empty_ ? number_of_runs_ : ids.size()) - 1yields exactly support1.0vs0.0as asserted. Note theFORBIDDEN=<PeptideIdentificationcheck holds in both modes for different reasons: RT/mz filters hit-less IDs at L879, per-spectrum does not and is saved only byIdXMLFile.cpp:299-303skipping them at write time. Worth knowing if that writer behaviour ever changes.if(count_empty)in the CMakeforeachcorrectly evaluates the"false"/"true"loop values as CMake boolean constants, and both helper scripts already exist on develop.
Findings
Three inline, ranked:
- L819 — missing space in the fatal error message; the PR fixes the identical defect in the adjacent message but not this one. One-character fix, suggestion attached.
- L576-581 — the
number_of_runs == 0guard replaces UB with silent data loss on maps that carry peptide IDs but no runs (reachable:FeatureXMLHandlerwarns and continues on a danglingidentification_run_ref). Also theclear()on this path is either a no-op or destructive, never useful. - L94 — the two modes now disagree on what empty input produces. Probably intended, but if so the
@noteat L82 ("All protein-level identification results will be lost") is now stale and should be corrected in the same PR.
Plus two non-blocking notes on AGENTS.md (repo-wide policy change bundled into a bug fix) and on the featureXML/consensusXML branches silently dropping extra -in files.
Generated by Claude Code
| @@ -801,14 +818,26 @@ class TOPPConsensusID : | |||
| { | |||
| OPENMS_LOG_FATAL_ERROR << "ConsensusID on idXML without the --per_spectrum flag, expects a single idXML file." | |||
There was a problem hiding this comment.
The adjacent string literals concatenate without a separating space, so this prints:
... expects a single idXML file.Please merge the files with IDMerger using its default settings.
This PR fixes exactly this defect in the sibling message 12 lines below (adding the leading space to " with multiple runs."), so this one looks like an oversight rather than a deliberate omission.
The new TOPP_ConsensusID_multiple_files_without_per_spectrum test only matches expects a single idXML file, so it will not catch the run-together text.
| OPENMS_LOG_FATAL_ERROR << "ConsensusID on idXML without the --per_spectrum flag, expects a single idXML file." | |
| OPENMS_LOG_FATAL_ERROR << "ConsensusID on idXML without the --per_spectrum flag, expects a single idXML file." | |
| " Please merge the files with IDMerger using its default settings." << std::endl; |
Generated by Claude Code
| if (number_of_runs == 0) | ||
| { | ||
| // Unannotated maps have no identification runs to combine. | ||
| input_map.getUnassignedPeptideIdentifications().clear(); | ||
| return; | ||
| } |
There was a problem hiding this comment.
This guard is right for the case the new tests cover, and it fixes real undefined behaviour — I checked both new fixtures (ConsensusID_no_ids_input.featureXML / .consensusXML) and neither carries any peptide identification, so before this change the loop below hit times_seen[id_mapping[...]] as an out-of-bounds write on an empty vector, followed by *max_element over an empty range.
Two things to consider:
1. A map can have peptide IDs and zero runs, and this path silently discards them.
FeatureXMLHandler.cpp:555-559 loads <PeptideIdentification identification_run_ref="PI_0"> even when no matching <IdentificationRun> exists — it only emits warning(LOAD, "Peptide identification without ProteinIdentification found") and leaves the identifier empty. On such input the guard now returns, the unassigned IDs are deleted outright, the assigned ones are dropped at write time by FeatureXMLHandler.cpp:962-965, and the tool exits EXECUTION_OK. Better than the previous UB, but the user gets a zero exit code and a file with every PSM gone.
Distinguishing the two cases would keep the fix and close the hole — no-op when the map carries no peptide identifications, and warn (or return INCOMPATIBLE_INPUT_DATA) when it does. A fixture with a dangling identification_run_ref would cover it.
2. The clear() has no justification on this path.
The identical call at line 610 is explained by the comment "remove outdated information (protein references will be broken)" — true there, because setProteinIdentifications_ has just replaced the runs. Nothing is replaced here, so this clear() is either a no-op (unannotated map) or data loss (case 1 above); it is never useful.
Generated by Claude Code
|
|
||
| @note Currently mzIdentML (mzid) is not directly supported as an input/output format of this tool. Convert mzid files to/from idXML using @ref TOPP_IDFileConverter if necessary. | ||
|
|
||
| @note An idXML file without peptide identifications is a valid empty search result. Without @p per_spectrum, its original identification runs and search settings are preserved. With @p per_spectrum, search settings are combined for each originating MS file even if no peptides were identified. Empty runs also remain available for the @p count_empty support calculation when combined with non-empty results. |
There was a problem hiding this comment.
Worth a deliberate decision before this merges: the two modes now disagree on what empty input produces.
Without per_spectrum, the original runs and their search parameters survive verbatim. With per_spectrum, empty input is still rewritten into ConsensusID for <file> runs (lines 778-785). So the shape of ConsensusID's output depends on whether the input happened to contain PSMs — a per-sample pipeline feeding IDMerger/FDR gets N original runs for samples that came out empty and one merged run for every other sample.
That may well be the intent (it is a fair reading of #1427 and the #8250 discussion), in which case this @note is the right place to record it. But if so, the @note at line 82 needs updating in the same PR:
@note Important: All protein-level identification results will be lost by applying ConsensusID.
That is no longer true on the empty RT/mz path, where the original ProteinHits are preserved by the early return at line 826. Line 82 is currently the only statement a user reads about protein-level output, and it now contradicts the new behaviour.
Generated by Claude Code
| **Before opening a pull request, always build the changes locally and run the relevant tests.** | ||
| Use an out-of-tree build and select the targets and tests affected by the change. Resolve | ||
| build or test failures before opening the PR; do not defer this validation to CI. |
There was a problem hiding this comment.
Non-blocking, process rather than code: this inverts a repository-wide agent policy inside a ConsensusID bug fix. The deleted line was a hard constraint —
- Build the project unless explicitly asked (extremely resource-intensive)
— under NEVER do these things, and it is replaced by a mandate to always build and test locally. The PR description does disclose it, but the CHANGELOG entry mentions only ConsensusID, so a reviewer approving the C++ fix approves the policy change without it appearing in the release notes, and the two cannot be reverted independently.
Suggest splitting it into its own PR, where it can be discussed on its merits by the people it actually governs.
Generated by Claude Code
| FileHandler().loadFeatures(in[0], map, {FileTypes::FEATUREXML}); | ||
|
|
||
| processFeatureOrConsensusMap_(map, consensus); | ||
| processFeatureOrConsensusMap_(map, consensus.get()); |
There was a problem hiding this comment.
Optional, and pre-existing rather than introduced here: this branch and the consensusXML one below load only in[0] and silently discard any further -in files — registerInputFileList_("in", ...) accepts the list and setValidFormats_ accepts featureXML, so nothing upstream rejects it. ConsensusID -in a.featureXML b.featureXML -out out.featureXML processes a.featureXML and returns EXECUTION_OK with no message about b.
Since this PR just added the symmetric INCOMPATIBLE_INPUT_DATA return for the idXML branch, the asymmetry is now conspicuous and cheap to close — an in.size() != 1 guard here and at line 943 would make "report invalid input combinations cleanly" hold for every input type, not just idXML. Reasonable to leave for a follow-up if you would rather keep this PR tight.
Generated by Claude Code
…10226) Adds CHANGELOG entries for merged PRs not yet reflected: FLASHDeconv negative mass/charge handling and TOPPAS file type detection (#9054), ConsensusID handling of empty idXML runs (#10203), the Applications install-component casing fix (#10199), and the implementing PR for the glycan/glycopeptide fragment generator (#10204). Also fills in the PR references on two existing Robustness entries (mzIdentML Measure definitions #10213, XIC chromatogram native IDs #10214) that were merged without one. Claude-Session: https://claude.ai/code/session_01CVWcsWWMa4DHbvKMhi9G8n Co-authored-by: Claude <[email protected]>
Valid idXML searches can contain no peptide identifications. ConsensusID currently rejects a single empty run, drops search settings when combining empty runs, and leaves per-spectrum runs without their MS-file metadata. Unannotated featureXML and consensusXML maps can also crash.
This follows the discussion on the closed PR #8250: empty means valid XML without peptide identifications, and search settings and
spectra_datamust be retained and tested.count_emptysettings, metadata, and invalid inputs with regression tests.AGENTS.mdto require a successful local build and relevant tests before opening a PR.Local validation completed before opening this PR: Linux/GCC 13 Debug build of the OpenMS libraries, ConsensusID, FuzzyDiff, and the relevant class-test executables; the final ConsensusID source was recompiled and linked with the CMake-generated commands. All 48 selected CTest tests passed, including the existing ConsensusID tests and the clustering/consensus class tests. All eight new fixtures and the generated outputs validated against the OpenMS XML schemas. Additional XML checks verified that merged search settings belong to the correct MS file.
Adversarial review found and fixed the missing-enzyme lookup and sentinel-charge-range cases. A baseline binary built from unmodified
developreproduced the single-empty-run failure, metadata loss, and both unannotated-map crashes; the updated binary passed the same cases.Closes #1427.