Skip to content

Fix charge-conflict continue in MapAlignmentAlgorithmKD::filterCCs_ - #10157

Merged
timosachsenberg merged 4 commits into
OpenMS:developfrom
ManasBagul23:fix/filterccs-charge-conflict-continue
Sep 16, 2026
Merged

timosachsenberg merged 4 commits into
OpenMS:developfrom
ManasBagul23:fix/filterccs-charge-conflict-continue

Conversation

@ManasBagul23

@ManasBagul23 ManasBagul23 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

The continue only escaped the inner charge-scanning loop, so a connected component with mixed charge states never actually got rejected: control fell through to the conflict check with passes still true. Break the inner loop on conflict and continue the outer loop explicitly so mixed-charge CCs are skipped.

Fixes #9050

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

  • Bug Fixes
    • Map alignment now rejects connected components containing conflicting nonzero feature charge states.
    • Components with matching charges or unknown charge values continue to be accepted.
    • Existing validation for component size and features from the same map remains unchanged.

The continue only escaped the inner charge-scanning loop, so a
connected component with mixed charge states never actually got
rejected: control fell through to the conflict check with passes
still true. Break the inner loop on conflict and continue the outer
loop explicitly so mixed-charge CCs are skipped.

Fixes OpenMS#9050
Copilot AI lite review requested due to automatic review settings September 16, 2026 07:27
@github-actions

Copy link
Copy Markdown
Contributor

Welcome @ManasBagul23 and thank you for your contribution to OpenMS! To help us better understand our userbase and contributors, we would appreciate if you could complete the survey at the link below. Completing this survey will help us get to your PR sooner. Thank you for your participation!

Survey

@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 4997d560-9f34-49c6-b67d-c59abb1e5cea

📥 Commits

Reviewing files that changed from the base of the PR and between 72408bd and a3b3200.

📒 Files selected for processing (2)
  • src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmKD.cpp
  • src/tests/class_tests/openms/source/MapAlignmentAlgorithmKD_test.cpp

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

filterCCs_ now rejects connected components that contain multiple nonzero charge states. Components without mixed charges continue through the existing size and same-map conflict checks. Direct tests cover the charge compatibility cases.

Changes

Map alignment filtering

Layer / File(s) Summary
Charge conflict check
src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmKD.cpp, src/tests/class_tests/openms/source/MapAlignmentAlgorithmKD_test.cpp
The filter tracks mixed-charge conflicts, stops the charge scan when detected, and rejects the connected component before same-map conflict processing. Tests cover matching charges, unknown and known charges, and conflicting nonzero charges.

Suggested reviewers: jpfeuffer

Priority: ➖ Normal

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to a3b32

The alignment filter now rejects incompatible nonzero charge components while retaining compatible and unknown-charge cases. No merge-blocking concern remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the fix to charge-conflict handling in MapAlignmentAlgorithmKD::filterCCs_, which is the main change in the pull request.
Linked Issues check ✅ Passed Issue #9050 requires rejection of connected components with multiple nonzero charge states. filterCCs_ now sets charge_conflict, stops charge scanning, and skips the component before the conflict …
Out of Scope Changes check ✅ Passed The changes modify only the charge compatibility logic in MapAlignmentAlgorithmKD::filterCCs_ and add focused automated tests. The changes directly support issue #9050. No unrelated change is identi…
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

A rabbit checks the charges in a row
Mixed sparks now stop before they grow
Matching signs may safely stay
Unknown zero joins the way
Bad pairs hop out of sight
The map aligns just right

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

Copilot AI 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.

🟡 Changes recommended

Add the requested regression test for mixed-charge component exclusion.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Fixes mixed-charge connected components being incorrectly retained during KD-tree map alignment.

Changes:

  • Corrects charge-conflict control flow.
  • Rejects components with multiple nonzero charge states.

Review note: A focused regression test is still needed to verify excluded components contribute no alignment points.

File summaries
File Description
src/openms/source/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithmKD.cpp Corrects mixed-charge component filtering.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +214 to +217
if (charge_conflict)
{
// reject CCs with mixed charge states
continue;

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.

@ManasBagul23 True. If you have a good idea for a small regression test in the corresponding class test, it would be great.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Added a small regression test in MapAlignmentAlgorithmKD_test.cpp: it builds three connected components across two maps and checks that filterCCs_ drops only the one mixing charges 2 and 3, while keeping a same-charge component and one that pairs a known charge with an unknown charge (0). On the previous code all three pass the filter.

ManasBagul23 and others added 3 commits September 16, 2026 16:35
Builds three connected components across two maps and checks that only
the one mixing charge states 2 and 3 is filtered out, while a component
pairing a known charge with an unknown one (0) is kept. Before the fix
all three passed, so mixed-charge components could feed alignment
points into the LOWESS fit.
@timosachsenberg
timosachsenberg merged commit 04504e0 into OpenMS:develop Sep 16, 2026
30 checks passed
timosachsenberg added a commit that referenced this pull request Sep 19, 2026
…10198)

Routine check of recently merged PRs against the 3.6.0 CHANGELOG. Found
five gaps:

- #10162 and #10164 (TOPP-tool-framework split into OpenMS_CLI, and the
  layered installed CMake package) already had prose but no PR citation.
- #10169 (zlib/bzip2/Eigen/SIMDe made private, consumer-visible header
  changes) likewise had prose but no citation.
- #10167 (nightly Bioconda deploy using the nonexistent bioconda-utils
  --pkg-dir flag) had no changelog entry; folded into the existing
  Bioconda CI-fixes bullet.
- #10157 (MapAlignmentAlgorithmKD::filterCCs_ failing to reject connected
  components with conflicting charge states, fixes #9050) and #10171
  (StringUtils whitespace scanners overflowing to negative on inputs
  longer than INT_MAX) had no changelog entry at all.


Claude-Session: https://claude.ai/code/session_01GprMUvPsGqXb3hJqcDmcYA

Co-authored-by: Claude <[email protected]>
@ManasBagul23
ManasBagul23 deleted the fix/filterccs-charge-conflict-continue branch September 19, 2026 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MapAlignmentAlgorithmKD::filterCCs_ logic error: Charge compatibility check fails to reject invalid CCs

4 participants