Repository navigation
[FIX] ProSE/SimpleSearchEngine: don't abort on low-res data; gate deisotoping via Deisotoper::isToleranceSupported (#9619) - #9620
Conversation
…ead of aborting (#9619) preprocessSpectra_ called Deisotoper::deisotopeAndSingleCharge inside an #pragma omp parallel for. The deisotoper throws for fragment tolerance >0.1 Da / >100 ppm, so the exception escaped the parallel region and called std::terminate() -- ProSE aborted (signal 6) on low-resolution (ion-trap CID) data, after the fragment index had already been built. Decide whether to deisotope once, before the OpenMP region: skip it (with a one-time OPENMS_LOG_WARN) when the tolerance is out of range, so ProSE can still search low-resolution spectra. High-res behaviour (<=0.1 Da / <=100 ppm) is unchanged; existing ProSE_1/2/4 TOPP tests run at 0.1 Da and are unaffected. Adds a ProSEAlgorithm_test regression section (preprocessSpectra_ at 0.5 Da / 150 ppm must not throw; 0.05 Da / 20 ppm still deisotope). Co-Authored-By: Claude Opus 4.8 <[email protected]>
… (fragment:deisotope) Generalize the low-res deisotoping fix (#9619) into an explicit parameter, modelled on data-driven engines' per-instrument deconvolution gating (e.g. bigbio/andes apply_deconvolution, which is off for its low-res CID model): fragment:deisotope = auto (default) | true | false - auto: deisotope only for high-res tolerances (<=0.1 Da / <=100 ppm), skip (with a warning) for low-res so the search still runs; - true: always deisotope; rejected up front (ILLEGAL_PARAMETERS) when the fragment tolerance is low-res, instead of aborting mid-search; - false: never deisotope. The decision is still made once, before the OpenMP region, and the Deisotoper is only ever called with an in-range tolerance, so no exception can escape the parallel region (the second defect in #9619). Extends ProSEAlgorithm_test with deisotope-mode coverage and parameter validation. Co-Authored-By: Claude Opus 4.8 <[email protected]>
📝 WalkthroughWalkthroughProSEAlgorithm and SimpleSearchEngineAlgorithm now safely gate MS2 deisotoping based on tolerance range support. A new ChangesSafe, configurable MS2 deisotoping with tolerance-aware gating
Possibly related issues
🚥 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.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp (1)
88-98:⚠️ Potential issue | 🟠 MajorReject negative fragment tolerances before the OpenMP path.
The new guard only checks the upper Deisotoper limit, so
fragment:mass_tolerance = -1is treated asin_rangeand can still be passed toDeisotoper::deisotopeAndSingleChargeinside the parallel loop. Add a non-negative minimum to the parameter and include the lower bound in both predicates.Also fix the
endlon line 378 to use\ninstead (preferred in new logging code per coding guidelines).Suggested fix
defaults_.setValue("fragment:mass_tolerance", 10.0, "Fragment mass tolerance"); + defaults_.setMinFloat("fragment:mass_tolerance", 0.0); @@ const bool unit_ppm = (fragment_mass_tolerance_unit_ == "ppm"); - const bool in_range = (unit_ppm && fragment_mass_tolerance_ <= 100.0) || (!unit_ppm && fragment_mass_tolerance_ <= 0.1); + const bool in_range = fragment_mass_tolerance_ >= 0.0 && + ((unit_ppm && fragment_mass_tolerance_ <= 100.0) || (!unit_ppm && fragment_mass_tolerance_ <= 0.1)); @@ const bool tol_in_range = - (fragment_mass_tolerance_unit_ppm && fragment_mass_tolerance <= 100.0) || - (!fragment_mass_tolerance_unit_ppm && fragment_mass_tolerance <= 0.1); + fragment_mass_tolerance >= 0.0 && + ((fragment_mass_tolerance_unit_ppm && fragment_mass_tolerance <= 100.0) || + (!fragment_mass_tolerance_unit_ppm && fragment_mass_tolerance <= 0.1)); @@ OPENMS_LOG_WARN << "[ProSE] Fragment tolerance " << fragment_mass_tolerance << (fragment_mass_tolerance_unit_ppm ? " ppm" : " Da") << " exceeds the deisotoping limit (100 ppm / 0.1 Da); skipping MS2 " - << "deisotoping (expected for low-resolution data)." << endl; + << "deisotoping (expected for low-resolution data)." << "\n";🤖 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/ANALYSIS/ID/ProSEAlgorithm.cpp` around lines 88 - 98, The fragment mass tolerance validation is missing a non-negative minimum bound check, allowing negative values like -1 to be passed to the Deisotoper::deisotopeAndSingleCharge function. Add a minimum bound validation to the "fragment:mass_tolerance" parameter using defaults_.setMinFloat to ensure it is non-negative, and update any predicates that check the tolerance range to include this lower bound check alongside the existing upper bound check. Additionally, locate and replace the endl on line 378 with \n to match the preferred logging style in new code per coding guidelines.
🧹 Nitpick comments (1)
src/tests/class_tests/openms/source/ProSEAlgorithm_test.cpp (1)
1457-1470: ⚡ Quick winAdd an explicit invalid
ppmcase fordeisotope=truevalidation.This section validates the low-res rejection only for
Da. Add a150 ppmrejection assertion to lock both unit branches of the contract.Suggested addition
// deisotope=true with a low-resolution (Da > 0.1) tolerance is rejected up front, // rather than aborting later inside the search. Param p = algo.getParameters(); p.setValue("fragment:deisotope", "true"); p.setValue("fragment:mass_tolerance", 0.5); p.setValue("fragment:mass_tolerance_unit", "Da"); TEST_EXCEPTION(Exception::InvalidParameter, algo.setParameters(p)) + + // deisotope=true with a low-resolution (ppm > 100) tolerance is also rejected. + p.setValue("fragment:mass_tolerance", 150.0); + p.setValue("fragment:mass_tolerance_unit", "ppm"); + TEST_EXCEPTION(Exception::InvalidParameter, algo.setParameters(p))🤖 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/ProSEAlgorithm_test.cpp` around lines 1457 - 1470, Add a test case after the existing low-resolution Da rejection test (where fragment:mass_tolerance is 0.5) to validate the same deisotope=true rejection behavior for ppm units. Create a new test block that sets fragment:mass_tolerance to 150, fragment:mass_tolerance_unit to "ppm", fragment:deisotope to "true", and verify that calling algo.setParameters(p) with these parameters throws an Exception::InvalidParameter using TEST_EXCEPTION, ensuring both unit branches (Da and ppm) of the deisotope validation contract are tested.
🤖 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/ANALYSIS/ID/ProSEAlgorithm.h`:
- Around line 366-367: The preprocessSpectra_ method's documentation is
incomplete and misleading. Add a full Doxygen documentation block before this
method declaration that includes a detailed `@brief` description explaining that
deisotoping behavior is now controlled by the deisotope_mode parameter, followed
by `@param` documentation for each parameter (exp, fragment_mass_tolerance,
fragment_mass_tolerance_unit_ppm, and deisotope_mode) with clear descriptions of
what deisotope_mode controls and the valid mode values, and clarify how the
tolerance parameters are used in the filtering and decharging process.
In `@src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp`:
- Around line 375-378: The OPENMS_LOG_WARN statement logging the fragment
tolerance warning uses `endl` which causes an unnecessary flush of the output
stream on every call. Replace the `endl` at the end of the log statement with
`'\n'` to avoid the performance penalty of flushing. This change should be made
in the warning message that mentions "Fragment tolerance" and "deisotoping limit
(100 ppm / 0.1 Da)".
---
Outside diff comments:
In `@src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp`:
- Around line 88-98: The fragment mass tolerance validation is missing a
non-negative minimum bound check, allowing negative values like -1 to be passed
to the Deisotoper::deisotopeAndSingleCharge function. Add a minimum bound
validation to the "fragment:mass_tolerance" parameter using
defaults_.setMinFloat to ensure it is non-negative, and update any predicates
that check the tolerance range to include this lower bound check alongside the
existing upper bound check. Additionally, locate and replace the endl on line
378 with \n to match the preferred logging style in new code per coding
guidelines.
---
Nitpick comments:
In `@src/tests/class_tests/openms/source/ProSEAlgorithm_test.cpp`:
- Around line 1457-1470: Add a test case after the existing low-resolution Da
rejection test (where fragment:mass_tolerance is 0.5) to validate the same
deisotope=true rejection behavior for ppm units. Create a new test block that
sets fragment:mass_tolerance to 150, fragment:mass_tolerance_unit to "ppm",
fragment:deisotope to "true", and verify that calling algo.setParameters(p) with
these parameters throws an Exception::InvalidParameter using TEST_EXCEPTION,
ensuring both unit branches (Da and ppm) of the deisotope validation contract
are tested.
🪄 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
Run ID: 0a271759-baa9-4eee-9057-54851f5931c5
📒 Files selected for processing (3)
src/openms/include/OpenMS/ANALYSIS/ID/ProSEAlgorithm.hsrc/openms/source/ANALYSIS/ID/ProSEAlgorithm.cppsrc/tests/class_tests/openms/source/ProSEAlgorithm_test.cpp
| /// @brief filter, deisotope, decharge spectra | ||
| static void preprocessSpectra_(PeakMap& exp, double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm); | ||
| static void preprocessSpectra_(PeakMap& exp, double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm, const std::string& deisotope_mode); |
There was a problem hiding this comment.
Document the new deisotoping mode parameter.
The header comment still says “filter, deisotope, decharge” unconditionally, but deisotope_mode now controls whether deisotoping happens. Please add a Doxygen block with the mode values and tolerance-gating behavior.
As per coding guidelines, headers should use Doxygen documentation with @brief, followed by details and parameter documentation.
Suggested documentation update
- /// `@brief` filter, deisotope, decharge spectra
+ /**
+ * `@brief` Filter, optionally deisotope/decharge, and normalize spectra.
+ *
+ * `@param`[in,out] exp Spectra to preprocess in-place.
+ * `@param`[in] fragment_mass_tolerance Fragment mass tolerance value.
+ * `@param`[in] fragment_mass_tolerance_unit_ppm Whether the fragment tolerance is in ppm.
+ * `@param`[in] deisotope_mode MS2 deisotoping mode: "auto", "true", or "false".
+ */
static void preprocessSpectra_(PeakMap& exp, double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm, const std::string& deisotope_mode);📝 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.
| /// @brief filter, deisotope, decharge spectra | |
| static void preprocessSpectra_(PeakMap& exp, double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm); | |
| static void preprocessSpectra_(PeakMap& exp, double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm, const std::string& deisotope_mode); | |
| /** | |
| * `@brief` Filter, optionally deisotope/decharge, and normalize spectra. | |
| * | |
| * `@param`[in,out] exp Spectra to preprocess in-place. | |
| * `@param`[in] fragment_mass_tolerance Fragment mass tolerance value. | |
| * `@param`[in] fragment_mass_tolerance_unit_ppm Whether the fragment tolerance is in ppm. | |
| * `@param`[in] deisotope_mode MS2 deisotoping mode: "auto", "true", or "false". | |
| */ | |
| static void preprocessSpectra_(PeakMap& exp, double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm, const std::string& deisotope_mode); |
🤖 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/ANALYSIS/ID/ProSEAlgorithm.h` around lines 366 -
367, The preprocessSpectra_ method's documentation is incomplete and misleading.
Add a full Doxygen documentation block before this method declaration that
includes a detailed `@brief` description explaining that deisotoping behavior is
now controlled by the deisotope_mode parameter, followed by `@param` documentation
for each parameter (exp, fragment_mass_tolerance,
fragment_mass_tolerance_unit_ppm, and deisotope_mode) with clear descriptions of
what deisotope_mode controls and the valid mode values, and clarify how the
tolerance parameters are used in the filtering and decharging process.
Source: Coding guidelines
…rchEngine through it (#9619) Addresses code review of the ProSE low-res deisotoping fix: the 100 ppm / 0.1 Da Deisotoper tolerance limit was duplicated by value inside ProSE, and the same latent abort (an exception escaping an OpenMP region calls std::terminate) still existed in the sibling SimpleSearchEngineAlgorithm. - Deisotoper::isToleranceSupported(tol, ppm): single, non-throwing source of truth for the limit; both deisotopeAndSingleCharge() precondition throws now use it. - ProSEAlgorithm: resolve the fragment:deisotope decision ONCE in updateMembers_ (fixes the per-file recompute and repeated warning on multi-file runs); preprocessSpectra_ now takes a plain bool and gates the Deisotoper call on isToleranceSupported(), so the static method is self-safe regardless of caller (no silent 'true' + out-of-range skip path). - SimpleSearchEngineAlgorithm: gate its deisotope call on isToleranceSupported() so low-resolution input skips deisotoping instead of aborting. - Tests: Deisotoper_test covers the isToleranceSupported boundaries; ProSEAlgorithm_test exercises the bool API + self-safety. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/openms/source/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cpp (1)
223-234: ⚡ Quick winPrefer
\noverendlfor logging.Line 233 uses
endlinstead of\n. As per coding guidelines,std::endlshould be avoided for performance; prefer\n.♻️ Proposed fix
OPENMS_LOG_WARN << "[SimpleSearchEngine] Fragment tolerance " << fragment_mass_tolerance << (fragment_mass_tolerance_unit_ppm ? " ppm" : " Da") << " exceeds the deisotoping limit (100 ppm / 0.1 Da); skipping MS2 " - << "deisotoping (expected for low-resolution data)." << endl; + << "deisotoping (expected for low-resolution data).\n";🤖 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/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cpp` around lines 223 - 234, The OPENMS_LOG_WARN logging statement in the Deisotoper tolerance check uses endl instead of \n for the newline. Replace the endl at the end of the OPENMS_LOG_WARN chain (after "deisotoping (expected for low-resolution data).") with \n to follow the coding guideline of avoiding std::endl for performance reasons.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/openms/source/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cpp`:
- Around line 223-234: The OPENMS_LOG_WARN logging statement in the Deisotoper
tolerance check uses endl instead of \n for the newline. Replace the endl at the
end of the OPENMS_LOG_WARN chain (after "deisotoping (expected for
low-resolution data).") with \n to follow the coding guideline of avoiding
std::endl for performance reasons.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 80b7f812-5c83-4277-9101-7fc825491d9e
📒 Files selected for processing (7)
src/openms/include/OpenMS/ANALYSIS/ID/ProSEAlgorithm.hsrc/openms/include/OpenMS/PROCESSING/DEISOTOPING/Deisotoper.hsrc/openms/source/ANALYSIS/ID/ProSEAlgorithm.cppsrc/openms/source/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cppsrc/openms/source/PROCESSING/DEISOTOPING/Deisotoper.cppsrc/tests/class_tests/openms/source/Deisotoper_test.cppsrc/tests/class_tests/openms/source/ProSEAlgorithm_test.cpp
|
Adversarial review result: no blocking behavioral issue found in this pass. Required source cleanup before merge: the diff adds tracker references in source/test comments and test section names. Please remove those references and keep the source comments focused on the behavior/contract itself. I did not run the tests locally. |
Add entries for all substantive non-test PRs merged since the last changelog update: - #9623 ThermoRawFile full mzML metadata extraction + polarity fix - #9602 New FileInfo library class usable from C++ and pyOpenMS - #9521 IMAGING multi-region support (add missing PR reference) - #9620 Deisotoper::isToleranceSupported + ProSE/SSE crash fix on low-res data - #9610 DistanceMatrix::setValue cached-minimum guard fix - #9497 DistanceMatrix::operator==, ClusteringGrid, File path guard fixes - #9583 LogStreamBuf thread-safety fix - #9514 CI Windows migration to Visual Studio 2026 Claude-Session: https://claude.ai/code/session_01YLg6pWyjyTxpWAU6mgrDzC Co-authored-by: Claude <[email protected]>
What
Fixes #9619.
OpenMS aborts (signal 6, uncaught
Exception::IllegalArgument) when a fragment-index search engine is given a fragment tolerance appropriate for low-resolution (ion-trap CID) MS2 data.Deisotoper::deisotopeAndSingleChargethrows for a fragment tolerance > 100 ppm / 0.1 Da, and ProSE / SimpleSearchEngine call it inside an#pragma omp parallel for— an exception escaping a parallel region callsstd::terminate(), after the fragment index has already been built.Fix
Single source of truth. New
static bool Deisotoper::isToleranceSupported(tol, ppm)exposes the deisotoper's own limit (non-throwing). BothdeisotopeAndSingleCharge()precondition throws now use it, and external callers consult it instead of re-hardcoding0.1 Da / 100 ppm.ProSE. New
fragment:deisotopeparameter (auto|true|false, defaultauto), modelled on how data-driven engines gate single-charge deconvolution per instrument class (off for low-res). Resolved once inupdateMembers_:falsenever deisotopes;autodeisotopes only for high-res tolerances and skips low-res (with a one-time warning) so the search runs;truealways deisotopes and is rejected up front (ILLEGAL_PARAMETERS) on a low-res tolerance.preprocessSpectra_now takes a plain bool and gates theDeisotopercall onisToleranceSupported(), so it is self-safe regardless of caller and no exception can escape the OpenMP region.SimpleSearchEngine. The sibling
SimpleSearchEngineAlgorithm::preprocessSpectra_had the identical latent abort; it now gates its deisotope call onisToleranceSupported()too — low-res input skips deisotoping instead of aborting.Behaviour
ProSE_1/2/4TOPP tests (fragment tolerance0.1 Da) and SimpleSearchEngine's normal ppm path.Tests
Deisotoper_test:isToleranceSupportedboundary values (ppm/Da).ProSEAlgorithm_test:preprocessSpectra_self-safety (never aborts out-of-range) +fragment:deisotoperesolution / validation.Verification (PRIDE PXD001819
UPS1_50amol_R1, low-res ion-trap CID)auto+0.5 Da: warns, completes, writes a valid.pin(before: abort).-Search:fragment:deisotope true+ low-res: cleanILLEGAL_PARAMETERS(before: abort).0.5 Da: warns, completes (82 MB idXML, 11 s), 0 aborts (before: abort).Note
This generalizes the original per-tool fix after code review (the
0.1 Da / 100 ppmlimit was duplicated, and the sibling SimpleSearchEngine retained the same latent abort). The otherdeisotopeAndSingleChargecallers (TargetedSpectraExtractor,OPXLSpectrumProcessingAlgorithms,SwathQC) are left unchanged but can now adoptDeisotoper::isToleranceSupported()to gate safely.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
auto, enabled, disabled) to control whether deisotoping runs during preprocessing.Bug Fixes
Tests