Repository navigation
[FIX,TOPP,ID] PSMFeatureExtractor: remove the multi-search-engine mode - #9896
Conversation
Both multi-engine code paths silently corrupted data and had no users. -concat aborted while writing X!Tandem input: it read a "XTandem_score" MetaValue that no OpenMS X!Tandem path ever writes, so CONCAT:XTandem became an empty DataValue and the idXML writer threw after a partial file. For MS-GF+ it took log() of the raw score instead of the E-value (MS:1002049 rather than MS:1002053); raw scores are routinely negative, so CONCAT:lnEvalue came out NaN. The shipped fixture combined.concat.perco.in.idXML had 4 of 29 lnEvalue values baked in as "nan", which is why the class test passed on the bug. Only 4 of the 7 supported engines had a branch at all. The default merge path keyed spectra via getScanMergeKey_, which parses a scan number out of "scan=" or "index=" native IDs and otherwise leaves it at 0. For "spectrum=" (PSI MS:1000777 - 211 occurrences vs 33 "scan=" in our own idXML fixtures, and what MzMLHandler falls back to writing), Sciex "sample=..." and "file=" IDs, every spectrum therefore got the same key and the std::map kept only the last one. On our own multi-engine test data 3 spectra collapsed to 1, with no warning; rewriting only "spectrum=N" to "scan=N" restores all 3. The reference PSMFeatureExtractor_1_out.idXML enshrined that loss. Removed the flags -multiple_search_engines, -concat, -skip_db_check, -impute and -limit_imputation; -in now takes a single file. Use ConsensusID to combine results from several search engines - PercolatorAdapter's mixed-engine error message now says so. The correspondingly unused PercolatorFeatureSetHelper statics concatMULTISEPeptideIds, mergeMULTISEPeptideIds, addMULTISEFeatures, addCONCATSEFeatures and getScanMergeKey_ are removed from the library and from pyOpenMS. mergeMULTISEProteinIds stays, PercolatorAdapter uses it. Tests: TOPP tests 1 and 2 become single-engine idXML/mzid runs; old test 3's reference carries over unchanged as the new _1_out.idXML, so the surviving single-engine path is byte-identical. The new mzid reference was cross-checked against that independent idXML reference (same feature set, hit count and feature_extractor tag). mergeMULTISEProteinIds and checkExtraFeatures had been covered only via the removed functions and now get direct tests; both were verified to fail on purpose before being trusted. Also fixed the docstrings in the pyOpenMS bindings, which were each attached to the preceding function. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01S7QNzj4dhRnX5htcHZFmDm
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthrough
ChangesSingle-search extraction
Sequence Diagram(s)sequenceDiagram
participant User
participant PSMFeatureExtractor
participant PercolatorFeatureSetHelper
participant Output
User->>PSMFeatureExtractor: Provide one input file
PSMFeatureExtractor->>PercolatorFeatureSetHelper: Apply single-engine features
PercolatorFeatureSetHelper-->>PSMFeatureExtractor: Return extracted features
PSMFeatureExtractor->>Output: Write converted identifications
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/topp/PSMFeatureExtractor.cpp (1)
130-145: 🩺 Stability & Availability | 🔴 Critical | ⚡ Quick winAdd a guard for an empty
protein_idsbefore the merge call.The code checks
protein_ids.size() > 1and throws, but it does not check forprotein_ids.size() == 0. If the loaded file yields zeroProteinIdentificationruns (for example, a validmzid/idparquetfile that legitimately reports no protein-detection results, or a type-detection mismatch that leavesprotein_idsempty),PercolatorFeatureSetHelper::mergeMULTISEProteinIds(all_protein_ids, protein_ids)callsnew_protein_ids.front()as its very first statement. This is undefined behavior on an empty vector and can crash the tool with no diagnostic message.
PercolatorAdapter.cppguards against exactly this case in its analogousreadInputFiles_function (see lines 632-639:if (protein_ids.empty()) { throw Exception::ElementNotFound(...); }before its own call tomergeMULTISEProteinIds).PSMFeatureExtractor.cppshould apply the same guard.🛡️ Proposed fix to guard against empty protein_ids
//check and warn if merged from multiple runs if (protein_ids.size() > 1) { throw Exception::InvalidValue( __FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "File '" + in + "' has more than one ProteinIDRun. This is currently not correctly handled." "Please use the merge_proteins_add_psms option if you used IDMerger. Alternatively, feed the" " original single-run idXML inputs into this tool one by one.", "# runs: " + StringUtils::toStr(protein_ids.size())); } + else if (protein_ids.empty()) + { + throw Exception::ElementNotFound( + __FILE__, + __LINE__, + OPENMS_PRETTY_FUNCTION, + "File '" + in + "' has no ProteinIDRun."); + } all_peptide_ids.insert(all_peptide_ids.end(), peptide_ids.begin(), peptide_ids.end()); PercolatorFeatureSetHelper::mergeMULTISEProteinIds(all_protein_ids, protein_ids);🤖 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/PSMFeatureExtractor.cpp` around lines 130 - 145, In the input-processing flow before PercolatorFeatureSetHelper::mergeMULTISEProteinIds, add an empty protein_ids guard matching the existing PercolatorAdapter::readInputFiles_ behavior: throw an appropriate Exception::ElementNotFound with a diagnostic message when no ProteinIdentification runs are loaded. Keep the existing size-greater-than-one validation and merge behavior unchanged for non-empty protein_ids.src/pyOpenMS/bindings/bind_analysis.cpp (1)
2227-2300: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winExpose
addANDESFeaturesandaddMSFRAGGERFeaturesin the pyOpenMS binding.
PercolatorFeatureSetHelper.addANDESFeatures(peptide_ids, feature_set)andPercolatorFeatureSetHelper.addMSFRAGGERFeatures(feature_set)are not bound insrc/pyOpenMS/bindings/bind_analysis.cpp, but the C++ side uses both methods for theandessearch engine and for MSFragger output. Add bindings matching those signatures to keep the pyOpenMS API parity with the existing search-engine feature helpers.🤖 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 2227 - 2300, Add static pyOpenMS bindings for OpenMS::PercolatorFeatureSetHelper::addANDESFeatures and addMSFRAGGERFeatures alongside the existing addMSGFFeatures, addXTANDEMFeatures, addCOMETFeatures, and addMASCOTFeatures bindings. Match each C++ method’s signature and wrapper behavior, including the appropriate peptide_ids and feature_set arguments and returning the updated feature_set, with documentation consistent with the neighboring helpers.
🧹 Nitpick comments (2)
src/tests/class_tests/openms/source/PercolatorFeatureSetHelper_test.cpp (1)
89-90: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd braces to each range-for body.
Lines 89-90 and Line 111 use range-for statements without braces. The C++ formatting rules require braces for all blocks.
As per coding guidelines, “always use braces for blocks.”
Also applies to: 111-111
🤖 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/PercolatorFeatureSetHelper_test.cpp` around lines 89 - 90, Add braces around the bodies of both range-for loops iterating over msgf_pods.front().getHits() and comet_pods.front().getHits(), and apply the same brace style to the range-for statement at line 111. Preserve the existing loop statements and body logic.Source: Coding guidelines
src/topp/PSMFeatureExtractor.cpp (1)
143-145: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider simplifying the single-run merge.
-innow accepts exactly one file, soall_protein_idsis empty on the only call tomergeMULTISEProteinIds. In that state the helper does more work than the single-run case needs: it sorts the incomingProteinHits for a union merge that has nothing to unite, and it stamps a freshly generated"TopPerc_" + dateidentifier onto the run instead of preserving whatever run identifier the input file already carried. A direct move ofprotein_ids.front()intoall_protein_ids(with the existingsearch_engine/search-parameter setup inlined) would be clearer for a single-input tool and would avoid discarding the input run's own identifier and date metadata.This is a code-clarity improvement, not a correctness fix, since the current behavior matches the pre-existing multi-run merge semantics.
🤖 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/PSMFeatureExtractor.cpp` around lines 143 - 145, In the single-input aggregation block, replace the first-call use of PercolatorFeatureSetHelper::mergeMULTISEProteinIds with a direct move of protein_ids.front() into all_protein_ids, preserving the input run’s identifier and date metadata. Inline the existing search_engine and search-parameter setup needed for that assignment, while leaving peptide aggregation and multi-run merge behavior unchanged.
🤖 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/tests/topp/CMakeLists.txt`:
- Around line 4745-4749: Add a TOPP regression test near the existing
PSMFeatureExtractor tests that invokes PSMFeatureExtractor with a multi-run
ProteinIdentification idXML input and asserts the command fails. Use the
existing test-data and temporary-directory conventions, and do not add a
reference-output comparison; ensure the test specifically exercises rejection of
multiple ProteinIdentification runs.
---
Outside diff comments:
In `@src/pyOpenMS/bindings/bind_analysis.cpp`:
- Around line 2227-2300: Add static pyOpenMS bindings for
OpenMS::PercolatorFeatureSetHelper::addANDESFeatures and addMSFRAGGERFeatures
alongside the existing addMSGFFeatures, addXTANDEMFeatures, addCOMETFeatures,
and addMASCOTFeatures bindings. Match each C++ method’s signature and wrapper
behavior, including the appropriate peptide_ids and feature_set arguments and
returning the updated feature_set, with documentation consistent with the
neighboring helpers.
In `@src/topp/PSMFeatureExtractor.cpp`:
- Around line 130-145: In the input-processing flow before
PercolatorFeatureSetHelper::mergeMULTISEProteinIds, add an empty protein_ids
guard matching the existing PercolatorAdapter::readInputFiles_ behavior: throw
an appropriate Exception::ElementNotFound with a diagnostic message when no
ProteinIdentification runs are loaded. Keep the existing size-greater-than-one
validation and merge behavior unchanged for non-empty protein_ids.
---
Nitpick comments:
In `@src/tests/class_tests/openms/source/PercolatorFeatureSetHelper_test.cpp`:
- Around line 89-90: Add braces around the bodies of both range-for loops
iterating over msgf_pods.front().getHits() and comet_pods.front().getHits(), and
apply the same brace style to the range-for statement at line 111. Preserve the
existing loop statements and body logic.
In `@src/topp/PSMFeatureExtractor.cpp`:
- Around line 143-145: In the single-input aggregation block, replace the
first-call use of PercolatorFeatureSetHelper::mergeMULTISEProteinIds with a
direct move of protein_ids.front() into all_protein_ids, preserving the input
run’s identifier and date metadata. Inline the existing search_engine and
search-parameter setup needed for that assignment, while leaving peptide
aggregation and multi-run merge behavior 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: 7ed277f8-9ff2-4401-8f2e-3c1b82421682
📒 Files selected for processing (13)
CHANGELOGsrc/openms/include/OpenMS/ANALYSIS/ID/PercolatorFeatureSetHelper.hsrc/openms/source/ANALYSIS/ID/PercolatorFeatureSetHelper.cppsrc/pyOpenMS/bindings/bind_analysis.cppsrc/tests/class_tests/openms/data/combined.concat.perco.in.idXMLsrc/tests/class_tests/openms/data/combined.merge.perco.in.idXMLsrc/tests/class_tests/openms/source/PercolatorFeatureSetHelper_test.cppsrc/tests/topp/CMakeLists.txtsrc/tests/topp/PSMFeatureExtractor_1_out.idXMLsrc/tests/topp/PSMFeatureExtractor_2_out.mzidsrc/tests/topp/PSMFeatureExtractor_3_out.idXMLsrc/topp/PSMFeatureExtractor.cppsrc/topp/PercolatorAdapter.cpp
💤 Files with no reviewable changes (4)
- src/tests/class_tests/openms/data/combined.concat.perco.in.idXML
- src/tests/topp/PSMFeatureExtractor_3_out.idXML
- src/tests/class_tests/openms/data/combined.merge.perco.in.idXML
- src/openms/source/ANALYSIS/ID/PercolatorFeatureSetHelper.cpp
| add_test("TOPP_PSMFeatureExtractor_1" ${TOPP_BIN_PATH}/PSMFeatureExtractor -test -in ${DATA_DIR_TOPP}/THIRDPARTY/MSGFPlusAdapter_1_out.idXML -out_type idXML -out ${TESTS_TEMP_DIR}/PSMFeatureExtractor_1_out.tmp.idXML) | ||
| add_test("TOPP_PSMFeatureExtractor_1_out" ${DIFF} -whitelist "InferenceEngineVersion" "spectra_data" "MS-GF+:" "db=" "date=" "UserParam type=\"string\" name=\"MSGFPlusAdapter:1" -in1 ${TESTS_TEMP_DIR}/PSMFeatureExtractor_1_out.tmp.idXML -in2 ${DATA_DIR_TOPP}/PSMFeatureExtractor_1_out.idXML) | ||
| set_tests_properties("TOPP_PSMFeatureExtractor_1_out" PROPERTIES DEPENDS "TOPP_PSMFeatureExtractor_1") | ||
|
|
||
| add_test("TOPP_PSMFeatureExtractor_2" ${TOPP_BIN_PATH}/PSMFeatureExtractor -test -in ${DATA_DIR_TOPP}/THIRDPARTY/MSGFPlusAdapter_1_out.idXML ${DATA_DIR_TOPP}/THIRDPARTY/XTandemAdapter_1_out.idXML -multiple_search_engines -skip_db_check -out_type mzid -out ${TESTS_TEMP_DIR}/PSMFeatureExtractor_2_out.tmp.mzid) | ||
| add_test("TOPP_PSMFeatureExtractor_2" ${TOPP_BIN_PATH}/PSMFeatureExtractor -test -in ${DATA_DIR_TOPP}/THIRDPARTY/MSGFPlusAdapter_1_out.idXML -out_type mzid -out ${TESTS_TEMP_DIR}/PSMFeatureExtractor_2_out.tmp.mzid) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Locate relevant files/text =="
rg -n "PSMFeatureExtractor|multi.?run|ProteinIdentification|multiple" src/tests/topp src -g '*.{cpp,h,cxx,hpp,txt}' | head -n 200
echo
echo "== PSMFeatureExtractor implementation candidates =="
fd -i 'PSMFeatureExtractor' . | sort
echo
echo "== CMake top relevant section =="
sed -n '4720,4770p' src/tests/topp/CMakeLists.txtRepository: OpenMS/OpenMS
Length of output: 41305
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== PSMFeatureExtractor source outline =="
ast-grep outline src/topp/PSMFeatureExtractor.cpp --view expanded || true
echo
echo "== PSMFeatureExtractor relevant source =="
wc -l src/topp/PSMFeatureExtractor.cpp
sed -n '1,260p'
echo
echo "== Exact multiple ProteinIdentification references in src/topp/PSMFeatureExtractor.cpp =="
rg -n -C 4 "ProteinIdentification|multiple|size|at most|only run|too many" src/topp/PSMFeatureExtractor.cpp
echo
echo "== Existing rejection tests in src/tests/topp/CMakeLists.txt =="
sed -n '460,475p;1330,1355p' src/tests/topp/CMakeLists.txt
echo
echo "== Negative/rejection test syntax examples =="
rg -n -C 2 'add_test\(.*-.*expect|expect=|return_code|exit' src/tests/topp/CMakeLists.txt | head -n 160Repository: OpenMS/OpenMS
Length of output: 891
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Full PSMFeatureExtractor source =="
cat -n src/topp/PSMFeatureExtractor.cpp
echo
echo "== Source branch count =="
wc -l src/topp/PSMFeatureExtractor.cpp
echo
echo "== Search exact identifiers in PSMFeatureExtractor =="
rg -n -C 3 '"ProteinIdentification"|getProteinIdentifications|setProteinIdentifications|throw|at\(|size\(\)|for\s*\(' src/topp/PSMFeatureExtractor.cppRepository: OpenMS/OpenMS
Length of output: 12530
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== TOPP test file size and last lines =="
wc -l src/tests/topp/THIRDPARTY/MSGGPlusAdapter_1_out.idXML src/tests/topp/THIRDPARTY/MSGFPlusAdapter_1_out.idXML 2>/dev/null || true
sed -n '1,80p' src/tests/topp/THIRDPARTY/MSGFPlusAdapter_1_out.idXML 2>/dev/null || true
sed -n '1,80p' src/tests/topp/PSMFeatureExtractor_1_out.idXML 2>/dev/null || true
echo
echo "== ProteinIDRun occurrences in available inputs =="
rg -n "ProteinIDRun|<ProteinIdentification" src/tests/topp/src/tests/topp/THIRDPARTY/MSGFPlusAdapter_1_out.idXML src/tests/topp/PSMFeatureExtractor_1_out.idXML 2>/dev/null || true
echo
echo "== Search for IDMerger test data with multiple ProteinIDRun =="
rg -n "merge_proteins_add_psms|IDMerger|ProteinIDRun" src/tests/topp -g '*.idXML' -g '*.mzid' | head -n 200Repository: OpenMS/OpenMS
Length of output: 15513
Add coverage for multi-run ProteinIdentification rejection.
PSMFeatureExtractor rejects inputs with more than one ProteinIdentification run, but the current TOPP tests only use the single-run MSGFPlusAdapter_1_out.idXML. Add a small TOPP regression that passes an idXML file with multiple ProteinIdentification runs and asserts failure; this covers the new guard and does not require the tool output to match a reference file.
🤖 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/topp/CMakeLists.txt` around lines 4745 - 4749, Add a TOPP
regression test near the existing PSMFeatureExtractor tests that invokes
PSMFeatureExtractor with a multi-run ProteinIdentification idXML input and
asserts the command fails. Use the existing test-data and temporary-directory
conventions, and do not add a reference-output comparison; ensure the test
specifically exercises rejection of multiple ProteinIdentification runs.
Source: Coding guidelines
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]>
Summary
Removes PSMFeatureExtractor's multi-search-engine mode: the flags
-multiple_search_engines,-concat,-skip_db_check,-imputeand-limit_imputation.-innow takes a single file.Both code paths silently corrupted data, and a search of public code turned up no users — only OpenMS's own two TOPP tests, the auto-generated Galaxy CTD wrapper (exposure, not usage), and three KNIME workflows that set both flags to
false. No repository anywhere sets them true.-concatnever workedRunning it on OpenMS's own multi-engine test data aborts with exit 8:
getMetaValue("XTandem_score"), a MetaValue no OpenMS X!Tandem path writes (onlyPepXMLFilereads it).CONCAT:XTandembecomes an emptyDataValueand the idXML writer throws, after a partial file has been written.evalue = toDouble(getMetaValue("MS:1002049"))takes the raw score despite the// evaluecomment (MS-GF+'s E-value isMS:1002053). Raw scores are routinely negative, solog()gives NaN. The shipped fixturecombined.concat.perco.in.idXMLhas 4 of 29CONCAT:lnEvaluevalues baked in asnan— which is why the class test passed on the bug.CONCAT:<engine>value and a constantlnEvalue = log(1000)whileextra_featuresstill advertised the feature. Only Comet's branch was correct.The merge path silently discarded most spectra
getScanMergeKey_parses a scan number out ofscan=orindex=native IDs and otherwise leaves it at its initialiser0— the same key for every spectrum, so thestd::mapkept only the last one. No warning: the existing"no known spectrum identifiers"message only fires when the reference is empty, not when it is unparseable.On OpenMS's own test data (3 spectra, both engines agreeing on all 3), changing nothing but the native-ID form:
spectrum_referencespectrum=0/1/2(shipped test data)scan=0/1/2MULTI:numHits=2This is not a corner case: in our own shipped idXML fixtures the prefixes run
spectrum=211×,scan=33×,index=11×.spectrum=is PSIMS:1000777, andMzMLHandler.cpp:4071shows OpenMS itself falls back to writing it when input native IDs are invalid. Sciex WIFF (sample=1 period=1 cycle=…) andfile=single-peak-list IDs collapse the same way. The referencePSMFeatureExtractor_1_out.idXMLenshrined the loss, so TOPP tests 1 and 2 passed green.Library / pyOpenMS
The now-unused statics
concatMULTISEPeptideIds,mergeMULTISEPeptideIds,addMULTISEFeatures,addCONCATSEFeaturesandgetScanMergeKey_are removed fromPercolatorFeatureSetHelperand from the pyOpenMS bindings.mergeMULTISEProteinIdsstays —PercolatorAdapter.cpp:761uses it.PercolatorAdapter's mixed-engine error message now points at ConsensusID instead of PSMFeatureExtractor.Tests
_1_out.idXML, so the surviving single-engine path is provably unchanged.feature_extractortag) rather than simply regenerated.mergeMULTISEProteinIdsandcheckExtraFeatureshad been covered only via the removed functions (checkExtraFeatureswas literallyNOT_TESTABLE). Both now get direct tests asserting the real contract; the union-by-accession expectation is computed in-test from the inputs, so there are no magic numbers.Full build green including pyOpenMS; 151 related ctests pass; pyOpenMS 5693 passed / 79 skipped.
TOPP_PercolatorAdapter_1_subprocess_outfails locally with identical numbers on a pristine tree (local percolator binary numerics), unrelated to this change.🤖 Generated with Claude Code
https://claude.ai/code/session_01S7QNzj4dhRnX5htcHZFmDm
Summary by CodeRabbit
Updated
TOPP_ConsensusIDto combine results from different search engines.Removed