matchms.importing.parsing_utils module

Helper functions for parsing metadata.

matchms.importing.parsing_utils.find_by_key(data: list | dict, target: str) Any[source]

Helper function to return entries from nested list/dictionary.

  • data – Nested dictionary or list in which entry should be searched.

  • target – Name of field to search for in data.

matchms.importing.parsing_utils.parse_mzml_mzxml_metadata(spectrum_dict: dict) dict[source]

Parse relevant mzml (or mzxml) metadata entries.



Spectrum dictionary containing metadata fields. Metadata parsing may easily break when field key names vary. The following metadata information is considered here:

  • precursor_mz, searched for in:

    –>”precursor”/”precursorMz”–> … –> “selected ion m/z”/”precursorMz”

  • charge, searched for in:

    –> “charge state”/”polarity”

  • title, searched for in “spectrum title”

  • scan_number, searched for in “num”

  • scan_start_time, searched for in “scan start time”

  • retention_time, searched for in “retentionTime”

matchms.importing.parsing_utils.parse_spectrum_dict(spectrum: Dict, metadata_harmonization, spectrum_type='pyteomics') Spectrum[source]

Parse a spectrum dict (as read from a msp file for instance) to a matchms Spectrum.

matchms.importing.parsing_utils.sort_by_mz(mz, intensities)[source]

Sort mz values and intensities by mz.