matchms.filtering.metadata_processing.require_correct_ionmode module

matchms.filtering.metadata_processing.require_correct_ionmode.require_correct_ionmode(spectrum_in: Spectrum, ion_mode_to_keep) Spectrum | None[source]

Validates the ion mode of a given spectrum. If the spectrum’s ion mode doesn’t match the ion_mode_to_keep, it will be removed and a log message will be generated.

Parameters:
  • spectrum_in (Spectrum) – The input spectrum to be validated. If None, the function will return None.

  • ion_mode_to_keep (str) – Desired ion mode (‘positive’, ‘negative’, or ‘both’). If not one of these, a ValueError is raised.

Returns:

The validated spectrum if its ion mode matches the desired one, or None otherwise.

Return type:

Spectrum or None