Repository navigation
fix(METADATA): leniently stringify non-string search settings (ProteomicsLFQ mzTab crash) - #9666
Conversation
getSearchEngineSettingsAsPairs() built a std::string pair member directly from params.getMetaValue(key). Since the String class was removed, DataValue::operator std::string() is strict and throws on any non-string type. The first Int setting (e.g. Comet:missed_cleavages=2) therefore threw "Could not convert non-string DataValue of type 'Int'", crashing ProteomicsLFQ's streaming mzTab export (MzTabFile::store(ConsensusMap) -> CMMzTabStream -> mapBetweenRunAndSearchEngines_) after the consensusXML had already been written. Convert explicitly with StringUtils::toStr(), matching the other settings in the same function. Adds a ProteinIdentification_test regression covering Int/Double/ String settings (the method was previously untested). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_016rawZsiVUCJjzyXTqkkrWK
📝 WalkthroughWalkthrough
ChangesProteinIdentification search-engine settings
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
🧹 Nitpick comments (1)
src/tests/class_tests/openms/source/ProteinIdentification_test.cpp (1)
376-378: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
TEST_TRUEfor boolean assertions.These assert booleans against
true; preferTEST_TRUEfor clarity. Themissed/enzymechecks can also assert string equality directly.♻️ Proposed change
- TEST_EQUAL(missed == "2", true) - TEST_EQUAL(enzyme == "Trypsin", true) - TEST_EQUAL(have_tol, true) + TEST_EQUAL(missed, "2") + TEST_EQUAL(enzyme, "Trypsin") + TEST_TRUE(have_tol)As per coding guidelines: "Prefer
TEST_TRUE(expr)andTEST_FALSE(expr)overTEST_EQUAL(expr, true)andTEST_EQUAL(expr, false)for boolean assertions".🤖 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/ProteinIdentification_test.cpp` around lines 376 - 378, The assertions in ProteinIdentification_test should use the boolean-specific test macros instead of comparing against true. Update the checks around the missed, enzyme, and have_tol values in the relevant test case to use TEST_TRUE for boolean conditions, and prefer direct string equality assertions for the missed and enzyme string values where applicable. Refer to the existing test block in ProteinIdentification_test and keep the same intent while replacing TEST_EQUAL(..., true) with the clearer assertions.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.
Nitpick comments:
In `@src/tests/class_tests/openms/source/ProteinIdentification_test.cpp`:
- Around line 376-378: The assertions in ProteinIdentification_test should use
the boolean-specific test macros instead of comparing against true. Update the
checks around the missed, enzyme, and have_tol values in the relevant test case
to use TEST_TRUE for boolean conditions, and prefer direct string equality
assertions for the missed and enzyme string values where applicable. Refer to
the existing test block in ProteinIdentification_test and keep the same intent
while replacing TEST_EQUAL(..., true) with the clearer assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7aa8bd03-a0da-421d-9698-ee73ed8c12e0
📒 Files selected for processing (2)
src/openms/source/METADATA/ProteinIdentification.cppsrc/tests/class_tests/openms/source/ProteinIdentification_test.cpp
Documents PRs that landed after the last CHANGELOG update (#9656): - #9647 PIP-ECHO match-between-runs algorithm in ProteomicsLFQ - #9666 ProteomicsLFQ mzTab crash on non-string search settings - #9658 ProteinQuantifier wrong per-file split on merged ID runs (fixes #5518) - #9664 Math::quantile1st/3rd crash on 1–2 element inputs (fixes #9659) Claude-Session: https://claude.ai/code/session_01DYJ6LYHiJADSGjCkfBBJiN Co-authored-by: Claude <[email protected]>
Problem
ProteomicsLFQaborts during mzTab export when the search settings include a non-string value (e.g. an integermissed_cleavages):The abort happens after the consensusXML has already been written, so
-out_cxmlsucceeds but-out(mzTab) and-out_msstatsare left empty/missing.Root cause
ProteinIdentification::getSearchEngineSettingsAsPairs()built thestd::stringmember of a(key, value)pair directly from aDataValue:result.emplace_back(StringUtils::substr(mvkey, se.size()+1), params.getMetaValue(mvkey));Since the
Stringclass was removed,DataValue::operator std::string()is strict and throwsConversionErroron any non-STRING_VALUEtype (the lenientString(const DataValue&)stringification is gone). The firstIntsetting (e.g.Comet:missed_cleavages = 2) therefore throws.Call path:
The other settings in the same function already use
StringUtils::toStr; this one branch was missed during theStringremoval.Fix
Use the lenient
StringUtils::toStr()(the documented replacement forString(const DataValue&)), matching the rest of the function.Test
Adds a
ProteinIdentification_testsection forgetSearchEngineSettingsAsPairscovering Int / Double / String settings (the method had no prior coverage).Verification
ProteomicsLFQon a real dataset now exits 0 and writes a fully populated mzTab (PRT/PSM/PEP) + MSstats where it previously crashed. Surfaced while benchmarking match-between-runs for #9647 (PIP-ECHO), but the bug is independent of that work.🤖 Generated with Claude Code
https://claude.ai/code/session_016rawZsiVUCJjzyXTqkkrWK
Summary by CodeRabbit
Bug Fixes
Tests