Lookup¶
mzmlpy.lookup.SpectrumLookup
¶
SpectrumLookup(
file_object: FileInterface,
*,
count: int | None = None,
id_regex: str | None = None
)
Bases: BaseLookup[Spectrum]
Lookup interface for spectra.
Source code in src/mzmlpy/lookup.py
filter
¶
filter(
*,
ms_level: int | None = None,
rt: float | None = None,
rt_range: (
tuple[float | None, float | None] | None
) = None,
rt_tolerance: float = 30.0,
polarity: Polarity | None = None,
precursor_mz: float | None = None,
precursor_mz_range: (
tuple[float | None, float | None] | None
) = None,
mz_tolerance: float = 20.0,
mz_tolerance_unit: ToleranceUnit = "ppm",
spectrum_type: (
Literal["centroid", "profile"] | None
) = None,
ook0_range: (
tuple[float | None, float | None] | None
) = None,
drift_time_range: (
tuple[float | None, float | None] | None
) = None,
faims_voltage_range: (
tuple[float | None, float | None] | None
) = None
) -> Iterator[Spectrum]
Lazily select spectra by metadata, without decoding binary arrays.
Criteria are combined with AND. Tuples are inclusive *_range bounds, either end None
for open. Point queries follow tdfpy's query: rt matches within rt_tolerance
seconds and precursor_mz within mz_tolerance ppm (or Da with
mz_tolerance_unit="da"). Pass a point or its range, not both. See
:class:SpectrumFilter for how each criterion matches. Keep the reader open while
iterating.
With an indexed reader (access strategy plain, rapidgzip or
memory; stream and embedded scan every spectrum), the first retention-time
query reads the scan times of every spectrum once, from the metadata before each
record's binary arrays, and caches them. It and later queries then read in full only the
spectra inside the window. Record order does not matter.
Raises:
| Type | Description |
|---|---|
MzmlError
|
A criterion is invalid, or both a point and its range were given. |
Source code in src/mzmlpy/lookup.py
get_by_index
¶
Get item by index. Negative indices count from the end, like a list.
Source code in src/mzmlpy/lookup.py
get_by_id
¶
Get item by native id, or by the id_regex key when the reader was given one.
Raises:
| Type | Description |
|---|---|
MzmlRecordNotFoundError
|
No record has this id (also a |
TypeError
|
|
Source code in src/mzmlpy/lookup.py
get_by_slice
¶
Get items by slice notation.
Source code in src/mzmlpy/lookup.py
mzmlpy.lookup.ChromatogramLookup
¶
ChromatogramLookup(
file_object: FileInterface,
*,
count: int | None = None,
id_regex: str | None = None
)
Bases: BaseLookup[Chromatogram]
Lookup interface for chromatograms.
Source code in src/mzmlpy/lookup.py
get_by_index
¶
Get item by index. Negative indices count from the end, like a list.
Source code in src/mzmlpy/lookup.py
get_by_id
¶
Get item by native id, or by the id_regex key when the reader was given one.
Raises:
| Type | Description |
|---|---|
MzmlRecordNotFoundError
|
No record has this id (also a |
TypeError
|
|
Source code in src/mzmlpy/lookup.py
get_by_slice
¶
Get items by slice notation.