Mzml Reader
mzmlpy.run.Mzml
Mzml(
file: str | Path | Any,
build_index_from_scratch: bool = False,
gzip_mode: Literal[
"extract", "indexed", "stream"
] = "extract",
in_memory: bool = True,
extract_dir: str | Path | None = None,
spectrum_id_regex: str | None = None,
chromatogram_id_regex: str | None = None,
)
Reader for mzML files.
Data is lazily loaded, so only the specific sections of the XML file are parsed.
The actual data and properties of objects are only parsed when accessed. Use the
context manager to ensure proper file handling. The spectra and chromatograms
properties return lookup objects that support iteration, indexing, and ID-based access.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
str | Path | Any
|
Path to the mzML file (str or Path) or a file-like object. |
required |
build_index_from_scratch
|
bool
|
Build the index from scratch instead of using an existing index. |
False
|
gzip_mode
|
Literal['extract', 'indexed', 'stream']
|
Strategy for reading gzip-compressed (
|
'extract'
|
in_memory
|
bool
|
Load the entire file into memory for faster access. |
True
|
extract_dir
|
str | Path | None
|
Directory to store extracted |
None
|
spectrum_id_regex
|
str | None
|
Optional regex applied to spectrum IDs to create a secondary lookup
key. The first capture group (or full match if no groups) becomes the simplified key.
For example, |
None
|
chromatogram_id_regex
|
str | None
|
Optional regex applied to chromatogram IDs to create a secondary
lookup key. Works identically to |
None
|
Initialize Mzml and parse metadata.
Source code in src/mzmlpy/run.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
file_path
property
file_path: Path | None
Access the file path as a Path object if available.
file_name
property
file_name: str
Access the file name as a string.
id
property
id: str
Access mzML id.
version
property
version: str
Access mzML version.
referenceable_param_groups
property
referenceable_param_groups: dict[
str, ReferenceableParamGroup
]
Access referenceable parameter groups.
instrument_configurations
property
instrument_configurations: dict[
str, InstrumentConfiguration
]
Access instrument configurations.