Repository navigation
feat: add IM_PEAK format checks to four TOPP tools - #9018
Conversation
…, FeatureFinderMultiplex, PeakPickerHiRes Resampler, FeatureFinderCentroided, and FeatureFinderMultiplex now error out (INCOMPATIBLE_INPUT_DATA) when given per-peak ion mobility data they cannot handle. PeakPickerHiRes warns but continues, since it has partial IM_PEAK support (intensity-weighted mean IM per picked peak) that works on pre-binned data. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
📝 WalkthroughWalkthroughFour TOPP tools (FeatureFinderCentroided, FeatureFinderMultiplex, PeakPickerHiRes, Resampler) now detect per-peak ion mobility format during startup. Each tool iterates over loaded spectra, identifies if any contain IM_PEAK format, and either logs an error/terminates or emits a warning before proceeding with normal processing. Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/topp/PeakPickerHiRes.cpp (1)
169-185:⚠️ Potential issue | 🟠 MajorMissing IM_PEAK warning in lowmemory processing path.
The IM_PEAK detection and warning is only implemented for the inmemory path (after line 213). When users run with
-processOption lowmemory, thedoLowMemAlgorithmfunction processes data via streaming without any warning about per-peak ion mobility data.This creates inconsistent behavior: the same input file produces a warning with
inmemorybut silently processes withlowmemory, potentially producing incorrect results without user awareness.Suggested approach: Add IM_PEAK check to lowmemory consumer
One option is to add IM check in
PPHiResMzMLConsumer::processSpectrum_with a flag to warn once:class PPHiResMzMLConsumer : public MSDataWritingConsumer { public: PPHiResMzMLConsumer(String filename, const PeakPickerHiRes& pp) : MSDataWritingConsumer(std::move(filename)), - ms_levels_(pp.getParameters().getValue("ms_levels").toIntVector()) + ms_levels_(pp.getParameters().getValue("ms_levels").toIntVector()), + im_peak_warned_(false) { pp_ = pp; } void processSpectrum_(MapType::SpectrumType& s) override { + // Warn once about per-peak ion mobility data + if (!im_peak_warned_) + { + IMFormat im_format = IMTypes::determineIMFormat(s); + if (im_format == IMFormat::IM_PEAK) + { + OPENMS_LOG_WARN << "Warning: Input contains per-peak ion mobility data (IM_PEAK, " + << imPeakTypeToString(s.getIMPeakType()) + << "). PeakPickerHiRes picks in m/z only and reports intensity-weighted " + << "mean ion mobility. This produces incorrect results on unbinned data. " + << "Consider IonMobilityBinning or PeakPickerIM first.\n"; + im_peak_warned_ = true; + } + } if (ms_levels_.empty()) //auto mode // ... rest unchanged } private: PeakPickerHiRes pp_; std::vector<Int> ms_levels_; + bool im_peak_warned_; };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/PeakPickerHiRes.cpp` around lines 169 - 185, doLowMemAlgorithm is missing the IM_PEAK warning because streaming uses PPHiResMzMLConsumer; add the same per-file IM_PEAK detection/warn into the low-memory path by implementing the check inside PPHiResMzMLConsumer::processSpectrum_ (or a helper it calls) so it detects ion-mobility values per peak and emits the existing IM_PEAK warning exactly once. Add a boolean member (e.g., warned_im_peak_) to PPHiResMzMLConsumer to ensure the warning is logged only once and reuse the same warning text/logic used by the inmemory path so behavior is consistent between doLowMemAlgorithm and the in-memory code paths.
🧹 Nitpick comments (4)
src/topp/Resampler.cpp (1)
105-117: Consistent IM_PEAK detection implementation.The implementation correctly follows the same pattern established in FeatureFinderCentroided and FeatureFinderMultiplex. The check is well-placed immediately after loading the experiment.
Same optional style note: consider
\noverstd::endl.Optional: Replace std::endl with \n
OPENMS_LOG_ERROR << "Error: Input contains per-peak ion mobility data (IM_PEAK, " << imPeakTypeToString(spec.getIMPeakType()) << ") which is not supported by Resampler. " - << "Preprocess with IonMobilityBinning or PeakPickerIM first." << std::endl; + << "Preprocess with IonMobilityBinning or PeakPickerIM first.\n";🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/Resampler.cpp` around lines 105 - 117, The log message in Resampler.cpp uses std::endl which flushes the stream unnecessarily; in the IM_PEAK detection block inside the loop that calls IMTypes::determineIMFormat(spec) (and returns INCOMPATIBLE_INPUT_DATA when im_format == IMFormat::IM_PEAK), replace the trailing std::endl with "\n" in the OPENMS_LOG_ERROR call (preserving the existing message and references to imPeakTypeToString and the return behavior) to avoid extra flushes while keeping the same error output.src/topp/FeatureFinderCentroided.cpp (1)
194-206: Well-implemented IM_PEAK detection with early abort.The ion mobility format check correctly identifies unsupported per-peak IM data and provides a clear error message with recommended preprocessing steps. The immediate return on first detection is efficient.
Minor style note: Consider using
\ninstead ofstd::endlfor performance (avoids unnecessary flush). As per coding guidelines: "Avoidstd::endlfor performance; prefer\n".Optional: Replace std::endl with \n
OPENMS_LOG_ERROR << "Error: Input contains per-peak ion mobility data (IM_PEAK, " << imPeakTypeToString(spec.getIMPeakType()) << ") which is not supported by FeatureFinderCentroided. " - << "Preprocess with IonMobilityBinning or PeakPickerIM first." << std::endl; + << "Preprocess with IonMobilityBinning or PeakPickerIM first.\n";🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/FeatureFinderCentroided.cpp` around lines 194 - 206, Replace the std::endl flush in the error logging inside FeatureFinderCentroided (the loop using IMTypes::determineIMFormat and imPeakTypeToString) with a '\n' to avoid an unnecessary stream flush; update the OPENMS_LOG_ERROR call to end with "\n" instead of std::endl so the message remains the same but is more performant.src/topp/PeakPickerHiRes.cpp (1)
215-228: Good warning implementation for inmemory path.The warning appropriately explains that PeakPickerHiRes operates on m/z only and may produce incorrect results on unbinned IM_PEAK data. The
breakensures the warning is emitted only once, which is good UX.Note: This correctly differs from other tools by warning rather than aborting, as PeakPickerHiRes has partial IM_PEAK support per the PR objectives.
Same optional style note: consider
\noverstd::endl.Optional: Replace std::endl with \n
OPENMS_LOG_WARN << "Warning: Input contains per-peak ion mobility data (IM_PEAK, " << imPeakTypeToString(spec.getIMPeakType()) << "). PeakPickerHiRes picks in m/z only and reports intensity-weighted " << "mean ion mobility. This produces incorrect results on unbinned data. " - << "Consider IonMobilityBinning or PeakPickerIM first." << std::endl; + << "Consider IonMobilityBinning or PeakPickerIM first.\n";🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/PeakPickerHiRes.cpp` around lines 215 - 228, The warning loop in PeakPickerHiRes that checks each spectrum in ms_exp_raw uses std::endl; change the final stream terminator to '\n' to avoid flushing the stream unnecessarily: in the loop where IMTypes::determineIMFormat(spec) yields IMFormat::IM_PEAK and you log with OPENMS_LOG_WARN and imPeakTypeToString(spec.getIMPeakType()), replace the std::endl at the end of the message with "\n" and keep the break to warn only once.src/topp/FeatureFinderMultiplex.cpp (1)
258-270: Consistent IM_PEAK detection implementation.The ion mobility format check mirrors the implementation in FeatureFinderCentroided, maintaining consistency across tools. The check is appropriately placed after loading but before processing begins.
Same optional style note applies: consider
\noverstd::endlfor performance.Optional: Replace std::endl with \n
OPENMS_LOG_ERROR << "Error: Input contains per-peak ion mobility data (IM_PEAK, " << imPeakTypeToString(spec.getIMPeakType()) << ") which is not supported by FeatureFinderMultiplex. " - << "Preprocess with IonMobilityBinning or PeakPickerIM first." << std::endl; + << "Preprocess with IonMobilityBinning or PeakPickerIM first.\n";🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/FeatureFinderMultiplex.cpp` around lines 258 - 270, The log line in the IM_PEAK detection loop uses std::endl which flushes the stream unnecessarily; update the OPENMS_LOG_ERROR message inside the loop that checks IMTypes::determineIMFormat(spec) and detects IMFormat::IM_PEAK (the block that calls imPeakTypeToString(spec.getIMPeakType()) and returns INCOMPATIBLE_INPUT_DATA) to terminate the message with '\n' instead of std::endl to avoid the extra flush and improve performance.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/topp/PeakPickerHiRes.cpp`:
- Around line 169-185: doLowMemAlgorithm is missing the IM_PEAK warning because
streaming uses PPHiResMzMLConsumer; add the same per-file IM_PEAK detection/warn
into the low-memory path by implementing the check inside
PPHiResMzMLConsumer::processSpectrum_ (or a helper it calls) so it detects
ion-mobility values per peak and emits the existing IM_PEAK warning exactly
once. Add a boolean member (e.g., warned_im_peak_) to PPHiResMzMLConsumer to
ensure the warning is logged only once and reuse the same warning text/logic
used by the inmemory path so behavior is consistent between doLowMemAlgorithm
and the in-memory code paths.
---
Nitpick comments:
In `@src/topp/FeatureFinderCentroided.cpp`:
- Around line 194-206: Replace the std::endl flush in the error logging inside
FeatureFinderCentroided (the loop using IMTypes::determineIMFormat and
imPeakTypeToString) with a '\n' to avoid an unnecessary stream flush; update the
OPENMS_LOG_ERROR call to end with "\n" instead of std::endl so the message
remains the same but is more performant.
In `@src/topp/FeatureFinderMultiplex.cpp`:
- Around line 258-270: The log line in the IM_PEAK detection loop uses std::endl
which flushes the stream unnecessarily; update the OPENMS_LOG_ERROR message
inside the loop that checks IMTypes::determineIMFormat(spec) and detects
IMFormat::IM_PEAK (the block that calls imPeakTypeToString(spec.getIMPeakType())
and returns INCOMPATIBLE_INPUT_DATA) to terminate the message with '\n' instead
of std::endl to avoid the extra flush and improve performance.
In `@src/topp/PeakPickerHiRes.cpp`:
- Around line 215-228: The warning loop in PeakPickerHiRes that checks each
spectrum in ms_exp_raw uses std::endl; change the final stream terminator to
'\n' to avoid flushing the stream unnecessarily: in the loop where
IMTypes::determineIMFormat(spec) yields IMFormat::IM_PEAK and you log with
OPENMS_LOG_WARN and imPeakTypeToString(spec.getIMPeakType()), replace the
std::endl at the end of the message with "\n" and keep the break to warn only
once.
In `@src/topp/Resampler.cpp`:
- Around line 105-117: The log message in Resampler.cpp uses std::endl which
flushes the stream unnecessarily; in the IM_PEAK detection block inside the loop
that calls IMTypes::determineIMFormat(spec) (and returns INCOMPATIBLE_INPUT_DATA
when im_format == IMFormat::IM_PEAK), replace the trailing std::endl with "\n"
in the OPENMS_LOG_ERROR call (preserving the existing message and references to
imPeakTypeToString and the return behavior) to avoid extra flushes while keeping
the same error output.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f4f134b6-ea54-4eb9-bf28-cc0ca9c2560c
📒 Files selected for processing (4)
src/topp/FeatureFinderCentroided.cppsrc/topp/FeatureFinderMultiplex.cppsrc/topp/PeakPickerHiRes.cppsrc/topp/Resampler.cpp
Add missing changelog entries for commits after the 2026-03-26 sync: - #9019: OpenSwathWorkflow direct Bruker .d (TDF) file input - #9018: IM_PEAK format checks in Resampler, FeatureFinderCentroided, FeatureFinderMultiplex, PeakPickerHiRes - #9003: TMT 32-plex and 35-plex quantitation support - #9007: IMPeakType enum added, IMFormat::CENTROIDED deprecated - #9011: BREAKING IMFormat::MIXED removed; determineIMFormat requires ms_level Co-authored-by: Copilot <[email protected]>
Add missing changelog entries for commits after the 2026-03-26 sync: - #9019: OpenSwathWorkflow direct Bruker .d (TDF) file input - #9018: IM_PEAK format checks in Resampler, FeatureFinderCentroided, FeatureFinderMultiplex, PeakPickerHiRes - #9003: TMT 32-plex and 35-plex quantitation support - #9007: IMPeakType enum added, IMFormat::CENTROIDED deprecated - #9011: BREAKING IMFormat::MIXED removed; determineIMFormat requires ms_level Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Summary
INCOMPATIBLE_INPUT_DATA) when input contains per-peak ion mobility data (IM_PEAK) they cannot properly handleIM_PEAKsupport (intensity-weighted mean IM per picked peak) that works correctly on pre-binned data but produces incorrect results on unbinned 2D dataAll checks report the detected
IMPeakType(im_profile/im_centroided) in the message and suggest preprocessing withIonMobilityBinningorPeakPickerIM.Motivation
With direct Bruker
.dfile reading now supported, tools can receiveIM_PEAKformat data (per-peak ion mobility in FloatDataArrays). Tools that operate in m/z only would silently produce wrong results (merging IM-separated species) or destroy IM metadata. These checks make the limitation explicit.Test plan
INCOMPATIBLE_INPUT_DATA🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes