matchms.filtering.metadata_processing.repair_adduct_based_on_smiles module

matchms.filtering.metadata_processing.repair_adduct_based_on_smiles.repair_adduct_based_on_smiles(spectrum_in: <module 'matchms.Spectrum' from '/home/docs/checkouts/readthedocs.org/user_builds/matchms/checkouts/latest/readthedocs/../matchms/Spectrum.py'>, mass_tolerance: float, accept_parent_mass_is_mol_wt: bool = True)[source]

Corrects the adduct of a spectrum based on its SMILES representation and the precursor m/z.

Given a spectrum, this function tries to match the spectrum’s parent mass, derived from its precursor m/z and known adducts, to the neutral monoisotopic mass of the molecule derived from its SMILES representation. If a match is found within a given mass tolerance, the adduct and parent mass of the spectrum are updated.

Parameters:

spectrum_inSpectrum

The input spectrum whose adduct needs to be repaired.

mass_tolerancefloat

Maximum allowed mass difference between the calculated parent mass and the neutral monoisotopic mass derived from the SMILES.

accept_parent_mass_is_mol_wtbool, optional (default=True)

Allows the function to attempt repairing the spectrum’s parent mass by assuming it represents the molecule’s weight. If True, further checks and corrections are made using repair_parent_mass_is_mol_wt.