Skip to content

Add MS1 trace primitives: reader filter push-down, exact isotope envelopes, isotope co-elution - #12

Merged
lfu46 merged 1 commit into
mainfrom
ms1-isotope-primitives
Sep 21, 2026
Merged

lfu46 merged 1 commit into
mainfrom
ms1-isotope-primitives

Conversation

@lfu46

@lfu46 lfu46 commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Three small MS1-level additions: iter_spectra(ms_level=, rt_range=) pushed into SQL on the spectrum cache, isotope_distribution() for exact-composition isotope envelopes (any element), and coelution_score() / isotope_trace_evidence() for trace-level precursor evidence. 195 offline tests pass.

🤖 Generated with Claude Code

…lopes, isotope co-elution

- iter_spectra(ms_level=, rt_range=) on SpectrumCache and MzMLReader. The cache filters in
  SQL (the idx_scans_mslevel index existed but was never used), so an MS1 sweep no longer
  zlib-decodes every MS2 scan. extract_xics pushes its filters down when the reader accepts
  them and keeps the Python-side checks as the guard for any other reader.
  On a 5,386 MS1 / 55,338 MS2 cached run: whole-run MS1 XIC 1.16 s -> 0.21 s, a +/-1 min
  window 1.15 s -> <0.01 s, traces identical.
- mzml_utils.isotopes.isotope_distribution(): isotope envelope of an elemental composition,
  aggregated by nominal mass with the centroid mass of each peak. Element data comes from
  pyteomics.mass.nist_mass, no new dependency. The averagine in deisotope cannot express a
  halogen tag or a heavy label; this can. Agrees with brute-force isotopologue enumeration to
  1e-9 and reproduces a published 4-bromo-Phe peptide envelope.
- coelution_score() and isotope_trace_evidence(): whether a precursor's isotope traces
  co-elute, how the observed envelope fits theory (cosine, not a 3-point Pearson), and whether
  a trace one isotope BELOW the assigned monoisotopic m/z co-elutes with it.

Prompted by Li et al., Angew Chem Int Ed 2026 (BrIS / BrScan-MS1, DOI 10.1002/anie.1708018).
No code from that repository is used.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@lfu46
lfu46 merged commit 7f18db3 into main Sep 21, 2026
@lfu46
lfu46 deleted the ms1-isotope-primitives branch September 21, 2026 16:48
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