matchms.filtering.derive_formula_from_name module

matchms.filtering.derive_formula_from_name.derive_formula_from_name(spectrum_in: Spectrum, remove_formula_from_name: bool = True) Spectrum[source]

Detect and remove misplaced formula in compound name and add to metadata.

Method to find misplaced formulas in compound name based on regular expression. This will not chemically test the detected formula, so the search is limited to frequently occuring types of shape ‘C47H83N1O8P1’.

Parameters
  • spectrum_in – Input spectrum.

  • remove_formula_from_name – Remove found formula from compound name if set to True. Default is True.

matchms.filtering.derive_formula_from_name.looks_like_formula(formula)[source]

Return True if input string has expected format of a molecular formula. Does only consider most frequent atoms found in many name strings.