Mercurial > repos > recetox > msp_merge
view msp_merge.py @ 1:d38d73004bba draft default tip
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msp_merge commit b757d35278216a1f43bd53ea687a951b005e47df
author | recetox |
---|---|
date | Wed, 20 Mar 2024 12:28:31 +0000 |
parents | c2862090e321 |
children |
line wrap: on
line source
import argparse from itertools import chain from typing import List from matchms import Spectrum from matchms.exporting import save_as_msp from matchms.importing import load_from_msp def read_spectra(filenames: str) -> List[Spectrum]: """Read spectra from files. Args: filenames (str): Paths to MSP files from which to load each spectrum. Returns: List[Spectrum]: Spectra stored in the file. """ spectra = list(chain(*[load_from_msp(file) for file in filenames])) return spectra listarg = argparse.ArgumentParser() listarg.add_argument('--filenames', nargs='+', type=str) listarg.add_argument('--outfilename', type=str) args = listarg.parse_args() if __name__ == "__main__": spectra = read_spectra(args.filenames) save_as_msp(spectra, args.outfilename)