annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
1 import argparse
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
2 import asyncio
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
3 import sys
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
4
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
5
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
6 from MSMetaEnhancer import Application
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
7
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
8
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
9 def main(argv):
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
10 parser = argparse.ArgumentParser(description="Annotate MSP file.")
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
11 parser.add_argument("--input_file", type=str, help="Path to query spectra file in MSP format.")
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
12 parser.add_argument("--output_file", type=str, help="Path to output spectra file.")
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
13 parser.add_argument("--jobs", type=str, help="Sequence of conversion jobs to be used.")
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
14 args = parser.parse_args()
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
15
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
16 app = Application()
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
17
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
18 # import .msp file
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
19 app.load_spectra(args.input_file, file_format='msp')
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
20
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
21 # curate given metadata
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
22 app.curate_spectra()
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
23
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
24 # specify requested services and jobs
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
25 services = ['PubChem', 'CTS', 'CIR', 'NLM']
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
26
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
27 if len(args.jobs) != 0:
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
28 jobs = []
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
29 for job in args.jobs.split(","):
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
30 if len(job) != 0:
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
31 jobs.append(job.split())
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
32 asyncio.run(app.annotate_spectra(services, jobs))
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
33 else:
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
34 # execute without jobs parameter to run all possible jobs
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
35 asyncio.run(app.annotate_spectra(services))
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
36
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
37 # export .msp file
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
38 app.save_spectra(args.output_file, file_format="msp")
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
39 return 0
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
40
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
41
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
42 if __name__ == "__main__":
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
43 main(argv=sys.argv[1:])