Skip to content

refactor(IMTypes): remove IMFormat::MIXED, require ms_level in determ… - #9011

Merged
timosachsenberg merged 1 commit into
developfrom
refactor/remove-imformat-mixed
Mar 26, 2026
Merged

timosachsenberg merged 1 commit into
developfrom
refactor/remove-imformat-mixed

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor

…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

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

How can I get additional information on failed tests during CI

Click to expand If your PR is failing you can check out

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.
  • setting the label "NoJenkins" will skip tests for this PR on jenkins (saves resources e.g., on edits that do not affect tests)
  • commenting with rebuild jenkins will retrigger Jenkins-based CI builds

⚠️ Note: Once you opened a PR try to minimize the number of pushes to it as every push will trigger CI (automated builds and test) and is rather heavy on our infrastructure (e.g., if several pushes per day are performed).

Summary by CodeRabbit

  • Refactor
    • Ion mobility format detection now evaluates spectra per MS level (e.g., MS1 vs MS2) rather than across the whole experiment.
    • The "MIXED" ion mobility format value has been removed; conflicting formats within the same MS level now raise an error.
    • Python bindings and tests updated to accept and validate an explicit MS level when querying ion mobility format.

…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]>
@timosachsenberg
timosachsenberg force-pushed the refactor/remove-imformat-mixed branch from afdbee0 to 5a79fd4 Compare March 26, 2026 16:31
@coderabbitai

coderabbitai Bot commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR removes IMFormat::MIXED, changes IMTypes::determineIMFormat() to accept an ms_level and only considers spectra at that level, and updates call sites, tests, Python bindings, and related IM-format handling to this per–MS-level behavior and new error semantics.

Changes

Cohort / File(s) Summary
Core Ion Mobility Types
src/openms/include/OpenMS/IONMOBILITY/IMTypes.h, src/openms/source/IONMOBILITY/IMTypes.cpp
Removed IMFormat::MIXED; determineIMFormat() now takes int ms_level and evaluates only spectra at that MS level; conflicting formats within that level now throw Exception::InvalidValue (no MIXED return).
Spectrum / Metadata
src/openms/source/METADATA/SpectrumSettings.cpp, src/tests/class_tests/openms/source/MSSpectrum_test.cpp
Removed MIXED rejection logic when setting IM format; tests updated to no longer expect MIXED-related exceptions and to validate valid assignments.
Consumers / Algorithms
src/openms/source/FEATUREFINDER/FeatureFinderAlgorithmMetaboIdent.cpp, src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp, src/topp/OpenNuXL.cpp, src/topp/PeakPickerIM.cpp
Calls to determineIMFormat() updated to pass MS level (typically 1 or 2 as appropriate); removed branches that handled IMFormat::MIXED and adjusted IM-aware control flow accordingly.
Bindings
src/pyOpenMS/bindings/bind_kernel.cpp, src/pyOpenMS/bindings/bind_misc.cpp
Removed MIXED from Python IMFormat export; IMTypes.determineIMFormat(exp) binding changed to IMTypes.determineIMFormat(exp, ms_level) (module wrapper updated).
Tests
src/tests/class_tests/openms/source/IMTypes_test.cpp
Updated tests to call new determineIMFormat(exp, ms_level) overload; adjusted expectations to per–MS-level results and to expect exceptions for mixed formats within a single MS level.

Possibly related issues

Possibly related PRs

Suggested labels

enhancement, Review effort [1-5]: 3

Suggested reviewers

  • alhigaylan
  • singjc
  • poshul

Poem

🐇 I nibble code on moonlit nights,
I hop through spectra, set things right.
MIXED is gone, each level sings—
Small hops, neat changes, clearer things.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main refactoring: removing IMFormat::MIXED enum and requiring ms_level parameter in determineIMFormat function.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/remove-imformat-mixed

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/openms/include/OpenMS/IONMOBILITY/IMTypes.h (1)

71-74: Documentation could use formal @param tag.

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 using UInt instead of int for ms_level.

MSSpectrum::getMSLevel() returns UInt. Using int here 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.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/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

📥 Commits

Reviewing files that changed from the base of the PR and between 3f8956f and afdbee0.

📒 Files selected for processing (11)
  • src/openms/include/OpenMS/IONMOBILITY/IMTypes.h
  • src/openms/source/FEATUREFINDER/FeatureFinderAlgorithmMetaboIdent.cpp
  • src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
  • src/openms/source/IONMOBILITY/IMTypes.cpp
  • src/openms/source/METADATA/SpectrumSettings.cpp
  • src/pyOpenMS/bindings/bind_kernel.cpp
  • src/pyOpenMS/bindings/bind_misc.cpp
  • src/tests/class_tests/openms/source/IMTypes_test.cpp
  • src/tests/class_tests/openms/source/MSSpectrum_test.cpp
  • src/topp/OpenNuXL.cpp
  • src/topp/PeakPickerIM.cpp
💤 Files with no reviewable changes (2)
  • src/openms/source/METADATA/SpectrumSettings.cpp
  • src/pyOpenMS/bindings/bind_kernel.cpp

Comment thread src/topp/OpenNuXL.cpp
std::tuple<IMFormat, DriftTimeUnit> getMS2IMType(const MSExperiment& spectra)
{
IMFormat IM_format = IMTypes::determineIMFormat(spectra);
IMFormat IM_format = IMTypes::determineIMFormat(spectra, 2);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Suggested change
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.

Comment thread src/topp/PeakPickerIM.cpp Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (1)
src/topp/OpenNuXL.cpp (1)

4548-4548: ⚠️ Potential issue | 🟠 Major

Handle mixed MS2 IM formats here instead of aborting.

IMTypes::determineIMFormat(spectra, 2) now throws when MS2 contains both IM_PEAK and IM_SPECTRUM. This caller used to degrade gracefully, but it now hard-fails OpenNuXL before processing. Catch Exception::InvalidValue here, 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

📥 Commits

Reviewing files that changed from the base of the PR and between afdbee0 and 5a79fd4.

📒 Files selected for processing (11)
  • src/openms/include/OpenMS/IONMOBILITY/IMTypes.h
  • src/openms/source/FEATUREFINDER/FeatureFinderAlgorithmMetaboIdent.cpp
  • src/openms/source/FEATUREFINDER/FeatureFinderIdentificationAlgorithm.cpp
  • src/openms/source/IONMOBILITY/IMTypes.cpp
  • src/openms/source/METADATA/SpectrumSettings.cpp
  • src/pyOpenMS/bindings/bind_kernel.cpp
  • src/pyOpenMS/bindings/bind_misc.cpp
  • src/tests/class_tests/openms/source/IMTypes_test.cpp
  • src/tests/class_tests/openms/source/MSSpectrum_test.cpp
  • src/topp/OpenNuXL.cpp
  • src/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

Comment on lines +95 to +98
/// 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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
/// 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).

⚠️ Potential issue | 🟡 Minor

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.

@timosachsenberg
timosachsenberg merged commit 4e73a9f into develop Mar 26, 2026
41 checks passed
@timosachsenberg
timosachsenberg deleted the refactor/remove-imformat-mixed branch March 26, 2026 19:11
github-actions Bot pushed a commit that referenced this pull request Mar 28, 2026
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]>
timosachsenberg pushed a commit that referenced this pull request Mar 28, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant