Skip to content

[TEST] Verify unknown-charge deisotoping matches precursor-free results - #10074

Merged
timosachsenberg merged 4 commits into
developfrom
test/deisotoper-unknown-charge-equivalence
Sep 7, 2026
Merged

timosachsenberg merged 4 commits into
developfrom
test/deisotoper-unknown-charge-equivalence

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Extends the regression tests from #10073 to compare unknown-charge precursors directly with spectra without precursor metadata.

Both algorithms now check retained m/z values and charge arrays in both keep-only and retention modes, including charge 0 on an unrelated retained peak. The existing known-precursor checks remain in place.

This branch is based on #10073 because the connector cannot push to the contributor's fork. Merge #10073 first; this PR will then contain only the additional test assertions.

Validation: C++ test execution is delegated to CI; no local OpenMS build was run.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed deisotoping for spectra with an unknown precursor charge.
    • Peaks are no longer incorrectly discarded when precursor charge information is unavailable.
    • Valid precursor-mass filtering remains applied when charge information is available.
  • Tests

    • Added regression coverage for unknown and valid precursor-charge scenarios.
    • Verified isotope-cluster handling, charge annotations, monoisotopic peaks, unrelated peaks, and integer data arrays.

aliviahossain and others added 4 commits September 6, 2026 22:57
…known

Both deisotopeAndSingleCharge() and deisotopeWithAveragineModel() enabled the
precursor-mass constraint whenever a single precursor was present, computing the
neutral mass from the precursor charge. A charge of 0 (unknown, see Precursor.h)
produced a zero precursor mass, so every positive-mass fragment cluster exceeded
it and was rejected: with keep_only_deisotoped=true the spectrum was emptied,
otherwise peaks were left unprocessed.

Only activate the constraint when a known charge yields a valid positive neutral
mass; otherwise fall back to the configured fragment-charge search. This also
handles negative/invalid masses gracefully.

Adds regression tests covering absent, unknown (charge 0), and known precursor
charge for both algorithms.

Fixes #10067
Add a 3.6.0 Fixes entry for the Deisotoper change so the user-facing
behaviour fix is recorded in the top-level CHANGELOG.

Refs #10067
Address review feedback on #10073: the regression tests only exercised
keep_only_deisotoped=true with a known precursor mass above the fragment
mass, so they never verified the constraint is actually applied for known
charges. Add, for both algorithms:
 - a known charge whose neutral mass is below the cluster, which must
   reject it (empty spectrum with keep_only_deisotoped)
 - a charge-array annotation check on the retained monoisotopic peak
 - a retention-mode case (keep_only_deisotoped=false) confirming an
   unassigned peak is kept

Refs #10067
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 4bcaad61-3ebd-40d8-961e-6064faebe5d1

📥 Commits

Reviewing files that changed from the base of the PR and between d5db5d0 and 17d4387.

📒 Files selected for processing (3)
  • CHANGELOG
  • src/openms/source/PROCESSING/DEISOTOPING/Deisotoper.cpp
  • src/tests/class_tests/openms/source/Deisotoper_test.cpp

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


📝 Walkthrough

Walkthrough

The change gates precursor-mass filtering on valid precursor charge data in both deisotoping methods. Regression tests cover unknown, valid, incompatible, and absent precursor metadata.

Changes

Deisotoping precursor filtering

Layer / File(s) Summary
Gate precursor-mass constraints
src/openms/source/PROCESSING/DEISOTOPING/Deisotoper.cpp, CHANGELOG
Both deisotoping methods now enable precursor-mass filtering only when the charge is known and the calculated neutral mass is positive. The changelog records the fix.
Validate precursor handling
src/tests/class_tests/openms/source/Deisotoper_test.cpp
Regression tests cover absent, unknown-charge, valid, and mass-incompatible precursors. Tests also verify cluster collapse, charge annotations, unrelated peak retention, and integer data arrays.

Suggested reviewers: cbielow

Poem

A rabbit checked the charge at dawn
Unknown? The mass constraint was gone.
Clusters stayed in tidy rows,
Peaks kept all their proper toes.
Tests now guard the spectra’s song.

Merge Risk: ⚪ Minimal · up to 17d43

Unknown precursor charges now behave like spectra without precursor metadata while known valid precursor constraints remain enforced. The change is covered by targeted regression tests and is ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1… 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 regression tests and the behavior they verify: unknown-charge deisotoping matches precursor-free results.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/deisotoper-unknown-charge-equivalence

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.

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

thanks!

@timosachsenberg
timosachsenberg merged commit dac73e0 into develop Sep 7, 2026
36 checks passed
@timosachsenberg
timosachsenberg deleted the test/deisotoper-unknown-charge-equivalence branch September 7, 2026 09:01
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