Mercurial > repos > recetox > matchms_split
diff matchms_split.py @ 4:0cf68b536cd1 draft
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit f79a5b51599254817727bc9028b9797ea994cb4e
author | recetox |
---|---|
date | Tue, 27 Jun 2023 14:25:30 +0000 (22 months ago) |
parents | 169c72b2ce79 |
children | 114617e6ad33 |
line wrap: on
line diff
--- a/matchms_split.py Thu May 25 09:06:58 2023 +0000 +++ b/matchms_split.py Tue Jun 27 14:25:30 2023 +0000 @@ -3,23 +3,10 @@ import os 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(filename: str) -> List[Spectrum]: - """Read spectra from file. - - Args: - filename (str): Path to .msp file from which to load the spectra. - - Returns: - List[Spectrum]: Spectra contained in the file. - """ - return list(load_from_msp(filename, True)) - - def get_spectra_names(spectra: list) -> List[str]: """Read the keyword 'compound_name' from a spectra. @@ -67,17 +54,6 @@ return outpath -def split_spectra(filename, outdir): - """Save individual MSP spectra files in the destination directory. - - Args: - filename (str): MSP file that contains the spectra. - outdir (str): Path to destination directory where split spectra files are saved. - """ - make_outdir(outdir) - return write_spectra(filename, outdir) - - def split_round_robin(iterable, num_chunks): chunks = [list() for _ in range(num_chunks)] index = itertools.cycle(range(num_chunks)) @@ -100,7 +76,7 @@ if __name__ == "__main__": - spectra = load_from_msp(filename) + spectra = load_from_msp(filename, metadata_harmonization=True) make_outdir(outdir) if method == "one-per-file":