matchms.filtering.metadata_processing.add_parent_mass module
- matchms.filtering.metadata_processing.add_parent_mass.add_parent_mass(spectrum_in: Spectrum, estimate_from_adduct: bool = True, overwrite_existing_entry: bool = False, estimate_from_charge: bool = True, clone: bool | None = True) Spectrum | None[source]
Add estimated parent mass to metadata (if not present yet).
Method to calculate the parent mass from given precursor m/z together with charge and/or adduct. Will take precursor m/z from “precursor_mz” as provided by running add_precursor_mz. For estimate_from_adduct=True this function will estimate the parent mass based on the mass and charge of known adducts. The table of known adduct properties can be found under
matchms/data/known_adducts_table.csv.- Parameters:
spectrum_in – Input spectrum.
estimate_from_adduct – When set to True, use adduct to estimate actual molecular mass (“parent mass”). Default is True. Switches back to charge-based estimate if adduct does not match a known adduct.
overwrite_existing_entry – Default is False. If set to True, a newly computed value will replace existing ones.
estimate_from_charge – Default is True. If set to True, the charge will be used to estimate the parent mass. Adduct of the form [M+H]+, [M+H]2+, [M-H]- etc are assumed.
clone – Optionally clone the Spectrum.
- Returns:
Spectrum with added parent mass, or None if not present.
- Return type:
Spectrum or None