Repository navigation
refactor(IMTypes): remove IMFormat::MIXED, require ms_level in determ… - #9011
Conversation
…ineIMFormat MIXED was never meaningfully handled by any consumer — all callers either pre-filtered to a single MS level (OpenNuXL), detected from a single spectrum (PeakPickerIM low-mem), or ignored it entirely (PeakPickerIM high-mem). Replace the experiment-level determineIMFormat(MSExperiment) with determineIMFormat(MSExperiment, int ms_level) so callers explicitly state which MS level they care about. This naturally handles files where MS1 has IM_PEAK and MS2 has IM_SPECTRUM (e.g. PASEF data) without needing a special MIXED enum value. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
afdbee0 to
5a79fd4
Compare
📝 WalkthroughWalkthroughThis PR removes Changes
Possibly related issues
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.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/openms/include/OpenMS/IONMOBILITY/IMTypes.h (1)
71-74: Documentation could use formal@paramtag.The description is accurate, but for consistency with OpenMS Doxygen standards, consider adding a formal
@param[in]tag.📝 Documentation improvement
- /// Checks only spectra of the given MS level for their IM format and returns the common type. - /// If no spectra of `@p` ms_level exist or none have IM data, IMFormat::NONE is returned. - /// `@throws` Exception::InvalidValue if spectra of the given MS level have different IM formats - static IMFormat determineIMFormat(const MSExperiment& exp, int ms_level); + /// `@brief` Checks only spectra of the given MS level for their IM format and returns the common type. + /// `@param`[in] exp The experiment to analyze + /// `@param`[in] ms_level The MS level to filter spectra (e.g., 1 for MS1, 2 for MS2) + /// `@return` The common IMFormat for spectra at the given MS level, or IMFormat::NONE if no IM data exists + /// `@throws` Exception::InvalidValue if spectra of the given MS level have different IM formats + static IMFormat determineIMFormat(const MSExperiment& exp, UInt ms_level);As per coding guidelines: "Document all method parameters with
@param[in],@param[out], or@param[in,out]tags."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/include/OpenMS/IONMOBILITY/IMTypes.h` around lines 71 - 74, Add formal Doxygen `@param` tags to the determineIMFormat declaration: document the input parameters by adding "@param[in] exp The MSExperiment to inspect" and "@param[in] ms_level The MS level to check" (leave the existing description and `@throws` unchanged); this ensures determineIMFormat(const MSExperiment& exp, int ms_level) follows the OpenMS Doxygen parameter documentation convention.src/openms/source/IONMOBILITY/IMTypes.cpp (1)
64-69: Consider usingUIntinstead ofintforms_level.
MSSpectrum::getMSLevel()returnsUInt. Usinginthere causes a signed/unsigned comparison at line 69 and deviates from the coding guideline to use OpenMS primitive types.♻️ Proposed signature change
In header and implementation:
- IMFormat IMTypes::determineIMFormat(const MSExperiment& exp, int ms_level) + IMFormat IMTypes::determineIMFormat(const MSExperiment& exp, UInt ms_level)As per coding guidelines: "Use OpenMS primitive types from
OpenMS/CONCEPT/Types.hinstead of standard C++ types."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/IONMOBILITY/IMTypes.cpp` around lines 64 - 69, The function IMTypes::determineIMFormat takes ms_level as int which causes a signed/unsigned comparison with MSSpectrum::getMSLevel() (returns UInt) and violates OpenMS type guidelines; change the parameter type from int to OpenMS::UInt (use the OpenMS primitive UInt from OpenMS/CONCEPT/Types.h) in both the header declaration and the implementation, update any callers to pass UInt (or static_cast<UInt> where appropriate), and include the proper header if not already present so comparisons in the loop (spec.getMSLevel() != ms_level) use matching unsigned types.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/topp/OpenNuXL.cpp`:
- Line 4548: Call to IMTypes::determineIMFormat(spectra, 2) can throw on mixed
MS2 IM annotations; wrap that invocation in a try/catch inside OpenNuXL and
avoid letting it hard-fail by catching the exception, logging a warning that
mixed IM formats were detected for level 2 (include the exception message), and
setting IM_format to a safe default (e.g., IMFormat::NONE or the previous
graceful behavior) so processing continues; reference the
IMTypes::determineIMFormat call and the IMFormat IM_format local variable when
making the change.
In `@src/topp/PeakPickerIM.cpp`:
- Around line 246-247: The IM-format detection is inconsistent between in-memory
and low-memory modes because the low-memory path currently inspects the first
streamed spectrum of any MS level; update the low-memory detection to mirror the
in-memory behavior by restricting detection to MS1 only. Locate the low-memory
branch in PeakPickerIM (the code that calls IMTypes::determineIMFormat on
streamed spectra) and change it so IMTypes::determineIMFormat is invoked with MS
level 1 (or explicitly scan for the first MS1 spectrum from the stream before
calling determineIMFormat) so both modes produce the same IMFormat result.
---
Nitpick comments:
In `@src/openms/include/OpenMS/IONMOBILITY/IMTypes.h`:
- Around line 71-74: Add formal Doxygen `@param` tags to the determineIMFormat
declaration: document the input parameters by adding "@param[in] exp The
MSExperiment to inspect" and "@param[in] ms_level The MS level to check" (leave
the existing description and `@throws` unchanged); this ensures
determineIMFormat(const MSExperiment& exp, int ms_level) follows the OpenMS
Doxygen parameter documentation convention.
In `@src/openms/source/IONMOBILITY/IMTypes.cpp`:
- Around line 64-69: The function IMTypes::determineIMFormat takes ms_level as
int which causes a signed/unsigned comparison with MSSpectrum::getMSLevel()
(returns UInt) and violates OpenMS type guidelines; change the parameter type
from int to OpenMS::UInt (use the OpenMS primitive UInt from
OpenMS/CONCEPT/Types.h) in both the header declaration and the implementation,
update any callers to pass UInt (or static_cast<UInt> where appropriate), and
include the proper header if not already present so comparisons in the loop
(spec.getMSLevel() != ms_level) use matching unsigned types.
🪄 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: f419163c-7558-4449-b6be-1de8bdc7eb63
📒 Files selected for processing (11)
src/openms/include/OpenMS/IONMOBILITY/IMTypes.hsrc/openms/source/FEATUREFINDER/FeatureFinderAlgorithmMetaboIdent.cppsrc/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cppsrc/openms/source/IONMOBILITY/IMTypes.cppsrc/openms/source/METADATA/SpectrumSettings.cppsrc/pyOpenMS/bindings/bind_kernel.cppsrc/pyOpenMS/bindings/bind_misc.cppsrc/tests/class_tests/openms/source/IMTypes_test.cppsrc/tests/class_tests/openms/source/MSSpectrum_test.cppsrc/topp/OpenNuXL.cppsrc/topp/PeakPickerIM.cpp
💤 Files with no reviewable changes (2)
- src/openms/source/METADATA/SpectrumSettings.cpp
- src/pyOpenMS/bindings/bind_kernel.cpp
| std::tuple<IMFormat, DriftTimeUnit> getMS2IMType(const MSExperiment& spectra) | ||
| { | ||
| IMFormat IM_format = IMTypes::determineIMFormat(spectra); | ||
| IMFormat IM_format = IMTypes::determineIMFormat(spectra, 2); |
There was a problem hiding this comment.
Guard determineIMFormat(..., 2) to avoid hard-failing on mixed MS2 IM annotations.
IMTypes::determineIMFormat now throws on mixed formats within the queried level. This unguarded call can terminate OpenNuXL before processing; previously this path degraded gracefully.
Proposed fix
std::tuple<IMFormat, DriftTimeUnit> getMS2IMType(const MSExperiment& spectra)
{
- IMFormat IM_format = IMTypes::determineIMFormat(spectra, 2);
+ IMFormat IM_format = IMFormat::NONE;
+ try
+ {
+ IM_format = IMTypes::determineIMFormat(spectra, 2);
+ }
+ catch (const Exception::InvalidValue&)
+ {
+ OPENMS_LOG_WARN << "Mixed Ion Mobility formats detected in MS2. "
+ << "Ion Mobility values need consistent annotation at one level. "
+ << "Continuing without IM features.\n";
+ return make_tuple(IMFormat::NONE, DriftTimeUnit::NONE);
+ }
DriftTimeUnit IM_unit = DriftTimeUnit::NONE;📝 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.
| IMFormat IM_format = IMTypes::determineIMFormat(spectra, 2); | |
| std::tuple<IMFormat, DriftTimeUnit> getMS2IMType(const MSExperiment& spectra) | |
| { | |
| IMFormat IM_format = IMFormat::NONE; | |
| try | |
| { | |
| IM_format = IMTypes::determineIMFormat(spectra, 2); | |
| } | |
| catch (const Exception::InvalidValue&) | |
| { | |
| OPENMS_LOG_WARN << "Mixed Ion Mobility formats detected in MS2. " | |
| << "Ion Mobility values need consistent annotation at one level. " | |
| << "Continuing without IM features.\n"; | |
| return make_tuple(IMFormat::NONE, DriftTimeUnit::NONE); | |
| } | |
| DriftTimeUnit IM_unit = DriftTimeUnit::NONE; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/topp/OpenNuXL.cpp` at line 4548, Call to
IMTypes::determineIMFormat(spectra, 2) can throw on mixed MS2 IM annotations;
wrap that invocation in a try/catch inside OpenNuXL and avoid letting it
hard-fail by catching the exception, logging a warning that mixed IM formats
were detected for level 2 (include the exception message), and setting IM_format
to a safe default (e.g., IMFormat::NONE or the previous graceful behavior) so
processing continues; reference the IMTypes::determineIMFormat call and the
IMFormat IM_format local variable when making the change.
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (1)
src/topp/OpenNuXL.cpp (1)
4548-4548:⚠️ Potential issue | 🟠 MajorHandle mixed MS2 IM formats here instead of aborting.
IMTypes::determineIMFormat(spectra, 2)now throws when MS2 contains bothIM_PEAKandIM_SPECTRUM. This caller used to degrade gracefully, but it now hard-failsOpenNuXLbefore processing. CatchException::InvalidValuehere, warn, and fall back to{IMFormat::NONE, DriftTimeUnit::NONE}.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/OpenNuXL.cpp` at line 4548, The call to IMTypes::determineIMFormat(spectra, 2) can throw Exception::InvalidValue for mixed MS2 IM formats; wrap this call in a try/catch around the site where IM_format is set (the assignment currently using IM_format = IMTypes::determineIMFormat(spectra, 2)), catch Exception::InvalidValue, log a warning, and set IM_format to a fallback of {IMFormat::NONE, DriftTimeUnit::NONE} so OpenNuXL continues processing instead of aborting.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openms/include/OpenMS/IONMOBILITY/IMTypes.h`:
- Around line 95-98: Add full Doxygen for the new overload of determineIMFormat
in IMTypes.h: add a `@brief` one-line description, a `@param`[in] exp describing the
MSExperiment to scan, a `@param`[in] ms_level noting the precondition that only
spectra of this MS level are considered (and what happens if none exist), a
`@return` that explicitly states IMFormat::NONE is returned when no spectra or no
IM data are found and otherwise the common IMFormat is returned, and retain
`@throws` Exception::InvalidValue when spectra of the given MS level have
different IM formats; ensure the tags are placed immediately above the
declaration of static IMFormat determineIMFormat(const MSExperiment& exp, int
ms_level).
- Around line 95-98: The public API determineIMFormat currently takes a raw int
for ms_level; change its parameter type to OpenMS's UInt (from
OpenMS/CONCEPT/Types.h) and update the doc comment to state that 0 is invalid;
inside the implementation of determineIMFormat(const MSExperiment& exp, UInt
ms_level) add an explicit check for ms_level == 0 and throw
Exception::InvalidValue with a clear message so callers cannot confuse invalid
input with "no spectra at that level", and ensure all references/usages of
determineIMFormat and its declaration in IMTypes.h and related tests/clients are
updated to the new UInt type.
In `@src/openms/source/IONMOBILITY/IMTypes.cpp`:
- Around line 85-95: The function IMTypes::determineIMFormat(const MSExperiment&
exp, int ms_level) must reject non-positive ms_level values at the start: add an
explicit check for ms_level <= 0 and throw Exception::InvalidValue with a clear
message (mentioning the invalid ms_level) instead of allowing the call to
proceed and eventually return IMFormat::NONE; place this guard at the top of the
function before iterating exp.getSpectra() so callers passing bad input are
distinguished from "no spectra at that level."
---
Duplicate comments:
In `@src/topp/OpenNuXL.cpp`:
- Line 4548: The call to IMTypes::determineIMFormat(spectra, 2) can throw
Exception::InvalidValue for mixed MS2 IM formats; wrap this call in a try/catch
around the site where IM_format is set (the assignment currently using IM_format
= IMTypes::determineIMFormat(spectra, 2)), catch Exception::InvalidValue, log a
warning, and set IM_format to a fallback of {IMFormat::NONE,
DriftTimeUnit::NONE} so OpenNuXL continues processing instead of aborting.
🪄 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: 13122fb6-c9d0-452a-b113-46eba269d94f
📒 Files selected for processing (11)
src/openms/include/OpenMS/IONMOBILITY/IMTypes.hsrc/openms/source/FEATUREFINDER/FeatureFinderAlgorithmMetaboIdent.cppsrc/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cppsrc/openms/source/IONMOBILITY/IMTypes.cppsrc/openms/source/METADATA/SpectrumSettings.cppsrc/pyOpenMS/bindings/bind_kernel.cppsrc/pyOpenMS/bindings/bind_misc.cppsrc/tests/class_tests/openms/source/IMTypes_test.cppsrc/tests/class_tests/openms/source/MSSpectrum_test.cppsrc/topp/OpenNuXL.cppsrc/topp/PeakPickerIM.cpp
💤 Files with no reviewable changes (2)
- src/openms/source/METADATA/SpectrumSettings.cpp
- src/pyOpenMS/bindings/bind_kernel.cpp
🚧 Files skipped from review as they are similar to previous changes (5)
- src/topp/PeakPickerIM.cpp
- src/openms/source/FEATUREFINDER/FeatureFinderAlgorithmMetaboIdent.cpp
- src/tests/class_tests/openms/source/MSSpectrum_test.cpp
- src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
- src/pyOpenMS/bindings/bind_misc.cpp
| /// Checks only spectra of the given MS level for their IM format and returns the common type. | ||
| /// If no spectra of @p ms_level exist or none have IM data, IMFormat::NONE is returned. | ||
| /// @throws Exception::InvalidValue if spectra of the given MS level have different IM formats | ||
| static IMFormat determineIMFormat(const MSExperiment& exp, int ms_level); |
There was a problem hiding this comment.
Please complete the Doxygen contract for the new overload.
This is a modified public header API, but the new overload still lacks @brief, @param[in], and @return docs, so the ms_level precondition and return semantics are not fully captured in generated API docs.
📝 Suggested documentation update
- /// Checks only spectra of the given MS level for their IM format and returns the common type.
- /// If no spectra of `@p` ms_level exist or none have IM data, IMFormat::NONE is returned.
- /// `@throws` Exception::InvalidValue if spectra of the given MS level have different IM formats
+ /// `@brief` Checks spectra of a requested MS level for their common IM format.
+ /// `@param`[in] exp Experiment to inspect.
+ /// `@param`[in] ms_level MS level to inspect. Must be greater than 0.
+ /// `@return` The common IM format at `@p` ms_level, or IMFormat::NONE if no such spectra carry IM data.
+ /// `@throws` Exception::InvalidValue If spectra at the requested level use different IM formats.
static IMFormat determineIMFormat(const MSExperiment& exp, int ms_level);As per coding guidelines, "Add Doxygen comments for new public methods and classes, and update relevant documentation when modifying existing functionality" and "Document all method parameters with @param[in], @param[out], or @param[in,out] tags; use @brief as required first line; document return values with @return".
📝 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.
| /// Checks only spectra of the given MS level for their IM format and returns the common type. | |
| /// If no spectra of @p ms_level exist or none have IM data, IMFormat::NONE is returned. | |
| /// @throws Exception::InvalidValue if spectra of the given MS level have different IM formats | |
| static IMFormat determineIMFormat(const MSExperiment& exp, int ms_level); | |
| /// `@brief` Checks spectra of a requested MS level for their common IM format. | |
| /// `@param`[in] exp Experiment to inspect. | |
| /// `@param`[in] ms_level MS level to inspect. Must be greater than 0. | |
| /// `@return` The common IM format at `@p` ms_level, or IMFormat::NONE if no such spectra carry IM data. | |
| /// `@throws` Exception::InvalidValue If spectra at the requested level use different IM formats. | |
| static IMFormat determineIMFormat(const MSExperiment& exp, int ms_level); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/openms/include/OpenMS/IONMOBILITY/IMTypes.h` around lines 95 - 98, Add
full Doxygen for the new overload of determineIMFormat in IMTypes.h: add a
`@brief` one-line description, a `@param`[in] exp describing the MSExperiment to
scan, a `@param`[in] ms_level noting the precondition that only spectra of this MS
level are considered (and what happens if none exist), a `@return` that explicitly
states IMFormat::NONE is returned when no spectra or no IM data are found and
otherwise the common IMFormat is returned, and retain `@throws`
Exception::InvalidValue when spectra of the given MS level have different IM
formats; ensure the tags are placed immediately above the declaration of static
IMFormat determineIMFormat(const MSExperiment& exp, int ms_level).
Use an OpenMS integral type for ms_level.
Line 98 introduces a raw int into a public API even though MS levels are domain-specific. Please switch this to an OpenMS primitive type (typically UInt) and document/validate 0 explicitly; otherwise invalid input is indistinguishable from the “no spectra at that level” case. As per coding guidelines, "Use OpenMS primitive types from OpenMS/CONCEPT/Types.h instead of standard C++ types".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/openms/include/OpenMS/IONMOBILITY/IMTypes.h` around lines 95 - 98, The
public API determineIMFormat currently takes a raw int for ms_level; change its
parameter type to OpenMS's UInt (from OpenMS/CONCEPT/Types.h) and update the doc
comment to state that 0 is invalid; inside the implementation of
determineIMFormat(const MSExperiment& exp, UInt ms_level) add an explicit check
for ms_level == 0 and throw Exception::InvalidValue with a clear message so
callers cannot confuse invalid input with "no spectra at that level", and ensure
all references/usages of determineIMFormat and its declaration in IMTypes.h and
related tests/clients are updated to the new UInt type.
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]>
…ineIMFormat
MIXED was never meaningfully handled by any consumer — all callers either pre-filtered to a single MS level (OpenNuXL), detected from a single spectrum (PeakPickerIM low-mem), or ignored it entirely (PeakPickerIM high-mem).
Replace the experiment-level determineIMFormat(MSExperiment) with determineIMFormat(MSExperiment, int ms_level) so callers explicitly state which MS level they care about. This naturally handles files where MS1 has IM_PEAK and MS2 has IM_SPECTRUM (e.g. PASEF data) without needing a special MIXED enum value.
Description
Checklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
Advanced commands (admins / reviewer only)
Click to expand
/reformat(experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.rebuild jenkinswill retrigger Jenkins-based CI buildsSummary by CodeRabbit