mzmlpy 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. mzmlpy-0.3.0/.github/copilot-instructions.md +66 -0
  2. mzmlpy-0.3.0/.github/workflows/python-package.yml +53 -0
  3. mzmlpy-0.3.0/.github/workflows/python-publish.yml +37 -0
  4. mzmlpy-0.3.0/.gitignore +120 -0
  5. mzmlpy-0.3.0/CLAUDE.md +70 -0
  6. mzmlpy-0.3.0/HISTORY.md +25 -0
  7. mzmlpy-0.3.0/MANIFEST.in +12 -0
  8. mzmlpy-0.3.0/PKG-INFO +75 -0
  9. mzmlpy-0.3.0/README.md +55 -0
  10. mzmlpy-0.3.0/docs/api/chromatogram.md +3 -0
  11. mzmlpy-0.3.0/docs/api/constants.md +11 -0
  12. mzmlpy-0.3.0/docs/api/data-processing.md +7 -0
  13. mzmlpy-0.3.0/docs/api/file-description.md +15 -0
  14. mzmlpy-0.3.0/docs/api/instrument.md +15 -0
  15. mzmlpy-0.3.0/docs/api/lookup.md +5 -0
  16. mzmlpy-0.3.0/docs/api/metadata.md +33 -0
  17. mzmlpy-0.3.0/docs/api/mzml.md +3 -0
  18. mzmlpy-0.3.0/docs/api/params.md +11 -0
  19. mzmlpy-0.3.0/docs/api/precursor.md +15 -0
  20. mzmlpy-0.3.0/docs/api/spectrum.md +15 -0
  21. mzmlpy-0.3.0/docs/getting-started.md +171 -0
  22. mzmlpy-0.3.0/docs/index.md +44 -0
  23. mzmlpy-0.3.0/justfile +47 -0
  24. mzmlpy-0.3.0/logo.png +0 -0
  25. mzmlpy-0.3.0/mkdocs.yml +46 -0
  26. mzmlpy-0.3.0/pyproject.toml +67 -0
  27. mzmlpy-0.3.0/src/mzmlpy/__init__.py +77 -0
  28. mzmlpy-0.3.0/src/mzmlpy/constants.py +320 -0
  29. mzmlpy-0.3.0/src/mzmlpy/content.py +200 -0
  30. mzmlpy-0.3.0/src/mzmlpy/decoder.py +92 -0
  31. mzmlpy-0.3.0/src/mzmlpy/elems/__init__.py +32 -0
  32. mzmlpy-0.3.0/src/mzmlpy/elems/data_processing.py +47 -0
  33. mzmlpy-0.3.0/src/mzmlpy/elems/dtree_wrapper.py +176 -0
  34. mzmlpy-0.3.0/src/mzmlpy/elems/file_desc.py +179 -0
  35. mzmlpy-0.3.0/src/mzmlpy/elems/instrument_config.py +91 -0
  36. mzmlpy-0.3.0/src/mzmlpy/elems/params.py +55 -0
  37. mzmlpy-0.3.0/src/mzmlpy/elems/referenceable_param_group.py +21 -0
  38. mzmlpy-0.3.0/src/mzmlpy/elems/run.py +50 -0
  39. mzmlpy-0.3.0/src/mzmlpy/elems/sample.py +26 -0
  40. mzmlpy-0.3.0/src/mzmlpy/elems/scan_setting.py +56 -0
  41. mzmlpy-0.3.0/src/mzmlpy/elems/software.py +25 -0
  42. mzmlpy-0.3.0/src/mzmlpy/file_classes/__init__.py +15 -0
  43. mzmlpy-0.3.0/src/mzmlpy/file_classes/interface.py +27 -0
  44. mzmlpy-0.3.0/src/mzmlpy/file_classes/standardGzip.py +169 -0
  45. mzmlpy-0.3.0/src/mzmlpy/file_classes/standardMzml.py +398 -0
  46. mzmlpy-0.3.0/src/mzmlpy/file_classes/xml_tuple.py +22 -0
  47. mzmlpy-0.3.0/src/mzmlpy/file_interface.py +232 -0
  48. mzmlpy-0.3.0/src/mzmlpy/lookup.py +188 -0
  49. mzmlpy-0.3.0/src/mzmlpy/py.typed +0 -0
  50. mzmlpy-0.3.0/src/mzmlpy/regex_patterns.py +13 -0
  51. mzmlpy-0.3.0/src/mzmlpy/run.py +225 -0
  52. mzmlpy-0.3.0/src/mzmlpy/spectra.py +979 -0
  53. mzmlpy-0.3.0/src/mzmlpy/util.py +5 -0
  54. mzmlpy-0.3.0/tests/data/example.mzML +337 -0
  55. mzmlpy-0.3.0/tests/data/example.mzML.gz +0 -0
  56. mzmlpy-0.3.0/tests/test_chromatogram.py +38 -0
  57. mzmlpy-0.3.0/tests/test_data_processing.py +33 -0
  58. mzmlpy-0.3.0/tests/test_docs.py +7 -0
  59. mzmlpy-0.3.0/tests/test_file_description.py +54 -0
  60. mzmlpy-0.3.0/tests/test_instrument_configuration.py +36 -0
  61. mzmlpy-0.3.0/tests/test_referenceable_param_group.py +34 -0
  62. mzmlpy-0.3.0/tests/test_sample_list.py +14 -0
  63. mzmlpy-0.3.0/tests/test_scan_settings.py +32 -0
  64. mzmlpy-0.3.0/tests/test_software_list.py +36 -0
  65. mzmlpy-0.3.0/tests/test_spectra.py +102 -0
  66. mzmlpy-0.3.0/uv.lock +1011 -0
@@ -0,0 +1,66 @@
1
+ ## Copilot Instructions
2
+
3
+ ### VERY IMPORTANT INSTRUCTIONS
4
+
5
+ USE THE JUSTFILE WHENEVER POSSIBLE. IF THERE IS NOT A JUSTFILE COMMAND CHECK AGAIN... IF THERE IS STILL NOT A FUCKING JUST COMAND... USE UV PACKAGE MANAGER! THIS IS ALREADY INSTALLED AND AVAILABLE. DO NOT, UNDER ANY CIRCUMSTANCES, INSTALL ANY DEPENDENCIES USING NPM, YARN, PIP, GEM, OR ANY OTHER PACKAGE MANAGER. AND NEVER USE PYHTON / PYTEST DIRECTLY!!! ALWAYS USE JUST FOR AVAILABLE COMMANDS AND ONLY FALL BACK TO UV IF THERE IS NO JUST COMMAND AVAILABLE.
6
+
7
+ ### Available Tools
8
+ - Use `just` for all project commands. See `just --list` for available commands.
9
+ - Use `uv` for package management and running scripts. See `uv --help` for usage.
10
+ - Use `git` for version control.
11
+ - Use ty for type checking. `uv run ty check src/ tests/` or `just ty`
12
+ - Use pytest for testing. `uv run pytest tests/` or `just test`
13
+ - use ruff for linting and formatting. `uv run ruff check src/ tests/` or `just lint` and `uv run ruff format src/` or `just format`
14
+
15
+ ### VERY IMPORTANT INSTRUCTIONS
16
+
17
+ USE THE JUSTFILE WHENEVER POSSIBLE. IF THERE IS NOT A JUSTFILE COMMAND CHECK AGAIN... IF THERE IS STILL NOT A FUCKING JUST COMAND... USE UV PACKAGE MANAGER! THIS IS ALREADY INSTALLED AND AVAILABLE. DO NOT, UNDER ANY CIRCUMSTANCES, INSTALL ANY DEPENDENCIES USING NPM, YARN, PIP, GEM, OR ANY OTHER PACKAGE MANAGER. AND NEVER USE PYHTON / PYTEST DIRECTLY!!! ALWAYS USE JUST FOR AVAILABLE COMMANDS AND ONLY FALL BACK TO UV IF THERE IS NO JUST COMMAND AVAILABLE.
18
+
19
+ ### Code Style & Philosophy
20
+
21
+ - **Type everything**: Use comprehensive type hints (NDArray, Literal, Protocol, Self, etc.). Generic types should be specific. Use pyhton 3.12 features where applicable. Match-case statements preferred over if-elif chains for discrete values >= 3. Use list, tuple, set over List, Tuple, Set where possible. Dont use Union or Optional, use | operator.
22
+ - **Immutability**: Prefer frozen dataclasses with `slots=True` and functional transformations over mutation. Though this is not absolute.
23
+ - **Explicit over implicit**: Clear, descriptive names. No magic. If there's a performance trade-off, make it obvious.
24
+ - **Simplicity**: Simple, readable code over clever one-liners. Break complex logic into smaller functions.
25
+
26
+ Test do not need to be strongly typed but should still use type hints where reasonable. dont worry about exhaustive typing in tests, nor running ruff/ty on tests.
27
+
28
+ ### VERY IMPORTANT INSTRUCTIONS
29
+
30
+ USE THE JUSTFILE WHENEVER POSSIBLE. IF THERE IS NOT A JUSTFILE COMMAND CHECK AGAIN... IF THERE IS STILL NOT A FUCKING JUST COMAND... USE UV PACKAGE MANAGER! THIS IS ALREADY INSTALLED AND AVAILABLE. DO NOT, UNDER ANY CIRCUMSTANCES, INSTALL ANY DEPENDENCIES USING NPM, YARN, PIP, GEM, OR ANY OTHER PACKAGE MANAGER. AND NEVER USE PYHTON / PYTEST DIRECTLY!!! ALWAYS USE JUST FOR AVAILABLE COMMANDS AND ONLY FALL BACK TO UV IF THERE IS NO JUST COMMAND AVAILABLE.
31
+
32
+ ### Documentation
33
+
34
+ - Concise docstrings - no novels
35
+ - Document the "why" when non-obvious, not the "what"
36
+ - Type hints are documentation - don't repeat them in docstrings. Methods/Function should be able to get by with no/minimal docstrings if types are clear.
37
+ - Use `Raises` section in docstrings for exceptions
38
+ - No placeholder comments like "TODO: implement later" - use `raise NotImplementedError("reason")`
39
+
40
+ ### Response Style
41
+
42
+ - Get to the point
43
+ - Show code, minimal explanation
44
+ - If I'm wrong, tell me directly
45
+ - Assume I know Python well - no hand-holding
46
+
47
+ ### VERY IMPORTANT INSTRUCTIONS
48
+
49
+ USE THE JUSTFILE WHENEVER POSSIBLE. IF THERE IS NOT A JUSTFILE COMMAND CHECK AGAIN... IF THERE IS STILL NOT A FUCKING JUST COMAND... USE UV PACKAGE MANAGER! THIS IS ALREADY INSTALLED AND AVAILABLE. DO NOT, UNDER ANY CIRCUMSTANCES, INSTALL ANY DEPENDENCIES USING NPM, YARN, PIP, GEM, OR ANY OTHER PACKAGE MANAGER. AND NEVER USE PYHTON / PYTEST DIRECTLY!!! ALWAYS USE JUST FOR AVAILABLE COMMANDS AND ONLY FALL BACK TO UV IF THERE IS NO JUST COMMAND AVAILABLE.
50
+
51
+ ### VERY IMPORTANT INSTRUCTIONS
52
+
53
+ USE THE JUSTFILE WHENEVER POSSIBLE. IF THERE IS NOT A JUSTFILE COMMAND CHECK AGAIN... IF THERE IS STILL NOT A FUCKING JUST COMAND... USE UV PACKAGE MANAGER! THIS IS ALREADY INSTALLED AND AVAILABLE. DO NOT, UNDER ANY CIRCUMSTANCES, INSTALL ANY DEPENDENCIES USING NPM, YARN, PIP, GEM, OR ANY OTHER PACKAGE MANAGER. AND NEVER USE PYHTON / PYTEST DIRECTLY!!! ALWAYS USE JUST FOR AVAILABLE COMMANDS AND ONLY FALL BACK TO UV IF THERE IS NO JUST COMMAND AVAILABLE.
54
+
55
+ ### VERY IMPORTANT INSTRUCTIONS
56
+
57
+ USE THE JUSTFILE WHENEVER POSSIBLE. IF THERE IS NOT A JUSTFILE COMMAND CHECK AGAIN... IF THERE IS STILL NOT A FUCKING JUST COMAND... USE UV PACKAGE MANAGER! THIS IS ALREADY INSTALLED AND AVAILABLE. DO NOT, UNDER ANY CIRCUMSTANCES, INSTALL ANY DEPENDENCIES USING NPM, YARN, PIP, GEM, OR ANY OTHER PACKAGE MANAGER. AND NEVER USE PYHTON / PYTEST DIRECTLY!!! ALWAYS USE JUST FOR AVAILABLE COMMANDS AND ONLY FALL BACK TO UV IF THERE IS NO JUST COMMAND AVAILABLE.
58
+
59
+ ### VERY IMPORTANT INSTRUCTIONS
60
+
61
+ USE THE JUSTFILE WHENEVER POSSIBLE. IF THERE IS NOT A JUSTFILE COMMAND CHECK AGAIN... IF THERE IS STILL NOT A FUCKING JUST COMAND... USE UV PACKAGE MANAGER! THIS IS ALREADY INSTALLED AND AVAILABLE. DO NOT, UNDER ANY CIRCUMSTANCES, INSTALL ANY DEPENDENCIES USING NPM, YARN, PIP, GEM, OR ANY OTHER PACKAGE MANAGER. AND NEVER USE PYHTON / PYTEST DIRECTLY!!! ALWAYS USE JUST FOR AVAILABLE COMMANDS AND ONLY FALL BACK TO UV IF THERE IS NO JUST COMMAND AVAILABLE.
62
+
63
+ ### VERY IMPORTANT INSTRUCTIONS
64
+
65
+ USE THE JUSTFILE WHENEVER POSSIBLE. IF THERE IS NOT A JUSTFILE COMMAND CHECK AGAIN... IF THERE IS STILL NOT A FUCKING JUST COMAND... USE UV PACKAGE MANAGER! THIS IS ALREADY INSTALLED AND AVAILABLE. DO NOT, UNDER ANY CIRCUMSTANCES, INSTALL ANY DEPENDENCIES USING NPM, YARN, PIP, GEM, OR ANY OTHER PACKAGE MANAGER. AND NEVER USE PYHTON / PYTEST DIRECTLY!!! ALWAYS USE JUST FOR AVAILABLE COMMANDS AND ONLY FALL BACK TO UV IF THERE IS NO JUST COMMAND AVAILABLE.
66
+
@@ -0,0 +1,53 @@
1
+ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3
+
4
+ name: Python package
5
+
6
+ on:
7
+ push:
8
+ paths:
9
+ - 'src/**'
10
+ - 'tests/**'
11
+ workflow_dispatch:
12
+
13
+ jobs:
14
+ build:
15
+
16
+ runs-on: ubuntu-latest
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ python-version: ["3.12"]
21
+
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ - name: Set up Python ${{ matrix.python-version }}
25
+ uses: actions/setup-python@v5
26
+ with:
27
+ python-version: ${{ matrix.python-version }}
28
+ - name: Install uv
29
+ uses: astral-sh/setup-uv@v4
30
+ - name: Install just
31
+ uses: extractions/setup-just@v2
32
+ - name: Install dependencies
33
+ run: just install
34
+ - name: Lint with ruff
35
+ run: just lint
36
+ - name: Type check with ty
37
+ run: just check
38
+ - name: Test with pytest
39
+ run: just test-cov codecov-tests
40
+ - name: Upload coverage reports to Codecov
41
+ uses: codecov/codecov-action@v5
42
+ with:
43
+ token: ${{ secrets.CODECOV_TOKEN }}
44
+ slug: tacular-omics/mzmlpy
45
+ fail_ci_if_error: false
46
+ - name: Upload test results to Codecov
47
+ if: ${{ !cancelled() }}
48
+ uses: codecov/codecov-action@v5
49
+ with:
50
+ token: ${{ secrets.CODECOV_TOKEN }}
51
+ slug: tacular-omics/mzmlpy
52
+ report_type: test_results
53
+ fail_ci_if_error: false
@@ -0,0 +1,37 @@
1
+ # This workflow will upload a Python Package using Twine when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3
+
4
+ # This workflow uses actions that are not certified by GitHub.
5
+ # They are provided by a third-party and are governed by
6
+ # separate terms of service, privacy policy, and support
7
+ # documentation.
8
+
9
+ name: Upload Python Package
10
+
11
+ on:
12
+ release:
13
+ types: [published]
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ jobs:
19
+ deploy:
20
+
21
+ runs-on: ubuntu-latest
22
+
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ - name: Set up Python
26
+ uses: actions/setup-python@v5
27
+ with:
28
+ python-version: '3.x'
29
+ - name: Install uv
30
+ uses: astral-sh/setup-uv@v4
31
+ - name: Build package with uv
32
+ run: uv build
33
+ - name: Publish package
34
+ uses: pypa/gh-action-pypi-publish@release/v1
35
+ with:
36
+ user: __token__
37
+ password: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,120 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ tmp.py
10
+
11
+
12
+ # Distribution / packaging
13
+ .Python
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ wheels/
26
+ share/python-wheels/
27
+ *.egg-info/
28
+ .installed.cfg
29
+ *.egg
30
+ MANIFEST
31
+
32
+ # PyInstaller
33
+ # Usually these files are written by a python script from a template
34
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
35
+ *.manifest
36
+ *.spec
37
+
38
+ # Installer logs
39
+ pip-log.txt
40
+ pip-delete-this-directory.txt
41
+
42
+ # Unit test / coverage reports
43
+ htmlcov/
44
+ .tox/
45
+ .nox/
46
+ .coverage
47
+ .coverage.*
48
+ .cache
49
+ nosetests.xml
50
+ coverage.xml
51
+ *.cover
52
+ *.py,cover
53
+ .hypothesis/
54
+ .pytest_cache/
55
+ cover/
56
+
57
+ # Translations
58
+ *.mo
59
+ *.pot
60
+
61
+ # Django stuff:
62
+ *.log
63
+ local_settings.py
64
+ db.sqlite3
65
+ db.sqlite3-journal
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # MkDocs
78
+ site/
79
+
80
+ # PyBuilder
81
+ target/
82
+
83
+ # Jupyter Notebook
84
+ .ipynb_checkpoints
85
+
86
+ # IPython
87
+ profile_default/
88
+ ipython_config.py
89
+
90
+ # pyenv
91
+ .python-version
92
+
93
+ # pipenv
94
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
96
+ # with no cross-platform support, pipenv may install dependencies that don't work, or not
97
+ # install all needed dependencies.
98
+ #Pipfile.lock
99
+
100
+ # poetry
101
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
102
+ # This is especially recommended for binary packages to ensure reproducible builds.
103
+ # However, if you need to use different versions of dependencies on different environments,
104
+ # you may want to ignore it.
105
+ #poetry.lock
106
+
107
+ # uv
108
+ .venv
109
+
110
+ # ruff
111
+ .ruff_cache/
112
+
113
+ # mypy
114
+ .mypy_cache/
115
+ .dmypy.json
116
+ dmypy.json
117
+
118
+ # editors
119
+ .vscode/
120
+ .idea/
mzmlpy-0.3.0/CLAUDE.md ADDED
@@ -0,0 +1,70 @@
1
+ # CLAUDE.md
2
+
3
+ ## Project
4
+
5
+ **mzmlpy** — lightweight Python library for parsing mzML mass spectrometry files. Exposes a type-safe, lazy-loading API for spectra, chromatograms, and file metadata. Python 3.12+ only.
6
+
7
+ Current version: **0.2.0** (Beta). Published on PyPI.
8
+
9
+ ## Commands
10
+
11
+ ```bash
12
+ just lint # ruff check src
13
+ just format # ruff isort + format src + tests
14
+ just ty # ty type checker (excludes src/mzmlpy/decoder.py)
15
+ just check # lint + ty + test
16
+ just test # pytest tests/
17
+ just test-cov # pytest with coverage report
18
+ just docs # mkdocs serve on localhost:8001
19
+ just docs-build # mkdocs build to site/
20
+ just install # uv sync
21
+ ```
22
+
23
+ Always run `just lint` and `just test` after any code change.
24
+
25
+ ## Architecture
26
+
27
+ ```
28
+ src/mzmlpy/
29
+ ├── run.py # Mzml — main reader class, context manager, lazy XML parsing
30
+ ├── spectra.py # Spectrum, Chromatogram, and all mixin/helper classes
31
+ ├── constants.py # All StrEnum accessions + ION_MOBILITIES constant set
32
+ ├── decoder.py # MSDecoder — zlib/zstd/numpress decompression (excluded from ty)
33
+ ├── lookup.py # SpectrumLookup, ChromatogramLookup — index/id/slice access
34
+ ├── file_interface.py # File format routing (.mzML, .mzML.gz)
35
+ ├── content.py # CVElement
36
+ ├── elems/ # Metadata dataclasses (FileDescription, InstrumentConfiguration, etc.)
37
+ └── py.typed # PEP 561 marker
38
+ ```
39
+
40
+ ### Key design patterns
41
+
42
+ - **Frozen dataclasses** — all data classes use `@dataclass(frozen=True)`; use `cached_property` for computed values
43
+ - **Mixin composition** — `Spectrum` inherits from `_BinaryDataArrayMixin`, `_ScanListMixin`, `_PrecursorListMixin`, `_ProductListMixin`; never duplicate logic across these
44
+ - **Lazy binary decoding** — `BinaryDataArray.data` decodes on every call (not cached); callers should store result if reusing
45
+ - **XML namespaced lookups** — all `element.find()` calls use `self.ns` prefix (e.g. `f"./{self.ns}scanList"`)
46
+ - **Warnings over exceptions** for ambiguous multi-scan/multi-window cases (e.g. `lower_mz` on a spectrum with multiple scans)
47
+
48
+ ## Dependencies
49
+
50
+ - **Runtime:** `numpy>=1.26.0` only
51
+ - **Optional:** `pynumpress>=0.0.4` (install via `pip install mzmlpy[numpress]`)
52
+ - **Dev:** pytest, ruff, ty, pyupgrade, zstd, pytest-cov, mkdocs, mkdocs-material, mkdocstrings[python]
53
+ - **Build:** uv + hatchling
54
+
55
+ ## Code style
56
+
57
+ - Line length: 120
58
+ - Type annotations required on all public API
59
+ - Google-style docstrings
60
+ - `StrEnum` for all CV accession constants — never hardcode accession strings outside `constants.py` (there are some legacy exceptions in `spectra.py` that should be migrated)
61
+ - `Literal[...]` return types preferred over plain `str` for known-set values (e.g. `polarity`, `spectrum_type`)
62
+
63
+ ## Docs
64
+
65
+ MkDocs + Material theme + mkdocstrings. All 34 exported public classes have API reference pages under `docs/api/`. Config in `mkdocs.yml` — `inherited_members: true` flattens mixin members, `signature_crossrefs: true` makes type annotations into links.
66
+
67
+ ## Tests
68
+
69
+ Test data: `tests/data/example.mzML` and `tests/data/example.mzML.gz` (4 spectra, 1 chromatogram).
70
+ Tests are parametrized over both files. No mocking — tests run against real XML.
@@ -0,0 +1,25 @@
1
+ # History
2
+
3
+ ## 0.2.0 (2026-03-16)
4
+
5
+ **Breaking changes:**
6
+
7
+ * Renamed `lower_limit` / `upper_limit` → `lower_mz` / `upper_mz` on `ScanWindow`, `Scan`, and `Spectrum`.
8
+ * Renamed `lower_scan_window_limit` / `upper_scan_window_limit` → `lower_mz` / `upper_mz` on `Scan`.
9
+
10
+ **Bug fixes:**
11
+
12
+ * Fixed polarity accessions — `ScanPolarity.POSITIVE` and `ScanPolarity.NEGATIVE` were swapped, causing incorrect polarity identification for all spectra.
13
+
14
+ **New features:**
15
+
16
+ * Added `ION_MOBILITIES` constant set grouping all ion mobility `BinaryDataArrayAccession` values.
17
+ * Added `Spectrum.charge` — charge array as a numpy array (or `None`).
18
+ * Added `Spectrum.has_im` — `True` if the spectrum contains any ion mobility binary array.
19
+ * Added `Spectrum.im_types` — set of `BinaryDataArrayAccession` values present for ion mobility.
20
+ * Added `Spectrum.scan_start_time` — delegates to the first scan's `scan_start_time`.
21
+ * Added `Spectrum.ion_injection_time` — delegates to the first scan's `ion_injection_time`.
22
+
23
+ ## 0.1.0 (2026-02-10)
24
+
25
+ * First release on PyPI.
@@ -0,0 +1,12 @@
1
+ include HISTORY.md
2
+ include README.md
3
+ include .gitignore
4
+ include tests/data
5
+
6
+ recursive-include tests *
7
+ recursive-include .github *
8
+
9
+ recursive-exclude * __pycache__
10
+ recursive-exclude * *.py[co]
11
+
12
+ recursive-include *.md justfile *.jpg *.png *.gif
mzmlpy-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,75 @@
1
+ Metadata-Version: 2.4
2
+ Name: mzmlpy
3
+ Version: 0.3.0
4
+ Summary: A lightweight Python library for parsing mzML mass spectrometry files.
5
+ Author-email: Patrick Garrett <pgarrett@scripps.edu>
6
+ Maintainer-email: Patrick Garrett <pgarrett@scripps.edu>
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Intended Audience :: Science/Research
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
12
+ Classifier: Typing :: Typed
13
+ Requires-Python: >=3.12
14
+ Requires-Dist: numpy>=1.26.0
15
+ Provides-Extra: numpress
16
+ Requires-Dist: pynumpress>=0.0.4; extra == 'numpress'
17
+ Provides-Extra: zstd
18
+ Requires-Dist: zstd>=1.5.5; extra == 'zstd'
19
+ Description-Content-Type: text/markdown
20
+
21
+ <div align="center">
22
+ <img src="logo.png" alt="MZMLpy Logo" width="400" style="margin: 20px;"/>
23
+
24
+ A lightweight Python library for parsing mzML mass spectrometry files. Implements a type-safe, lazy-loading API with direct support for modern mzML structures (>= 1.1.0).
25
+
26
+ [![Python package](https://github.com/tacular-omics/mzmlpy/actions/workflows/python-package.yml/badge.svg)](https://github.com/tacular-omics/mzmlpy/actions/workflows/python-package.yml)
27
+ [![codecov](https://codecov.io/github/tacular-omics/mzmlpy/graph/badge.svg?token=1CTVZVFXF7)](https://codecov.io/github/tacular-omics/mzmlpy)
28
+ [![PyPI version](https://badge.fury.io/py/mzmlpy.svg)](https://badge.fury.io/py/mzmlpy)
29
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
30
+ [![License: MIT](https://img.shields.io/badge/License-MIT-g.svg)](https://opensource.org/licenses/MIT)
31
+
32
+ </div>
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pip install mzmlpy
38
+ ```
39
+
40
+ Optional extras:
41
+
42
+ ```bash
43
+ pip install mzmlpy[numpress] # MS-Numpress decoding
44
+ pip install mzmlpy[zstd] # Zstandard compression
45
+ ```
46
+
47
+ ## Quick Start
48
+
49
+ ```python
50
+ from mzmlpy import Mzml
51
+
52
+ with Mzml("path/to/file.mzML") as reader:
53
+ print(f"File: {reader.file_name} | Spectra: {len(reader.spectra)}")
54
+
55
+ for spectrum in reader.spectra:
56
+ mz = spectrum.mz
57
+ intensity = spectrum.intensity
58
+ print(f" {spectrum.id} MS{spectrum.ms_level} — {len(mz)} peaks")
59
+ ```
60
+
61
+ Both `.mzML` and `.mzML.gz` files are supported. Metadata is parsed eagerly; binary data is decoded on demand.
62
+
63
+ For full usage examples see the **[Getting Started guide](https://tacular-omics.github.io/mzmlpy/getting-started/)** and **[API Reference](https://tacular-omics.github.io/mzmlpy/api/mzml/)**.
64
+
65
+ ## Development
66
+
67
+ ```bash
68
+ just lint # ruff check
69
+ just format # ruff isort + format
70
+ just ty # ty type checker
71
+ just test # pytest
72
+
73
+ # or all at once:
74
+ just check
75
+ ```
mzmlpy-0.3.0/README.md ADDED
@@ -0,0 +1,55 @@
1
+ <div align="center">
2
+ <img src="logo.png" alt="MZMLpy Logo" width="400" style="margin: 20px;"/>
3
+
4
+ A lightweight Python library for parsing mzML mass spectrometry files. Implements a type-safe, lazy-loading API with direct support for modern mzML structures (>= 1.1.0).
5
+
6
+ [![Python package](https://github.com/tacular-omics/mzmlpy/actions/workflows/python-package.yml/badge.svg)](https://github.com/tacular-omics/mzmlpy/actions/workflows/python-package.yml)
7
+ [![codecov](https://codecov.io/github/tacular-omics/mzmlpy/graph/badge.svg?token=1CTVZVFXF7)](https://codecov.io/github/tacular-omics/mzmlpy)
8
+ [![PyPI version](https://badge.fury.io/py/mzmlpy.svg)](https://badge.fury.io/py/mzmlpy)
9
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-g.svg)](https://opensource.org/licenses/MIT)
11
+
12
+ </div>
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pip install mzmlpy
18
+ ```
19
+
20
+ Optional extras:
21
+
22
+ ```bash
23
+ pip install mzmlpy[numpress] # MS-Numpress decoding
24
+ pip install mzmlpy[zstd] # Zstandard compression
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ```python
30
+ from mzmlpy import Mzml
31
+
32
+ with Mzml("path/to/file.mzML") as reader:
33
+ print(f"File: {reader.file_name} | Spectra: {len(reader.spectra)}")
34
+
35
+ for spectrum in reader.spectra:
36
+ mz = spectrum.mz
37
+ intensity = spectrum.intensity
38
+ print(f" {spectrum.id} MS{spectrum.ms_level} — {len(mz)} peaks")
39
+ ```
40
+
41
+ Both `.mzML` and `.mzML.gz` files are supported. Metadata is parsed eagerly; binary data is decoded on demand.
42
+
43
+ For full usage examples see the **[Getting Started guide](https://tacular-omics.github.io/mzmlpy/getting-started/)** and **[API Reference](https://tacular-omics.github.io/mzmlpy/api/mzml/)**.
44
+
45
+ ## Development
46
+
47
+ ```bash
48
+ just lint # ruff check
49
+ just format # ruff isort + format
50
+ just ty # ty type checker
51
+ just test # pytest
52
+
53
+ # or all at once:
54
+ just check
55
+ ```
@@ -0,0 +1,3 @@
1
+ # Chromatogram
2
+
3
+ ::: mzmlpy.spectra.Chromatogram
@@ -0,0 +1,11 @@
1
+ # Constants
2
+
3
+ ::: mzmlpy.constants
4
+ options:
5
+ members:
6
+ - ScanPolarity
7
+ - SpectrumType
8
+ - BinaryDataArrayAccession
9
+ - CompressionTypeAccessions
10
+ - ION_MOBILITIES
11
+ - PROTON_MASS
@@ -0,0 +1,7 @@
1
+ # Data Processing
2
+
3
+ ::: mzmlpy.elems.data_processing.DataProcessing
4
+
5
+ ## ProcessingMethod
6
+
7
+ ::: mzmlpy.elems.data_processing.ProcessingMethod
@@ -0,0 +1,15 @@
1
+ # File Description
2
+
3
+ ::: mzmlpy.elems.file_desc.FileDescription
4
+
5
+ ## FileContent
6
+
7
+ ::: mzmlpy.elems.file_desc.FileContent
8
+
9
+ ## SourceFile
10
+
11
+ ::: mzmlpy.elems.file_desc.SourceFile
12
+
13
+ ## Contact
14
+
15
+ ::: mzmlpy.elems.file_desc.Contact
@@ -0,0 +1,15 @@
1
+ # Instrument Configuration
2
+
3
+ ::: mzmlpy.elems.instrument_config.InstrumentConfiguration
4
+
5
+ ## SourceComponent
6
+
7
+ ::: mzmlpy.elems.instrument_config.SourceComponent
8
+
9
+ ## AnalyzerComponent
10
+
11
+ ::: mzmlpy.elems.instrument_config.AnalyzerComponent
12
+
13
+ ## DetectorComponent
14
+
15
+ ::: mzmlpy.elems.instrument_config.DetectorComponent
@@ -0,0 +1,5 @@
1
+ # Lookup
2
+
3
+ ::: mzmlpy.lookup.SpectrumLookup
4
+
5
+ ::: mzmlpy.lookup.ChromatogramLookup
@@ -0,0 +1,33 @@
1
+ # Metadata
2
+
3
+ ## Software
4
+
5
+ ::: mzmlpy.elems.software.Software
6
+
7
+ ## Sample
8
+
9
+ ::: mzmlpy.elems.sample.Sample
10
+
11
+ ## Run
12
+
13
+ ::: mzmlpy.elems.run.Run
14
+
15
+ ## ScanSetting
16
+
17
+ ::: mzmlpy.elems.scan_setting.ScanSetting
18
+
19
+ ## Target
20
+
21
+ ::: mzmlpy.elems.scan_setting.Target
22
+
23
+ ## SourceFileRef
24
+
25
+ ::: mzmlpy.elems.scan_setting.SourceFileRef
26
+
27
+ ## ReferenceableParamGroup
28
+
29
+ ::: mzmlpy.elems.referenceable_param_group.ReferenceableParamGroup
30
+
31
+ ## ReferenceableParamGroupRef
32
+
33
+ ::: mzmlpy.elems.params.ReferenceableParamGroupRef
@@ -0,0 +1,3 @@
1
+ # Mzml Reader
2
+
3
+ ::: mzmlpy.run.Mzml
@@ -0,0 +1,11 @@
1
+ # CV Parameters
2
+
3
+ ::: mzmlpy.elems.params.CvParam
4
+
5
+ ## UserParam
6
+
7
+ ::: mzmlpy.elems.params.UserParam
8
+
9
+ ## CVElement
10
+
11
+ ::: mzmlpy.content.CVElement
@@ -0,0 +1,15 @@
1
+ # Precursor & Ions
2
+
3
+ ::: mzmlpy.spectra.Precursor
4
+
5
+ ## IsolationWindow
6
+
7
+ ::: mzmlpy.spectra.IsolationWindow
8
+
9
+ ## SelectedIon
10
+
11
+ ::: mzmlpy.spectra.SelectedIon
12
+
13
+ ## Activation
14
+
15
+ ::: mzmlpy.spectra.Activation
@@ -0,0 +1,15 @@
1
+ # Spectrum
2
+
3
+ ::: mzmlpy.spectra.Spectrum
4
+
5
+ ## Scan
6
+
7
+ ::: mzmlpy.spectra.Scan
8
+
9
+ ## ScanWindow
10
+
11
+ ::: mzmlpy.spectra.ScanWindow
12
+
13
+ ## BinaryDataArray
14
+
15
+ ::: mzmlpy.spectra.BinaryDataArray