comparison msmetaenhancer_wrapper.py @ 0:ce612a11b455 draft

"planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 26bede767f65ec97ac84b8cc3309db0aced22d53"
author recetox
date Tue, 22 Mar 2022 15:33:37 +0000
parents
children 8338640d8676
comparison
equal deleted inserted replaced
-1:000000000000 0:ce612a11b455
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 parser.add_argument("--log_file", type=str, help="Path to log with details of the annotation process.")
15 args = parser.parse_args()
16
17 app = Application(log_file=args.log_file)
18
19 # import .msp file
20 app.load_spectra(args.input_file, file_format='msp')
21
22 # curate given metadata
23 app.curate_spectra()
24
25 # specify requested services and jobs
26 services = ['PubChem', 'CTS', 'CIR', 'NLM', 'RDKit', 'IDSM', 'BridgeDB']
27
28 if len(args.jobs) != 0:
29 jobs = []
30 for job in args.jobs.split(","):
31 if len(job) != 0:
32 jobs.append(job.split())
33 asyncio.run(app.annotate_spectra(services, jobs))
34 else:
35 # execute without jobs parameter to run all possible jobs
36 asyncio.run(app.annotate_spectra(services))
37
38 # export .msp file
39 app.save_spectra(args.output_file, file_format="msp")
40 return 0
41
42
43 if __name__ == "__main__":
44 main(argv=sys.argv[1:])