Skip to content

feat: make common mzML exploration easier and safer - #418

Open
arthuc01 wants to merge 3 commits into
pymzml:devfrom
arthuc01:dev
Open

arthuc01 wants to merge 3 commits into
pymzml:devfrom
arthuc01:dev

Conversation

@arthuc01

@arthuc01 arthuc01 commented Nov 9, 2026

Copy link
Copy Markdown

Added a few focused tools that reduce the amount of code needed for everyday mzML analysis:

  • filter spectra by MS level, retention time, or polarity while reading
  • build extracted-ion chromatograms directly from a Reader
  • find the spectrum closest to a retention time without disturbing iteration
  • convert spectra and chromatograms into simple dictionaries for export, logging, or downstream analysis

The new behaviour is backwards compatible. Retention-time information is indexed only when first needed, decoded arrays remain lazy unless requested, and existing Reader access continues to work as before.

I have also fixedd a few small issues:

  • allow empty chromatograms without failing
  • give each new Spectrum its own XML element
  • keep peak reduction within the available data
  • handle native spectrum identifiers correctly
  • close Reader resources more safely
  • provide a sensible version fallback for source checkouts

I have added tests for the new workflows and corrected edge cases.

Validation:

  • 143 tests passed
  • 3 tests skipped
  • 8 subtests passed
  • documentation build completed successfully

chxcja added 3 commits November 9, 2026 16:07
Add a few focused tools that reduce the amount of code needed for everyday mzML analysis:

- filter spectra by MS level, retention time, or polarity while reading
- build extracted-ion chromatograms directly from a Reader
- find the spectrum closest to a retention time without disturbing iteration
- convert spectra and chromatograms into simple dictionaries for export, logging, or downstream analysis

The new behaviour is backwards compatible. Retention-time information is indexed only when first needed, decoded arrays remain lazy unless requested, and existing Reader access continues to work as before.

Also fix several small reliability issues:

- allow empty chromatograms without failing
- give each new Spectrum its own XML element
- keep peak reduction within the available data
- handle native spectrum identifiers correctly
- close Reader resources more safely
- provide a sensible version fallback for source checkouts

Add tests for the new workflows and corrected edge cases.

Validation:

- 143 tests passed
- 3 tests skipped
- 8 subtests passed
- documentation build completed successfully
Keep the new Reader features easier to follow by moving filter validation, spectrum matching, and retention-time indexing decisions into small named helpers without changing their behaviour.

Make the regression tests clearer by comparing two named Spectrum instances and expecting the precise KeyError raised for an unknown indexed spectrum.

Addresses all five open SonarCloud findings on PR 418.
Put the calculated noise estimate before its expected reference value, matching unittest conventions and the rest of the test file.
@sonarqubecloud

Copy link
Copy Markdown

@MKoesters

Copy link
Copy Markdown
Member

Thanks for you contribution!
I will only be able to have a look at this the week after next, but I'll set myself a reminder to come back to this

This branch has not been deployed

No deployments
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