Repository navigation
[FIX,TOPP,ID] ProteomicsLFQ, IsobaricWorkflow: reduce identifications to one per spectrum (#9871) - #9892
Conversation
… to one per spectrum Adds IDConflictResolverAlgorithm::reduceToOnePerSpectrum(), which keeps the best-scoring identification of each (spectrum_reference, top-hit peptidoform, top-hit charge) group and removes the rest, reporting what it did. Quantification tools measure one value per such triple. Input carrying several identifications of one triple - two search engines concatenated rather than combined - leaves it undecided which owns the measurement, and keeping all of them counts one measurement several times. Picking the better of two scores that something upstream already assigned is a tie-break, not a scoring decision; combining scores from different engines remains ConsensusIDAlgorithm's job and is deliberately not done here. Details that matter: - Identifications are keyed on the top hit AS STORED. Hits are never re-sorted, so the key matches what the exporters and quantifiers read (QPXFile writes hits[0] unsorted, as does ConsensusMapArrowExport::topHitPsmIdentity). - Group membership uses the ordering the range was sorted with, not operator==. AASequence's two operators disagree on what identifies a residue - operator< compares the one-letter code, operator== the interned Residue* - so a pair operator< calls equivalent could otherwise be split apart and its duplicate silently missed. - A group whose members disagree on isHigherScoreBetter() has no defined "best" and is left intact rather than reduced by a coin flip. - Ties break on input position, so the survivor is deterministic; survivors keep their original relative order. - Identifications without a spectrum reference, and those without hits, are left untouched. No caller yet, so no behaviour changes with this commit. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01S7QNzj4dhRnX5htcHZFmDm
…er spectrum (#9871) Both tools now reduce their input to one identification per (spectrum, peptidoform, charge) at load, and document the precondition on -ids / -in_id and in their tool docs. The shape being handled is a search-engine merge that concatenates rather than combines. OpenMS produces it in two places: PSMFeatureExtractor -multiple_search_engines -concat, whose documented purpose is "naive merging ... instead of merging on scan level" and which assigns every engine's identifications one run identifier; and PercolatorAdapter at its default -score:fdr 1.0, which retains the PSMs target-decoy competition rejected, marked as not identified. Both are resolved but not reduced - something upstream ranked them, it just did not delete the losers - which is why this reduces rather than refuses. Measured effect of a single duplicated identification: - IsobaricWorkflow: 7 consensus features instead of 6, the extra one bit-identical. Because it builds one consensus feature per identification and all identifications of one spectrum read the same MS2/MS3 scan, the same reporter intensities enter the quantification twice. Protein abundance +37% (PROTA channel 1: 2.176e04 vs 1.584e04) and the PSM q-value column moves from 0.1667 to 0.2. The peptide row is duplicated with unchanged values, so the damage lands at protein level rather than as a doubled peptide abundance. - ProteomicsLFQ: 116 mzTab PSM rows against 115, plus a consensusXML difference. MSstats and Triqler output is unaffected. Placement in ProteomicsLFQ is deliberately after the missing-spectrum-reference repair (SpectrumMetaDataLookup::addMissingSpectrumReferences): an identification with no reference cannot be keyed at all, so reducing earlier would silently skip exactly the files whose references had to be reannotated. The new fixture demonstrates this - BSA1_F1.idXML carries no spectrum references at all. Both TOPP tests diff against the EXISTING un-duplicated references rather than new ones, since "the duplicate changed no number" is the assertion; they also require the reduction to report, because an identical output could otherwise mean it never ran. Verified by reverting each reduction in turn and confirming the tests go red for the right reason. ctest: 95/95 TOPP_ProteomicsLFQ + TOPP_IsobaricWorkflow pass, no reference file churn. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01S7QNzj4dhRnX5htcHZFmDm
📝 WalkthroughWalkthroughChangesIdentification deduplication
Filename validation utilities
Sequence Diagram(s)sequenceDiagram
participant IsobaricWorkflow
participant ProteomicsLFQ
participant IDConflictResolverAlgorithm
participant PeptideIdentificationList
IsobaricWorkflow->>IDConflictResolverAlgorithm: reduceToOnePerSpectrum(ids)
IDConflictResolverAlgorithm->>PeptideIdentificationList: remove duplicate identifications
IDConflictResolverAlgorithm-->>IsobaricWorkflow: return reduction diagnostics
ProteomicsLFQ->>IDConflictResolverAlgorithm: reduceToOnePerSpectrum(repaired ids)
IDConflictResolverAlgorithm-->>ProteomicsLFQ: return reduction diagnostics
Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
src/tests/class_tests/openms/source/IDConflictResolverAlgorithm_test.cpp (1)
211-327: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a modified-peptidoform case.
Every sequence in this section is unmodified, so the section cannot show how the grouping treats modifications. Add a case with two identifications of one spectrum and charge, one carrying a modification, and assert that both survive.
💚 Proposed additional case
+ // Two peptidoforms of one backbone are two measurements and must both survive. + { + PeptideIdentificationList ids; + ids.push_back(makePepID_(ref, "PEPTIDEK", 2, 0.1)); + ids.push_back(makePepID_(ref, "PEPT(Phospho)IDEK", 2, 0.2)); + auto report = IDConflictResolverAlgorithm::reduceToOnePerSpectrum(ids); + TEST_EQUAL(report.removed, 0) + TEST_EQUAL(ids.size(), 2) + }🤖 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/tests/class_tests/openms/source/IDConflictResolverAlgorithm_test.cpp` around lines 211 - 327, Add a test case within reduceToOnePerSpectrum using two identifications sharing the same spectrum and charge but differing by a peptide modification, and assert both remain in ids with report.removed equal to zero. Use the existing modified-peptidoform construction conventions and verify the grouping distinguishes the modified and unmodified forms.src/topp/IsobaricWorkflow.cpp (1)
639-672: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winExtract the shared "reduce and log" pattern instead of duplicating it in two TOPP tools. Both sites call
IDConflictResolverAlgorithm::reduceToOnePerSpectrumand then log each field ofUnresolvedIdentificationswith near-identical branching. The duplication has already caused the two copies to diverge: one reports one fewer diagnostic field than the other. ProteomicsLFQ already uses a sharedDDAWorkflowCommonsclass for other cross-tool logic (e.g.mapMzML2Ids,calculateSeeds), which is a natural place for this helper.
src/topp/IsobaricWorkflow.cpp#L639-L672: extract this block into a shared helper (or add the missingmultiply_identified_spectralog branch to match ProteomicsLFQ) so the two tools cannot drift again.src/topp/ProteomicsLFQ.cpp#L953-L998: replacereduceToOnePerSpectrum_with a call to the same shared helper used by IsobaricWorkflow.🤖 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 639 - 672, The duplicated identification-reduction and diagnostic logging must use one shared implementation. In src/topp/IsobaricWorkflow.cpp:639-672, move the reduceToOnePerSpectrum reporting into a shared DDAWorkflowCommons helper, including every UnresolvedIdentifications diagnostic such as multiply_identified_spectra; in src/topp/ProteomicsLFQ.cpp:953-998, replace reduceToOnePerSpectrum_ with that same helper and remove the duplicate local logic.
🤖 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 `@CHANGELOG`:
- Around line 333-339: Move the new IsobaricWorkflow bullet from the heading
near line 333 into the existing IsobaricWorkflow section later in the Changes
section, preserving the bullet text and removing the duplicate heading. Keep the
entry alongside the existing IsobaricWorkflow bullets, matching the
single-section pattern used by ProteomicsLFQ.
In `@src/openms/include/OpenMS/ANALYSIS/ID/IDConflictResolverAlgorithm.h`:
- Around line 125-145: The new public API is missing from pyOpenMS. Update the
analysis bindings in bind_analysis.cpp and the corresponding pyOpenMS stub/.pxd
declarations to expose IDConflictResolverAlgorithm::UnresolvedIdentifications
and its static reduceToOnePerSpectrum(PeptideIdentificationList&) method,
preserving the C++ return type and argument behavior.
In `@src/openms/source/ANALYSIS/ID/IDConflictResolverAlgorithm.cpp`:
- Around line 134-140: Update the inconsistent-group branch in
IDConflictResolverAlgorithm to increment surviving_here once per unresolved
group rather than by group_end - group. Preserve the existing group advancement
and continue behavior, matching the resolved branch’s group-level counting so
multiply_identified_spectra is not inflated.
---
Nitpick comments:
In `@src/tests/class_tests/openms/source/IDConflictResolverAlgorithm_test.cpp`:
- Around line 211-327: Add a test case within reduceToOnePerSpectrum using two
identifications sharing the same spectrum and charge but differing by a peptide
modification, and assert both remain in ids with report.removed equal to zero.
Use the existing modified-peptidoform construction conventions and verify the
grouping distinguishes the modified and unmodified forms.
In `@src/topp/IsobaricWorkflow.cpp`:
- Around line 639-672: The duplicated identification-reduction and diagnostic
logging must use one shared implementation. In
src/topp/IsobaricWorkflow.cpp:639-672, move the reduceToOnePerSpectrum reporting
into a shared DDAWorkflowCommons helper, including every
UnresolvedIdentifications diagnostic such as multiply_identified_spectra; in
src/topp/ProteomicsLFQ.cpp:953-998, replace reduceToOnePerSpectrum_ with that
same helper and remove the duplicate local logic.
🪄 Autofix
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: bb4dbed5-8f67-49be-a8d1-738e013d9079
📒 Files selected for processing (9)
CHANGELOGsrc/openms/include/OpenMS/ANALYSIS/ID/IDConflictResolverAlgorithm.hsrc/openms/source/ANALYSIS/ID/IDConflictResolverAlgorithm.cppsrc/tests/class_tests/openms/source/IDConflictResolverAlgorithm_test.cppsrc/tests/topp/CMakeLists.txtsrc/tests/topp/IsobaricWorkflow_duplicate_psm_input.idXMLsrc/tests/topp/ProteomicsLFQ_duplicate_psm_1.idXMLsrc/topp/IsobaricWorkflow.cppsrc/topp/ProteomicsLFQ.cpp
Three findings from the automated review of #9892, all valid: 1. reduceToOnePerSpectrum() reported an unresolvable group as a chimeric spectrum. A group whose members disagree on isHigherScoreBetter() is left intact, and every member was then added to the per-spectrum survivor count, pushing multiply_identified_spectra above 1. That counter is documented -- and logged by both tools -- as spectra "naming different peptidoforms", so a single repeated peptidoform with a direction disagreement produced a second, contradictory message. Counted once now, as the reduced branch already does. The class test gained the assertion that pins it; verified to fail before the change (got 1, expected 0). 2. IDConflictResolverAlgorithm is wrapped in pyOpenMS, so the new API is bound too: UnresolvedIdentifications (read-only fields) and the reduceToOnePerSpectrum static. Exercised from Python: a duplicate pair reduces to the better-scoring one and reports it. 3. CHANGELOG had two "IsobaricWorkflow:" headings under one "Changes:" section -- the new entry is merged into the pre-existing one, matching how the ProteomicsLFQ entry was added. ctest: 109/109 across TOPP_ProteomicsLFQ, TOPP_IsobaricWorkflow and IDConflictResolverAlgorithm. pyOpenMS builds clean. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01S7QNzj4dhRnX5htcHZFmDm
|
All three review findings were valid and are fixed in 0ac0faa. 1. Unresolved group reported as chimeric ( The class test gained 2. pyOpenMS wrapper — also correct; I'd missed that the class is already bound at 3. Duplicate CHANGELOG heading — correct, merged into the pre-existing One note on the committable suggestion for (1): it renders as ctest: 109/109 across |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/pyOpenMS/bindings/bind_analysis.cpp (2)
578-589: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the unresolved score-direction case.
The docstring says that the best identification is kept for each key. The native implementation leaves a duplicate group unchanged when its
isHigherScoreBetter()values disagree and incrementsinconsistent_score_direction. Document this exception and state that score ties retain the first input identification.Proposed documentation update
Identifications of one spectrum naming different peptidoforms are left alone, as are those without a spectrum reference or without hits. + Groups with conflicting `isHigherScoreBetter()` values are also left unchanged and counted in `inconsistent_score_direction`. + Score ties retain the first input identification.🤖 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/pyOpenMS/bindings/bind_analysis.cpp` around lines 578 - 589, Update the reduceToOnePerSpectrum docstring to document that duplicate groups with conflicting isHigherScoreBetter() values remain unchanged and are reported as inconsistent_score_direction. Also state that score ties retain the first input identification.
562-569: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd copy support for
UnresolvedIdentifications.This value type exposes only
nb::init<>. Add its copy constructor,__copy__, and__deepcopy__methods to match the surrounding pyOpenMS bindings. Otherwise Python callers cannot rely on standard copy behavior for the report returned byreduceToOnePerSpectrum.Proposed binding update
nb::class_<OpenMS::IDConflictResolverAlgorithm::UnresolvedIdentifications>( m, "UnresolvedIdentifications", "What IDConflictResolverAlgorithm.reduceToOnePerSpectrum did") .def(nb::init<>()) + .def(nb::init<const OpenMS::IDConflictResolverAlgorithm::UnresolvedIdentifications &>()) + .def("__copy__", [](const OpenMS::IDConflictResolverAlgorithm::UnresolvedIdentifications& self) { + return OpenMS::IDConflictResolverAlgorithm::UnresolvedIdentifications(self); + }) + .def("__deepcopy__", [](const OpenMS::IDConflictResolverAlgorithm::UnresolvedIdentifications& self, nb::dict) { + return OpenMS::IDConflictResolverAlgorithm::UnresolvedIdentifications(self); + }, "memo"_a) .def_ro("removed", &OpenMS::IDConflictResolverAlgorithm::UnresolvedIdentifications::removed)As per coding guidelines, pyOpenMS bindings must include default and copy constructors, plus
__copy__and__deepcopy__, when available.🤖 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/pyOpenMS/bindings/bind_analysis.cpp` around lines 562 - 569, Update the UnresolvedIdentifications binding to expose its copy constructor alongside nb::init<>, and add __copy__ and __deepcopy__ methods using the surrounding pyOpenMS binding conventions. Keep the existing read-only fields unchanged.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/openms/include/OpenMS/FORMAT/FileName.h`:
- Around line 31-43: Replace the line comments documenting public methods
stemName() and extension() with /** */ Doxygen blocks. Add `@brief`, `@param`[in]
file, and `@return` tags while preserving each method’s current behavior and
examples; do not alter the MatchingFileListsStatus enum documentation unless
needed for the same public API style.
In `@src/openms/source/FORMAT/FileName.cpp`:
- Around line 47-83: Replace the duplicate-dropping sl1_set and sl2_set
containers in the filename comparison logic with multiplicity-preserving
comparisons, such as std::multiset, so same_set is false when normalized names
have different counts and the result is SET_MISMATCH. Add a regression test
covering repeated normalized names such as ["a", "a", "b"] versus ["a", "b",
"b"], while preserving existing MATCH and ORDER_MISMATCH behavior.
---
Nitpick comments:
In `@src/pyOpenMS/bindings/bind_analysis.cpp`:
- Around line 578-589: Update the reduceToOnePerSpectrum docstring to document
that duplicate groups with conflicting isHigherScoreBetter() values remain
unchanged and are reported as inconsistent_score_direction. Also state that
score ties retain the first input identification.
- Around line 562-569: Update the UnresolvedIdentifications binding to expose
its copy constructor alongside nb::init<>, and add __copy__ and __deepcopy__
methods using the surrounding pyOpenMS binding conventions. Keep the existing
read-only fields unchanged.
🪄 Autofix
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: 77c6195b-21f9-4769-aa5e-33bc169895f9
📒 Files selected for processing (8)
CHANGELOGsrc/openms/extern/nlohmann_json/ lohmann-json:src/openms/include/OpenMS/FORMAT/FileName.hsrc/openms/source/ANALYSIS/ID/IDConflictResolverAlgorithm.cppsrc/openms/source/FORMAT/FileName.cppsrc/pyOpenMS/bindings/bind_analysis.cppsrc/tests/class_tests/openms/source/FileName_test.cppsrc/tests/class_tests/openms/source/IDConflictResolverAlgorithm_test.cpp
🚧 Files skipped from review as they are similar to previous changes (3)
- CHANGELOG
- src/tests/class_tests/openms/source/IDConflictResolverAlgorithm_test.cpp
- src/openms/source/ANALYSIS/ID/IDConflictResolverAlgorithm.cpp
| /// Returns the basename of @p file without its (known) extension, e.g. "/x/foo.mzML.gz" -> "foo". | ||
| static String stemName(const String& file); | ||
|
|
||
| /// Returns the (known) extension of @p file including the leading '.', or "" if it has none. | ||
| static String extension(const String& file); | ||
|
|
||
| /// Result of validateMatchingFileNames(). | ||
| enum class MatchingFileListsStatus | ||
| { | ||
| MATCH = 0, ///< Everything matches perfectly | ||
| ORDER_MISMATCH = 1, ///< Same set of files but in wrong order | ||
| SET_MISMATCH = 2 ///< Different sets of files (including size mismatch) | ||
| }; |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use block Doxygen for the new public API.
Lines 31-43 use line comments. The public methods also omit required @brief, @param[in], and @return tags. Replace these comments with /** */ Doxygen blocks.
Proposed documentation update
- /// Returns the basename of `@p` file without its (known) extension, e.g. "/x/foo.mzML.gz" -> "foo".
+ /**
+ `@brief` Return the basename without its known extension.
+ `@param`[in] file Input file name.
+ `@return` Basename without its extension.
+ */
static String stemName(const String& file);
- /// Returns the (known) extension of `@p` file including the leading '.', or "" if it has none.
+ /**
+ `@brief` Return the known extension, including the leading period.
+ `@param`[in] file Input file name.
+ `@return` The extension, or an empty string if no extension exists.
+ */
static String extension(const String& file);As per coding guidelines, Doxygen comments must use /** */ with @ tags, @brief is required, and parameter tags must specify direction.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /// Returns the basename of @p file without its (known) extension, e.g. "/x/foo.mzML.gz" -> "foo". | |
| static String stemName(const String& file); | |
| /// Returns the (known) extension of @p file including the leading '.', or "" if it has none. | |
| static String extension(const String& file); | |
| /// Result of validateMatchingFileNames(). | |
| enum class MatchingFileListsStatus | |
| { | |
| MATCH = 0, ///< Everything matches perfectly | |
| ORDER_MISMATCH = 1, ///< Same set of files but in wrong order | |
| SET_MISMATCH = 2 ///< Different sets of files (including size mismatch) | |
| }; | |
| /** | |
| `@brief` Return the basename without its known extension. | |
| `@param`[in] file Input file name. | |
| `@return` Basename without its extension. | |
| */ | |
| static String stemName(const String& file); | |
| /** | |
| `@brief` Return the known extension, including the leading period. | |
| `@param`[in] file Input file name. | |
| `@return` The extension, or an empty string if no extension exists. | |
| */ | |
| static String extension(const String& file); | |
| /// Result of validateMatchingFileNames(). | |
| enum class MatchingFileListsStatus | |
| { | |
| MATCH = 0, ///< Everything matches perfectly | |
| ORDER_MISMATCH = 1, ///< Same set of files but in wrong order | |
| SET_MISMATCH = 2 ///< Different sets of files (including size mismatch) | |
| }; |
🤖 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/openms/include/OpenMS/FORMAT/FileName.h` around lines 31 - 43, Replace
the line comments documenting public methods stemName() and extension() with /**
*/ Doxygen blocks. Add `@brief`, `@param`[in] file, and `@return` tags while
preserving each method’s current behavior and examples; do not alter the
MatchingFileListsStatus enum documentation unless needed for the same public API
style.
Source: Coding guidelines
| set<String> sl1_set; | ||
| set<String> sl2_set; | ||
| bool different_name_at_index = false; | ||
|
|
||
| // Process and compare each filename | ||
| for (size_t i = 0; i != sl1.size(); ++i) | ||
| { | ||
| String sl1_name = sl1[i]; | ||
| String sl2_name = sl2[i]; | ||
|
|
||
| if (basename) | ||
| { | ||
| sl1_name = File::basename(sl1_name); | ||
| sl2_name = File::basename(sl2_name); | ||
| } | ||
|
|
||
| if (ignore_extension) | ||
| { | ||
| sl1_name = FileHandler::stripExtension(sl1_name); | ||
| sl2_name = FileHandler::stripExtension(sl2_name); | ||
| } | ||
|
|
||
| sl1_set.insert(sl1_name); | ||
| sl2_set.insert(sl2_name); | ||
|
|
||
| if (sl1_name != sl2_name) | ||
| { | ||
| different_name_at_index = true; | ||
| } | ||
| } | ||
|
|
||
| const bool same_set = (sl1_set == sl2_set); | ||
|
|
||
| // Check if it's an order mismatch or complete mismatch | ||
| if (same_set) | ||
| { | ||
| return different_name_at_index ? MatchingFileListsStatus::ORDER_MISMATCH : MatchingFileListsStatus::MATCH; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Preserve duplicate file-name counts during comparison.
Line 47 and Line 48 use std::set, which removes duplicates. For ["a", "a", "b"] and ["a", "b", "b"], Line 78 reports equal sets and Line 83 returns ORDER_MISMATCH. The normalized lists have different multiplicities, so the result must be SET_MISMATCH.
Use std::multiset or per-name counts. Add a regression test with repeated normalized file names.
Proposed implementation update
- set<String> sl1_set;
- set<String> sl2_set;
+ multiset<String> sl1_set;
+ multiset<String> sl2_set;As per coding guidelines, add or update relevant tests for changes under src/**/*.cpp.
🤖 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/openms/source/FORMAT/FileName.cpp` around lines 47 - 83, Replace the
duplicate-dropping sl1_set and sl2_set containers in the filename comparison
logic with multiplicity-preserving comparisons, such as std::multiset, so
same_set is false when normalized names have different counts and the result is
SET_MISMATCH. Add a regression test covering repeated normalized names such as
["a", "a", "b"] versus ["a", "b", "b"], while preserving existing MATCH and
ORDER_MISMATCH behavior.
Source: Coding guidelines
Three findings from the automated review of #9892, all valid: 1. reduceToOnePerSpectrum() reported an unresolvable group as a chimeric spectrum. A group whose members disagree on isHigherScoreBetter() is left intact, and every member was then added to the per-spectrum survivor count, pushing multiply_identified_spectra above 1. That counter is documented -- and logged by both tools -- as spectra "naming different peptidoforms", so a single repeated peptidoform with a direction disagreement produced a second, contradictory message. Counted once now, as the reduced branch already does. The class test gained the assertion that pins it; verified to fail before the change (got 1, expected 0). 2. IDConflictResolverAlgorithm is wrapped in pyOpenMS, so the new API is bound too: UnresolvedIdentifications (read-only fields) and the reduceToOnePerSpectrum static. Exercised from Python: a duplicate pair reduces to the better-scoring one and reports it. 3. CHANGELOG had two "IsobaricWorkflow:" headings under one "Changes:" section -- the new entry is merged into the pre-existing one, matching how the ProteomicsLFQ entry was added. ctest: 109/109 across TOPP_ProteomicsLFQ, TOPP_IsobaricWorkflow and IDConflictResolverAlgorithm. pyOpenMS builds clean. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01S7QNzj4dhRnX5htcHZFmDm
0ac0faa to
23d2637
Compare
|
Hmm I think that feature linking was still retrieving matching non-best identifications from features that were linked together. |
It doesn't — the linker resolves which features to group, never which identification wins. With And that choice is then discarded: On the non-best retrieval: you're right that Why reduce at load: FFID keys on Making the linker's distance-based choice actually count is the Generated by Claude Code |
|
one pattern that emerges a lot are the missing data contracts. might be worth tightening what we write out to reduce the amount of pre-checks This seems to be good to go for now (and is needed to move forward in the larger audit for qpx 1.1) |
|
Yes but I am not sure if this is the right contract here. You have the information about the potential match of a feature against a spectrum but we decide to report it as unassigned only because it was the second best hit. Instead of leaving it attached or reattaching. Note that I think this can happen quite frequently with peptidoforms where in one map the algorithm decides on a different modification position as number 1. |
|
It will now look like a transferred identification instead of a genuine potentially close tie at a specific feature in a map. |
|
@jpfeuffer Maybe I overlooked something but I don't think we properly resolve those currently. If we want to support resolving nearly tied hits via linking I think we need to make sure all algorithms really support this use case. Then it should also be more explicit. |
|
But it wasn't about resolving. It was about carrying over agreeing identifications to the result. |
|
If you link feature with IDs
Then the idea was to report that there was indeed evidence for A in map 2 with all its scores. And that it is not just a transferred identification |
|
It is a bit niche but could be valuable and less confusing as having an unattached PSM dangling somewhere. |
|
hmm I see the point but I see also a lot of ways this can go wrong e.g. both peptides elute at different RTs etc. |
|
Correcting my earlier comment — two of its citations were wrong, and they pointed in the wrong direction.
So nothing on this path is unassigned for being second best. The unassigned pushes reachable here are decoy ( @jpfeuffer — on carrying agreeing identifications over: you're right that we don't do it, and the reason is earlier than I suggested. Rank-2+ hits aren't demoted to unassigned, they're deleted: One thing worth recording for whenever that decision gets made: that function doesn't add the agreeing identification, it replaces the map's own rank-1 call with the winner ( Supporting this needs FFID to retain rank-2+ hits against an invariant several call sites rely on, plus that add-vs-replace decision. Separate piece of work, not for this thread. For the record on this PR specifically: |
Audited PRs merged since the last CHANGELOG update (#9881): most of them (#9879, #9880, #9882, #9884, #9886, #9892, #9896, #9898, #9900, #9901, #9888) already carried their own CHANGELOG entries. Only the Docker library-stage fix (#9891) was missing one. Claude-Session: https://claude.ai/code/session_01Jgrv6mFL3oawgLdYs1efPH Co-authored-by: Claude <[email protected]>
ProteomicsLFQandIsobaricWorkflowmeasure one value per(spectrum, peptidoform, charge). Input carrying several identifications of that same triple leaves it undecided which one owns the measurement, and both tools silently took all of them. This reduces to the best-scoring one at load, in both tools, and documents the precondition.The shape, and why this reduces rather than refuses
Two OpenMS tools produce it deliberately, so refusing would refuse the library's own output:
PSMFeatureExtractor -multiple_search_engines -concat— documented as "Naive merging of PSMs from different search engines: concatenate multiple search results instead of merging on scan level" (PSMFeatureExtractor.cpp:94), assigning every engine's identifications one run identifier (:257-260). The repo already ships a fixture of it:combined.concat.perco.in.idXML:137,594— samescan=334, same sequenceHYSEEEYDSEFDDADDDEEQ, same charge.PercolatorAdapterat its default-score:fdr 1.0—:1449-1470, verbatim: "If the input contains multiple PSMs per spectrum, Percolator only reports the top scoring PSM. The remaining PSMs should be reported as not identified" (PEP and q-value set to1.0).Both are resolved but not reduced: something upstream already ranked them, it just did not delete the losers. Picking the better of two scores on one scale is a tie-break, not a scoring decision — combining scores from different engines stays
ConsensusIDAlgorithm's job and is deliberately not done here.The one genuinely unresolvable case needs no new code:
ProteomicsLFQ::switchScoreType_(:764-779) already refuses input lacking a PEP score everywhere, so an un-rescored-concatfile (MS-GF:RawScorehigher-better vsexpectlower-better) is rejected today, for the right reason. What reaches the reduction is always one comparable scale.Measured effect of a single duplicated identification
IsobaricWorkflow— 7 consensus features instead of 6, the extra one bit-identical. It builds one consensus feature per identification (:631) and all identifications of one spectrum read the same MS2/MS3 scan, so the same reporter intensities enter quantification twice:Worth noting the damage is not a doubled peptide abundance — the peptide row duplicates with identical values, and the inflation lands at protein level. Not a clean 2× either, since a protein aggregates several peptides and only one is duplicated.
ProteomicsLFQ— 116 mzTab PSM rows against 115, plus a consensusXML difference. MSstats and Triqler output is unaffected; the damage from a duplicate is not uniform across exporters.Placement
In
ProteomicsLFQthe reduction runs after the missing-spectrum-reference repair (SpectrumMetaDataLookup::addMissingSpectrumReferences). An identification with no reference cannot be keyed at all, so reducing earlier would silently skip exactly the files whose references had to be reannotated. The fixture demonstrates this rather than asserting it:BSA1_F1.idXMLcarries no spectrum references at all, so at the earlier position the test would pass green while doing nothing.Implementation notes
QPXFilewriteshits[0]unsorted, as doesConsensusMapArrowExport::topHitPsmIdentity).operator==.AASequence's two operators disagree on what identifies a residue —operator<compares the one-letter code (AASequence.cpp:354-363),operator==the internedResidue*(:873-884) — so a pairoperator<calls equivalent could otherwise be split apart and its duplicate silently missed.isHigherScoreBetter()has no defined "best" and is left intact rather than reduced by a coin flip.Testing
Both TOPP tests diff against the existing un-duplicated reference files rather than new ones — "the duplicate changed no number" is exactly the assertion — so there is zero reference-file churn. Each also requires the reduction to report, since an identical output could otherwise mean it never ran.
IDConflictResolverAlgorithm_test: 8 cases, including both score directions, chimeric, missing reference, hitless, ordering, and empty input.TOPP_ProteomicsLFQ_duplicate_psm(+4 diffs),TOPP_IsobaricWorkflow_duplicate_psm(+1 diff).TOPP_ProteomicsLFQ+TOPP_IsobaricWorkflowpass.doctarget rebuilt; the Doxygen log contains only the two pre-existingHAVE_DOTwarnings.Relation to #9871
#9871 reported this as "one PSM row per search engine" from a quantms run. That diagnosis does not hold — the reported parquet predates #9818 and its collisions are the pre-#9818
run_file_namecollapse (analysis). But the underlying shape is real and OpenMS mishandled it, which is what this fixes. The issue's actual request — one PSM carrying per-engine scores — is not implementable in the exporter, since no per-hit engine label survives Percolator or ConsensusID; it belongs atConsensusIDAlgorithm.cpp:107(//TODO add SE name) and is left for a follow-up.Not in scope, each worth its own issue: the
qpxScanComponentsvendor truncation (every Sciex MS2 collapses onto itsexperimentindex; merged PASEF takes the wrong token), and moving duplicate-primary-key detection intoQPXCollectionExport::requireExportable.🤖 Generated with Claude Code
https://claude.ai/code/session_01S7QNzj4dhRnX5htcHZFmDm
Summary by CodeRabbit
New Features
Documentation
Tests