matchms.exporting.save_as_mgf module

matchms.exporting.save_as_mgf.save_as_mgf(spectrums: List[matchms.Spectrum.Spectrum], filename: str)[source]

Save spectrum(s) as mgf file.

losses of spectrum will not be saved.

Example:

import numpy
from matchms import Spectrum
from matchms.exporting import save_as_mgf

# Create dummy spectrum
spectrum = Spectrum(mz=numpy.array([100, 200, 300], dtype="float"),
                    intensities=numpy.array([10, 10, 500], dtype="float"),
                    metadata={"charge": -1,
                              "inchi": '"InChI=1S/C6H12"',
                              "precursor_mz": 222.2})

# Write spectrum to test file
save_as_mgf(spectrum, "test.mgf")
Parameters
  • spectrums – Expected input are match.Spectrum.Spectrum() objects.

  • filename – Provide filename to save spectrum(s).