Mercurial > repos > recetox > msmetaenhancer
comparison msmetaenhancer_wrapper.py @ 0:053ce79ed564 draft
"planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
author | recetox |
---|---|
date | Tue, 11 Jan 2022 15:12:26 +0000 |
parents | |
children | 4ae5b466a805 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:053ce79ed564 |
---|---|
1 import argparse | |
2 import asyncio | |
3 import sys | |
4 | |
5 | |
6 from MSMetaEnhancer import Application | |
7 | |
8 | |
9 def main(argv): | |
10 parser = argparse.ArgumentParser(description="Annotate MSP file.") | |
11 parser.add_argument("--input_file", type=str, help="Path to query spectra file in MSP format.") | |
12 parser.add_argument("--output_file", type=str, help="Path to output spectra file.") | |
13 parser.add_argument("--jobs", type=str, help="Sequence of conversion jobs to be used.") | |
14 args = parser.parse_args() | |
15 | |
16 app = Application() | |
17 | |
18 # import .msp file | |
19 app.load_spectra(args.input_file, file_format='msp') | |
20 | |
21 # curate given metadata | |
22 app.curate_spectra() | |
23 | |
24 # specify requested services and jobs | |
25 services = ['PubChem', 'CTS', 'CIR', 'NLM'] | |
26 | |
27 if len(args.jobs) != 0: | |
28 jobs = [] | |
29 for job in args.jobs.split(","): | |
30 if len(job) != 0: | |
31 jobs.append(job.split()) | |
32 asyncio.run(app.annotate_spectra(services, jobs)) | |
33 else: | |
34 # execute without jobs parameter to run all possible jobs | |
35 asyncio.run(app.annotate_spectra(services)) | |
36 | |
37 # export .msp file | |
38 app.save_spectra(args.output_file, file_format="msp") | |
39 return 0 | |
40 | |
41 | |
42 if __name__ == "__main__": | |
43 main(argv=sys.argv[1:]) |