Skip to content

Precursor & Ions

mzmlpy.spectra.Precursor dataclass

Precursor(element: ElementTree.Element)

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.

ns cached property

ns: str

Get XML namespace from the element tag.

serialize

serialize() -> dict[str, object]

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
def serialize(self) -> dict[str, object]:
    """Return the element as nested dicts: ``tag``, ``attributes``, ``text``, ``children``.

    The result is a fresh copy; changing it does not change the wrapped element.
    """
    return {
        "tag": self.element.tag,
        "attributes": dict(self.element.attrib),
        "text": self.element.text,
        "children": [_DataTreeWrapper(child).serialize() for child in self.element],
    }

get_attribute

get_attribute(attr_name: str) -> str | None

Get an attribute value from the element.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_attribute(self, attr_name: str) -> str | None:
    """Get an attribute value from the element."""
    return self.element.attrib.get(attr_name)

Product

mzmlpy.spectra.Product dataclass

Product(element: ElementTree.Element)

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.

ns cached property

ns: str

Get XML namespace from the element tag.

cv_params cached property

cv_params: tuple[CvParam, ...]

The element's cvParams, in document order.

accessions cached property

accessions: frozenset[str]

All cvParam accessions.

names cached property

names: frozenset[str]

All cvParam names.

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

serialize() -> dict[str, object]

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
def serialize(self) -> dict[str, object]:
    """Return the element as nested dicts: ``tag``, ``attributes``, ``text``, ``children``.

    The result is a fresh copy; changing it does not change the wrapped element.
    """
    return {
        "tag": self.element.tag,
        "attributes": dict(self.element.attrib),
        "text": self.element.text,
        "children": [_DataTreeWrapper(child).serialize() for child in self.element],
    }

get_attribute

get_attribute(attr_name: str) -> str | None

Get an attribute value from the element.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_attribute(self, attr_name: str) -> str | None:
    """Get an attribute value from the element."""
    return self.element.attrib.get(attr_name)

get_cv_param

get_cv_param(id: str) -> CvParam | None

Get a cvParam by accession or name, or None if absent.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_cv_param(self, id: str) -> CvParam | None:
    """Get a cvParam by accession or name, or None if absent."""
    for cv_param in self.cv_params:
        if cv_param.accession == id or cv_param.name == id:
            return cv_param
    return None

has_cv_param

has_cv_param(id: str) -> bool

Check if a cvParam with the given accession or name exists.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def has_cv_param(self, id: str) -> bool:
    """Check if a cvParam with the given accession or name exists."""
    return any(cv_param.accession == id or cv_param.name == id for cv_param in self.cv_params)

cv_float

cv_float(id: str) -> float | None

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
def cv_float(self, id: str) -> float | None:
    """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".
    """
    cv_param = self.get_cv_param(id)
    if cv_param is None or cv_param.value is None:
        return None
    try:
        return float(cv_param.value)
    except ValueError as e:
        raise MzmlError(
            f"CV param {cv_param.name or id!r} ({id}) has a non-numeric value {cv_param.value!r}"
        ) from e

cv_int

cv_int(id: str) -> int | None

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
def cv_int(self, id: str) -> int | None:
    """Return a cvParam's value as an int, or None if absent or valueless (see :meth:`cv_float`)."""
    cv_param = self.get_cv_param(id)
    if cv_param is None or cv_param.value is None:
        return None
    try:
        return int(cv_param.value)
    except ValueError as e:
        raise MzmlError(
            f"CV param {cv_param.name or id!r} ({id}) has a non-integer value {cv_param.value!r}"
        ) from e

get_user_param

get_user_param(name: str) -> UserParam | None

Get a userParam by name.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_user_param(self, name: str) -> UserParam | None:
    """Get a userParam by name."""
    for user_param in self.user_params:
        if user_param.name == name:
            return user_param
    return None

has_user_param

has_user_param(name: str) -> bool

Check if a userParam with the given name exists.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def has_user_param(self, name: str) -> bool:
    """Check if a userParam with the given name exists."""
    return any(user_param.name == name for user_param in self.user_params)

get_ref_param

get_ref_param(
    ref: str,
) -> ReferenceableParamGroupRef | None

Get a referenceable parameter by ref.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_ref_param(self, ref: str) -> ReferenceableParamGroupRef | None:
    """Get a referenceable parameter by ref."""
    for ref_param in self.ref_params:
        if ref_param.ref == ref:
            return ref_param
    return None

has_ref_param

has_ref_param(ref: str) -> bool

Check if a referenceable parameter with the given ref exists.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def has_ref_param(self, ref: str) -> bool:
    """Check if a referenceable parameter with the given ref exists."""
    return any(ref_param.ref == ref for ref_param in self.ref_params)

IsolationWindow

mzmlpy.spectra.IsolationWindow dataclass

IsolationWindow(element: ElementTree.Element)

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_mz: float | None

Isolation window target m/z (MS:1000827), or None.

lower_offset property

lower_offset: float | None

Get isolation window lower offset for this precursor.

upper_offset property

upper_offset: float | None

Get isolation window upper offset for this precursor.

isolation_width property

isolation_width: float | None

Full window width, lower_offset + upper_offset, or None if either offset is missing.

isolation_mz_range property

isolation_mz_range: tuple[float, float] | None

(isolation_mz - lower_offset, isolation_mz + upper_offset), or None if any of the three is missing.

no_isolation property

no_isolation: bool

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).

ns cached property

ns: str

Get XML namespace from the element tag.

cv_params cached property

cv_params: tuple[CvParam, ...]

The element's cvParams, in document order.

accessions cached property

accessions: frozenset[str]

All cvParam accessions.

names cached property

names: frozenset[str]

All cvParam names.

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

serialize() -> dict[str, object]

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
def serialize(self) -> dict[str, object]:
    """Return the element as nested dicts: ``tag``, ``attributes``, ``text``, ``children``.

    The result is a fresh copy; changing it does not change the wrapped element.
    """
    return {
        "tag": self.element.tag,
        "attributes": dict(self.element.attrib),
        "text": self.element.text,
        "children": [_DataTreeWrapper(child).serialize() for child in self.element],
    }

get_attribute

get_attribute(attr_name: str) -> str | None

Get an attribute value from the element.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_attribute(self, attr_name: str) -> str | None:
    """Get an attribute value from the element."""
    return self.element.attrib.get(attr_name)

get_cv_param

get_cv_param(id: str) -> CvParam | None

Get a cvParam by accession or name, or None if absent.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_cv_param(self, id: str) -> CvParam | None:
    """Get a cvParam by accession or name, or None if absent."""
    for cv_param in self.cv_params:
        if cv_param.accession == id or cv_param.name == id:
            return cv_param
    return None

has_cv_param

has_cv_param(id: str) -> bool

Check if a cvParam with the given accession or name exists.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def has_cv_param(self, id: str) -> bool:
    """Check if a cvParam with the given accession or name exists."""
    return any(cv_param.accession == id or cv_param.name == id for cv_param in self.cv_params)

cv_float

cv_float(id: str) -> float | None

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
def cv_float(self, id: str) -> float | None:
    """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".
    """
    cv_param = self.get_cv_param(id)
    if cv_param is None or cv_param.value is None:
        return None
    try:
        return float(cv_param.value)
    except ValueError as e:
        raise MzmlError(
            f"CV param {cv_param.name or id!r} ({id}) has a non-numeric value {cv_param.value!r}"
        ) from e

cv_int

cv_int(id: str) -> int | None

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
def cv_int(self, id: str) -> int | None:
    """Return a cvParam's value as an int, or None if absent or valueless (see :meth:`cv_float`)."""
    cv_param = self.get_cv_param(id)
    if cv_param is None or cv_param.value is None:
        return None
    try:
        return int(cv_param.value)
    except ValueError as e:
        raise MzmlError(
            f"CV param {cv_param.name or id!r} ({id}) has a non-integer value {cv_param.value!r}"
        ) from e

get_user_param

get_user_param(name: str) -> UserParam | None

Get a userParam by name.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_user_param(self, name: str) -> UserParam | None:
    """Get a userParam by name."""
    for user_param in self.user_params:
        if user_param.name == name:
            return user_param
    return None

has_user_param

has_user_param(name: str) -> bool

Check if a userParam with the given name exists.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def has_user_param(self, name: str) -> bool:
    """Check if a userParam with the given name exists."""
    return any(user_param.name == name for user_param in self.user_params)

get_ref_param

get_ref_param(
    ref: str,
) -> ReferenceableParamGroupRef | None

Get a referenceable parameter by ref.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_ref_param(self, ref: str) -> ReferenceableParamGroupRef | None:
    """Get a referenceable parameter by ref."""
    for ref_param in self.ref_params:
        if ref_param.ref == ref:
            return ref_param
    return None

has_ref_param

has_ref_param(ref: str) -> bool

Check if a referenceable parameter with the given ref exists.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def has_ref_param(self, ref: str) -> bool:
    """Check if a referenceable parameter with the given ref exists."""
    return any(ref_param.ref == ref for ref_param in self.ref_params)

SelectedIon

mzmlpy.spectra.SelectedIon dataclass

SelectedIon(element: ElementTree.Element)

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.

mz property

mz: float | None

Selected ion m/z (MS:1000744), or None.

intensity property

intensity: float | None

Peak intensity of the selected ion (MS:1000042), or None.

charge property

charge: int | None

Charge state of the selected ion (MS:1000041), or None.

possible_charges property

possible_charges: tuple[int, ...]

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

ook0: float | None

Inverse reduced ion mobility 1/K0 (Vs/cm², MS:1002815) of the selected ion, or None.

drift_time property

drift_time: float | None

Ion mobility drift time of the selected ion, or None.

faims_voltage_start property

faims_voltage_start: float | None

Get FAIMS voltage start for this precursor.

faims_voltage_end property

faims_voltage_end: float | None

Get FAIMS voltage end for this precursor.

ccs property

ccs: float | None

Get collisional cross section for this precursor.

ns cached property

ns: str

Get XML namespace from the element tag.

cv_params cached property

cv_params: tuple[CvParam, ...]

The element's cvParams, in document order.

accessions cached property

accessions: frozenset[str]

All cvParam accessions.

names cached property

names: frozenset[str]

All cvParam names.

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

serialize() -> dict[str, object]

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
def serialize(self) -> dict[str, object]:
    """Return the element as nested dicts: ``tag``, ``attributes``, ``text``, ``children``.

    The result is a fresh copy; changing it does not change the wrapped element.
    """
    return {
        "tag": self.element.tag,
        "attributes": dict(self.element.attrib),
        "text": self.element.text,
        "children": [_DataTreeWrapper(child).serialize() for child in self.element],
    }

get_attribute

get_attribute(attr_name: str) -> str | None

Get an attribute value from the element.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_attribute(self, attr_name: str) -> str | None:
    """Get an attribute value from the element."""
    return self.element.attrib.get(attr_name)

get_cv_param

get_cv_param(id: str) -> CvParam | None

Get a cvParam by accession or name, or None if absent.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_cv_param(self, id: str) -> CvParam | None:
    """Get a cvParam by accession or name, or None if absent."""
    for cv_param in self.cv_params:
        if cv_param.accession == id or cv_param.name == id:
            return cv_param
    return None

has_cv_param

has_cv_param(id: str) -> bool

Check if a cvParam with the given accession or name exists.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def has_cv_param(self, id: str) -> bool:
    """Check if a cvParam with the given accession or name exists."""
    return any(cv_param.accession == id or cv_param.name == id for cv_param in self.cv_params)

cv_float

cv_float(id: str) -> float | None

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
def cv_float(self, id: str) -> float | None:
    """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".
    """
    cv_param = self.get_cv_param(id)
    if cv_param is None or cv_param.value is None:
        return None
    try:
        return float(cv_param.value)
    except ValueError as e:
        raise MzmlError(
            f"CV param {cv_param.name or id!r} ({id}) has a non-numeric value {cv_param.value!r}"
        ) from e

cv_int

cv_int(id: str) -> int | None

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
def cv_int(self, id: str) -> int | None:
    """Return a cvParam's value as an int, or None if absent or valueless (see :meth:`cv_float`)."""
    cv_param = self.get_cv_param(id)
    if cv_param is None or cv_param.value is None:
        return None
    try:
        return int(cv_param.value)
    except ValueError as e:
        raise MzmlError(
            f"CV param {cv_param.name or id!r} ({id}) has a non-integer value {cv_param.value!r}"
        ) from e

get_user_param

get_user_param(name: str) -> UserParam | None

Get a userParam by name.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_user_param(self, name: str) -> UserParam | None:
    """Get a userParam by name."""
    for user_param in self.user_params:
        if user_param.name == name:
            return user_param
    return None

has_user_param

has_user_param(name: str) -> bool

Check if a userParam with the given name exists.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def has_user_param(self, name: str) -> bool:
    """Check if a userParam with the given name exists."""
    return any(user_param.name == name for user_param in self.user_params)

get_ref_param

get_ref_param(
    ref: str,
) -> ReferenceableParamGroupRef | None

Get a referenceable parameter by ref.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_ref_param(self, ref: str) -> ReferenceableParamGroupRef | None:
    """Get a referenceable parameter by ref."""
    for ref_param in self.ref_params:
        if ref_param.ref == ref:
            return ref_param
    return None

has_ref_param

has_ref_param(ref: str) -> bool

Check if a referenceable parameter with the given ref exists.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def has_ref_param(self, ref: str) -> bool:
    """Check if a referenceable parameter with the given ref exists."""
    return any(ref_param.ref == ref for ref_param in self.ref_params)

Activation

mzmlpy.spectra.Activation dataclass

Activation(element: ElementTree.Element)

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

activation_energy: float | None

Get activation energy for this precursor.

collision_energy property

collision_energy: float | None

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: float | None

Supplemental collision energy (MS:1002680) as recorded, or None (e.g. EThcD supplemental activation).

collision_gas property

collision_gas: str | None

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

collision_gas_pressure: float | None

Get collision gas pressure for this precursor.

ns cached property

ns: str

Get XML namespace from the element tag.

cv_params cached property

cv_params: tuple[CvParam, ...]

The element's cvParams, in document order.

accessions cached property

accessions: frozenset[str]

All cvParam accessions.

names cached property

names: frozenset[str]

All cvParam names.

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

serialize() -> dict[str, object]

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
def serialize(self) -> dict[str, object]:
    """Return the element as nested dicts: ``tag``, ``attributes``, ``text``, ``children``.

    The result is a fresh copy; changing it does not change the wrapped element.
    """
    return {
        "tag": self.element.tag,
        "attributes": dict(self.element.attrib),
        "text": self.element.text,
        "children": [_DataTreeWrapper(child).serialize() for child in self.element],
    }

get_attribute

get_attribute(attr_name: str) -> str | None

Get an attribute value from the element.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_attribute(self, attr_name: str) -> str | None:
    """Get an attribute value from the element."""
    return self.element.attrib.get(attr_name)

get_cv_param

get_cv_param(id: str) -> CvParam | None

Get a cvParam by accession or name, or None if absent.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_cv_param(self, id: str) -> CvParam | None:
    """Get a cvParam by accession or name, or None if absent."""
    for cv_param in self.cv_params:
        if cv_param.accession == id or cv_param.name == id:
            return cv_param
    return None

has_cv_param

has_cv_param(id: str) -> bool

Check if a cvParam with the given accession or name exists.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def has_cv_param(self, id: str) -> bool:
    """Check if a cvParam with the given accession or name exists."""
    return any(cv_param.accession == id or cv_param.name == id for cv_param in self.cv_params)

cv_float

cv_float(id: str) -> float | None

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
def cv_float(self, id: str) -> float | None:
    """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".
    """
    cv_param = self.get_cv_param(id)
    if cv_param is None or cv_param.value is None:
        return None
    try:
        return float(cv_param.value)
    except ValueError as e:
        raise MzmlError(
            f"CV param {cv_param.name or id!r} ({id}) has a non-numeric value {cv_param.value!r}"
        ) from e

cv_int

cv_int(id: str) -> int | None

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
def cv_int(self, id: str) -> int | None:
    """Return a cvParam's value as an int, or None if absent or valueless (see :meth:`cv_float`)."""
    cv_param = self.get_cv_param(id)
    if cv_param is None or cv_param.value is None:
        return None
    try:
        return int(cv_param.value)
    except ValueError as e:
        raise MzmlError(
            f"CV param {cv_param.name or id!r} ({id}) has a non-integer value {cv_param.value!r}"
        ) from e

get_user_param

get_user_param(name: str) -> UserParam | None

Get a userParam by name.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_user_param(self, name: str) -> UserParam | None:
    """Get a userParam by name."""
    for user_param in self.user_params:
        if user_param.name == name:
            return user_param
    return None

has_user_param

has_user_param(name: str) -> bool

Check if a userParam with the given name exists.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def has_user_param(self, name: str) -> bool:
    """Check if a userParam with the given name exists."""
    return any(user_param.name == name for user_param in self.user_params)

get_ref_param

get_ref_param(
    ref: str,
) -> ReferenceableParamGroupRef | None

Get a referenceable parameter by ref.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def get_ref_param(self, ref: str) -> ReferenceableParamGroupRef | None:
    """Get a referenceable parameter by ref."""
    for ref_param in self.ref_params:
        if ref_param.ref == ref:
            return ref_param
    return None

has_ref_param

has_ref_param(ref: str) -> bool

Check if a referenceable parameter with the given ref exists.

Source code in src/mzmlpy/elems/dtree_wrapper.py
def has_ref_param(self, ref: str) -> bool:
    """Check if a referenceable parameter with the given ref exists."""
    return any(ref_param.ref == ref for ref_param in self.ref_params)