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