Skip to content

fix: skip window estimation for MS1 when no MS1 Maps are available - #8308

Merged
timosachsenberg merged 2 commits into
OpenMS:developfrom
singjc:fix/SwathMapMassCorrection
Oct 17, 2025
Merged

timosachsenberg merged 2 commits into
OpenMS:developfrom
singjc:fix/SwathMapMassCorrection

Conversation

@singjc

@singjc singjc commented Oct 16, 2025 •

Copy link
Copy Markdown
Contributor

Description

This fixes and issue during MS1 window estimation logic in SwathMapMassCorrection.cpp if no MS1 map is present. The change ensures that window estimation for MS1 is only performed when MS1 maps are available, preventing potential errors when no MS1 maps are present.

Logic control fix for MS1 window estimation:

  • Updated the condition in SwathMapMassCorrection.cpp to skip MS1 window estimation if there are no MS1 maps.

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

  • Bug Fixes
    • Enhanced stability of mass correction analysis by adding validation checks for MS1 data availability.

@singjc
singjc requested a review from cbielow October 16, 2025 20:34
@coderabbitai

coderabbitai Bot commented Oct 16, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The change adds a defensive guard condition to the MS1 window estimation logic in SwathMapMassCorrection.cpp. The gate now requires ms1_maps to be non-empty before collecting MS1 IM points for window estimation, with an added clarifying comment explaining the new safeguard.

Changes

Cohort / File(s) Summary
MS1 window estimation guard
src/openms/source/ANALYSIS/OPENSWATH/SwathMapMassCorrection.cpp
Extended MS1 window estimation gate to check that ms1_maps is non-empty; added clarifying comment

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • jpfeuffer

Poem

🐰 A guard stands tall with watchful eyes,
"Is ms1_maps here?" it gently cries.
No maps? No problem, skip ahead,
The code now safe, no thread misled!
Simple checks make systems bright,
One small change, forever right. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "fix: skip window estimation for MS1 when no MS1 Maps are available" is directly aligned with the main change in the changeset. The modification to SwathMapMassCorrection.cpp extends the MS1 window estimation gate to check that ms1_maps is non-empty, which is precisely what the title describes. The title is specific and concise, clearly communicating the bug fix and the condition under which it applies, making it easy for teammates to understand the primary intent when reviewing the PR history.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e901f74 and 76a6d42.

📒 Files selected for processing (1)
  • src/openms/source/ANALYSIS/OPENSWATH/SwathMapMassCorrection.cpp (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/openms/**/*.{cpp,h,hpp,cc,cxx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms

Files:

  • src/openms/source/ANALYSIS/OPENSWATH/SwathMapMassCorrection.cpp
🧠 Learnings (1)
📚 Learning: 2025-08-29T19:09:45.997Z
Learnt from: jcharkow
PR: OpenMS/OpenMS#8188
File: src/topp/OpenSwathWorkflow.cpp:1118-1123
Timestamp: 2025-08-29T19:09:45.997Z
Learning: In OpenMS OpenSwathWorkflow, the use_ms1_ion_mobility parameter should be respected when applying estimated MS1 ion mobility extraction windows. The apply_window calls for MS1 ion mobility should check both pasef AND use_ms1_ion_mobility to avoid re-enabling disabled functionality.

Applied to files:

  • src/openms/source/ANALYSIS/OPENSWATH/SwathMapMassCorrection.cpp
🔇 Additional comments (1)
src/openms/source/ANALYSIS/OPENSWATH/SwathMapMassCorrection.cpp (1)

291-292: LGTM! Defensive guard prevents errors when MS1 maps are absent.

The added condition correctly prevents attempting MS1 window estimation when ms1_maps is empty, which would otherwise cause issues when calling fetchSpectrumSwath(ms1_maps, ...) at line 307. This change is consistent with the similar guard at line 566 in correctMZ.

For consistency, verify that the similar MS1 map usage at lines 228-232 handles empty ms1_maps gracefully. While that block is guarded by if (ms1_im_), it doesn't explicitly check if ms1_maps is empty before calling fetchSpectrumSwath(ms1_maps, ...):

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

@timosachsenberg
timosachsenberg merged commit 4b22565 into OpenMS:develop Oct 17, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Feb 5, 2026
5 tasks done
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.

2 participants