Precursor & Ions¶
mzmlpy.spectra.Precursor
dataclass
¶
Bases: _DataTreeWrapper
Represents a precursor element in an mzML spectrum.
Provides access to the isolation window, selected ions, activation parameters, and reference attributes such as spectrum ref and source file ref.
serialize
¶
Return the element as nested dicts: tag, attributes, text, children.
The result is a fresh copy; changing it does not change the wrapped element.
Source code in src/mzmlpy/elems/dtree_wrapper.py
get_attribute
¶
Product¶
mzmlpy.spectra.Product
dataclass
¶
Bases: _ParamGroup
A product ion selection element containing an isolation window and CV parameters.
isolation_window
property
¶
isolation_window: IsolationWindow | None
Get the isolation window for this product, if present.
cv_params
cached
property
¶
cv_params: tuple[CvParam, ...]
The element's cvParams, in document order.
user_params
cached
property
¶
user_params: tuple[UserParam, ...]
The element's userParams, in document order.
ref_params
cached
property
¶
ref_params: tuple[ReferenceableParamGroupRef, ...]
The element's referenceableParamGroupRefs, in document order.
serialize
¶
Return the element as nested dicts: tag, attributes, text, children.
The result is a fresh copy; changing it does not change the wrapped element.
Source code in src/mzmlpy/elems/dtree_wrapper.py
get_attribute
¶
get_cv_param
¶
get_cv_param(id: str) -> CvParam | None
Get a cvParam by accession or name, or None if absent.
has_cv_param
¶
Check if a cvParam with the given accession or name exists.
cv_float
¶
Return a cvParam's value as a float, or None if the term is absent or has no value.
Raises MzmlError naming the term and its bad value if the value is present but not numeric — more actionable than a bare "could not convert string to float".
Source code in src/mzmlpy/elems/dtree_wrapper.py
cv_int
¶
Return a cvParam's value as an int, or None if absent or valueless (see :meth:cv_float).
Source code in src/mzmlpy/elems/dtree_wrapper.py
has_user_param
¶
get_ref_param
¶
get_ref_param(
ref: str,
) -> ReferenceableParamGroupRef | None
Get a referenceable parameter by ref.
has_ref_param
¶
IsolationWindow¶
mzmlpy.spectra.IsolationWindow
dataclass
¶
Bases: _ParamGroup
Represents an isolation window element from a precursor or product.
Provides the isolation target m/z, the lower and upper offsets, the window width and the
isolated m/z range. The names match tdfpy's DiaWindow and Precursor.
isolation_mz
property
¶
Isolation window target m/z (MS:1000827), or None.
lower_offset
property
¶
Get isolation window lower offset for this precursor.
upper_offset
property
¶
Get isolation window upper offset for this precursor.
isolation_width
property
¶
Full window width, lower_offset + upper_offset, or None if either offset is missing.
isolation_mz_range
property
¶
(isolation_mz - lower_offset, isolation_mz + upper_offset), or None if any of the three is missing.
no_isolation
property
¶
Whether this window carries the "no isolation" marker (MS:1003159).
Full-mass-range DIA (e.g. MSE/HDMSE) sets this on an otherwise-empty isolationWindow to signal that no precursor was isolated (PSI IM-MS/DIA recommendation v1.0, §3.5).
cv_params
cached
property
¶
cv_params: tuple[CvParam, ...]
The element's cvParams, in document order.
user_params
cached
property
¶
user_params: tuple[UserParam, ...]
The element's userParams, in document order.
ref_params
cached
property
¶
ref_params: tuple[ReferenceableParamGroupRef, ...]
The element's referenceableParamGroupRefs, in document order.
serialize
¶
Return the element as nested dicts: tag, attributes, text, children.
The result is a fresh copy; changing it does not change the wrapped element.
Source code in src/mzmlpy/elems/dtree_wrapper.py
get_attribute
¶
get_cv_param
¶
get_cv_param(id: str) -> CvParam | None
Get a cvParam by accession or name, or None if absent.
has_cv_param
¶
Check if a cvParam with the given accession or name exists.
cv_float
¶
Return a cvParam's value as a float, or None if the term is absent or has no value.
Raises MzmlError naming the term and its bad value if the value is present but not numeric — more actionable than a bare "could not convert string to float".
Source code in src/mzmlpy/elems/dtree_wrapper.py
cv_int
¶
Return a cvParam's value as an int, or None if absent or valueless (see :meth:cv_float).
Source code in src/mzmlpy/elems/dtree_wrapper.py
has_user_param
¶
get_ref_param
¶
get_ref_param(
ref: str,
) -> ReferenceableParamGroupRef | None
Get a referenceable parameter by ref.
has_ref_param
¶
SelectedIon¶
mzmlpy.spectra.SelectedIon
dataclass
¶
Bases: _ParamGroup
Represents a selected ion element within a precursor.
Provides access to the selected ion m/z, peak intensity, charge, ion mobility values, FAIMS voltages, and collisional cross section.
intensity
property
¶
Peak intensity of the selected ion (MS:1000042), or None.
possible_charges
property
¶
Every possible charge state (MS:1000633) of the selected ion, in document order; empty if none.
Written when the charge could not be determined uniquely; a file may list several.
ook0
property
¶
Inverse reduced ion mobility 1/K0 (Vs/cm², MS:1002815) of the selected ion, or None.
drift_time
property
¶
Ion mobility drift time of the selected ion, or None.
faims_voltage_start
property
¶
Get FAIMS voltage start for this precursor.
faims_voltage_end
property
¶
Get FAIMS voltage end for this precursor.
cv_params
cached
property
¶
cv_params: tuple[CvParam, ...]
The element's cvParams, in document order.
user_params
cached
property
¶
user_params: tuple[UserParam, ...]
The element's userParams, in document order.
ref_params
cached
property
¶
ref_params: tuple[ReferenceableParamGroupRef, ...]
The element's referenceableParamGroupRefs, in document order.
serialize
¶
Return the element as nested dicts: tag, attributes, text, children.
The result is a fresh copy; changing it does not change the wrapped element.
Source code in src/mzmlpy/elems/dtree_wrapper.py
get_attribute
¶
get_cv_param
¶
get_cv_param(id: str) -> CvParam | None
Get a cvParam by accession or name, or None if absent.
has_cv_param
¶
Check if a cvParam with the given accession or name exists.
cv_float
¶
Return a cvParam's value as a float, or None if the term is absent or has no value.
Raises MzmlError naming the term and its bad value if the value is present but not numeric — more actionable than a bare "could not convert string to float".
Source code in src/mzmlpy/elems/dtree_wrapper.py
cv_int
¶
Return a cvParam's value as an int, or None if absent or valueless (see :meth:cv_float).
Source code in src/mzmlpy/elems/dtree_wrapper.py
has_user_param
¶
get_ref_param
¶
get_ref_param(
ref: str,
) -> ReferenceableParamGroupRef | None
Get a referenceable parameter by ref.
has_ref_param
¶
Activation¶
mzmlpy.spectra.Activation
dataclass
¶
Bases: _ParamGroup
Represents an activation element within a precursor.
Provides access to the activation type, collision energy, supplemental collision energy, collision gas, and collision gas pressure.
activation_types
property
¶
activation_types: tuple[
CollisionDissociationTypeAccession, ...
]
Every dissociation method term of this activation, in document order, without duplicates.
EThcD, as msconvert writes it, gives (ELECTRON_TRANSFER_DISSOCIATION,
SUPPLEMENTAL_BEAM_TYPE_COLLISION_INDUCED_DISSOCIATION).
activation_type
property
¶
activation_type: CollisionDissociationTypeAccession | None
The primary dissociation method of this activation, or None.
Supplemental terms (supplemental beam-type CID MS:1002678, supplemental CID MS:1002679) only
qualify the primary method, so a non-supplemental term wins: EThcD (ETD + supplemental
beam-type CID) reports ETD. Among several primary terms the first in document order wins; a
supplemental term is returned only when no primary term is present. Use
:attr:activation_types for every term.
activation_energy
property
¶
Get activation energy for this precursor.
collision_energy
property
¶
Collision energy (MS:1000045) as recorded, or None.
The term's unit is electronvolt, but some writers (notably Thermo converters) record the
normalized collision energy (NCE, percent) under this term, so the number is returned as
written without conversion. :attr:activation_energy (MS:1000509) is a separate term.
supplemental_collision_energy
property
¶
Supplemental collision energy (MS:1002680) as recorded, or None (e.g. EThcD supplemental activation).
collision_gas
property
¶
Get collision gas for this precursor.
collision gas (MS:1000419) is normally a valueless flag whose identity is carried by
the term name, so this returns the parameter's value when one is present and otherwise the
term name — instead of returning None for the (common) valueless case.
collision_gas_pressure
property
¶
Get collision gas pressure for this precursor.
cv_params
cached
property
¶
cv_params: tuple[CvParam, ...]
The element's cvParams, in document order.
user_params
cached
property
¶
user_params: tuple[UserParam, ...]
The element's userParams, in document order.
ref_params
cached
property
¶
ref_params: tuple[ReferenceableParamGroupRef, ...]
The element's referenceableParamGroupRefs, in document order.
serialize
¶
Return the element as nested dicts: tag, attributes, text, children.
The result is a fresh copy; changing it does not change the wrapped element.
Source code in src/mzmlpy/elems/dtree_wrapper.py
get_attribute
¶
get_cv_param
¶
get_cv_param(id: str) -> CvParam | None
Get a cvParam by accession or name, or None if absent.
has_cv_param
¶
Check if a cvParam with the given accession or name exists.
cv_float
¶
Return a cvParam's value as a float, or None if the term is absent or has no value.
Raises MzmlError naming the term and its bad value if the value is present but not numeric — more actionable than a bare "could not convert string to float".
Source code in src/mzmlpy/elems/dtree_wrapper.py
cv_int
¶
Return a cvParam's value as an int, or None if absent or valueless (see :meth:cv_float).
Source code in src/mzmlpy/elems/dtree_wrapper.py
has_user_param
¶
get_ref_param
¶
get_ref_param(
ref: str,
) -> ReferenceableParamGroupRef | None
Get a referenceable parameter by ref.