Skip to content

Comments

Refactor isotope/adduct models, add pyopenms/ms-deisotope helpers, and extend tests#316

Open
joewandy wants to merge 1 commit intomasterfrom
codex/review-adduct-and-isotope-implementation-mvulud
Open

Refactor isotope/adduct models, add pyopenms/ms-deisotope helpers, and extend tests#316
joewandy wants to merge 1 commit intomasterfrom
codex/review-adduct-and-isotope-implementation-mvulud

Conversation

@joewandy
Copy link
Member

@joewandy joewandy commented Feb 7, 2026

Motivation

  • Improve realism and configurability of isotope and adduct generation and provide robust reverse helpers that integrate with pyopenms and ms_deisotope for deisotoping/de-adducting.
  • Add guarded tests to exercise the OpenMS integration paths and cover edge cases such as empty input and multiple features.

Description

  • Add vimms/Deisotoping.py implementing a pure-Python Deisotoper class and helpers deisotope_with_pyopenms, deadduct_with_pyopenms, and deisotope_with_ms_deisotope for optional integrations.
  • Refactor vimms/Chemicals.py to replace the old carbon-only binomial model with a multi-element isotope convolution pipeline and add configurable parameters (min_prob, max_peaks, max_states, mass_precision), and extend Adducts to accept callable/default priors, adduct profiles, and Dirichlet concentration.
  • Update vimms/Common.py to add NATURAL_ISOTOPES, expanded ADDUCT_TERMS, ADDUCT_PRIOR_POS/ADDUCT_PRIOR_NEG, and ADDUCT_PROFILE_PRESETS used by Adducts.
  • Add tests in tests/test_deisotoping.py that cover isotope distributions, the Python Deisotoper, and additional pyopenms-guarded cases for de-adducting multiple features and empty-input deisotoping.
  • Update pyproject.toml to declare optional integration dependencies ms-deisotope and pyopenms.

Testing

  • Ran pytest -q tests/test_deisotoping.py, which attempted to execute the test file but the run failed with ModuleNotFoundError: No module named 'numpy' raised while loading tests/conftest.py, so the test suite could not complete.
  • The pyopenms-guarded tests are protected with pytest.importorskip("pyopenms") so they will only run in environments that have pyopenms installed.
  • Local commits include the new tests and the refactors so CI with proper dependencies should exercise the new code paths successfully (no further automated test runs succeeded in this environment due to missing runtime deps).

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant