matchms.exporting.save_as_msp module
- matchms.exporting.save_as_msp.save_as_msp(spectra: list[Spectrum], filename: str, write_peak_comments: bool = True, file_mode: str = 'a', style: str = 'matchms', peak_sep: str = '\t')[source]
Save spectrum(s) as msp file.
Example:
import numpy as np from matchms import Spectrum from matchms.exporting import save_as_msp # Create dummy spectrum spectrum = Spectrum( mz=np.array([100, 200, 300], dtype="float"), intensities=np.array([10, 10, 500], dtype="float"), metadata={ "charge": -1, "inchi": '"InChI=1S/C6H12"', "precursor_mz": 222.2 } ) # Write spectrum to test file save_as_msp(spectrum, "test.msp")
- Parameters:
spectra – Expected input are match.Spectrum.Spectrum() objects.
filename – Provide filename to save spectrum(s).
write_peak_comments – Writes peak comments to individual peaks after the respective mz/intensity pair when set to True. Default is True.
file_mode – Mode on how to write to file. One of [“w”, “a”] (write/append). Default is append.
style – Converts the keys to required Export style. One of [“massbank”, “nist”, “riken”, “gnps”]. Default is “matchms”
peak_sep – Separator to use for writing the msp file.