matchms.importing.load_from_msp module

matchms.importing.load_from_msp.contains_metadata(rline: str) bool[source]

Check if line contains Spectrum metadata.

matchms.importing.load_from_msp.get_peak_comment(rline: str) str[source]

Get the peak comment from the line containing the peak information.

matchms.importing.load_from_msp.get_peak_tuples(rline: str) Iterator[str][source]

Splits line at ‘;’ and performs additional string cleaning.

matchms.importing.load_from_msp.get_peak_values(peak: str) Tuple[float, float][source]

Get the m/z and intensity value from the line containing the peak information.

matchms.importing.load_from_msp.load_from_msp(filename: str, metadata_harmonization: bool = True) Generator[matchms.Spectrum.Spectrum, None, None][source]

MSP file to a Spectrum objects Function that reads a .msp file and converts the info in Spectrum objects.

Parameters
  • filename – Path of the msp file.

  • metadata_harmonization (bool, optional) – Set to False if metadata harmonization to default keys is not desired. The default is True.

Yields

Yield a spectrum object with the data of the msp file

Example:

from matchms.importing import load_from_msp

# Download msp file from MassBank of North America repository at https://mona.fiehnlab.ucdavis.edu/
file_msp = "MoNA-export-GC-MS-first10.msp"
spectrums = list(load_from_msp(file_msp))
matchms.importing.load_from_msp.parse_metadata(rline: str, params: dict)[source]

Reads metadata contained in line into params dict.

matchms.importing.load_from_msp.parse_msp_file(filename: str) Generator[dict, None, None][source]

Read msp file and parse info in list of spectrum dictionaries.