Skip to content

Data Processing

mzmlpy.elems.data_processing.DataProcessing dataclass

DataProcessing(element: ElementTree.Element)

Bases: _DataTreeWrapper

Named collection of ordered processing methods describing how spectral data was transformed.

ns cached property

ns: str

Get XML namespace from the element tag.

serialize

serialize() -> dict

return the full element content

Source code in src/mzmlpy/elems/dtree_wrapper.py
59
60
61
62
63
64
65
66
def serialize(self) -> dict:
    """return the full element content"""
    return {
        "tag": self.element.tag,
        "attributes": 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
68
69
70
def get_attribute(self, attr_name: str) -> str | None:
    """Get an attribute value from the element."""
    return self.element.attrib.get(attr_name)

ProcessingMethod

mzmlpy.elems.data_processing.ProcessingMethod dataclass

ProcessingMethod(element: ElementTree.Element)

Bases: _ParamGroup

A single data processing step applied to the spectral data, with an order index and software reference.

ns cached property

ns: str

Get XML namespace from the element tag.

cv_params cached property

cv_params: list[CvParam]

Parse cvParams from the XML element.

accessions cached property

accessions: set[str]

Get a set of all accession numbers from the cvParams.

names cached property

names: set[str]

Get a set of all names from the cvParams.

user_params property

user_params: list[UserParam]

Parse userParams from the XML element.

ref_params property

ref_params: list[ReferenceableParamGroupRef]

Get a list of all referenceable parameters from the XML element.

serialize

serialize() -> dict

return the full element content

Source code in src/mzmlpy/elems/dtree_wrapper.py
59
60
61
62
63
64
65
66
def serialize(self) -> dict:
    """return the full element content"""
    return {
        "tag": self.element.tag,
        "attributes": 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
68
69
70
def get_attribute(self, attr_name: str) -> str | None:
    """Get an attribute value from the element."""
    return self.element.attrib.get(attr_name)

get_cvparm

get_cvparm(id: str) -> CvParam | None

Get a cvParam by accession or name.

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

has_cvparm

has_cvparm(id: str) -> bool

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

Source code in src/mzmlpy/elems/dtree_wrapper.py
101
102
103
def has_cvparm(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)

get_user_param

get_user_param(name: str) -> UserParam | None

Get a userParam by name.

Source code in src/mzmlpy/elems/dtree_wrapper.py
133
134
135
136
137
138
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
140
141
142
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
153
154
155
156
157
158
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
160
161
162
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)