annotate msmetaenhancer_wrapper.py @ 4:e329be622dc8 draft

"planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 9a2276670c6ebf147ccd2cdd1cc54b306af3d20c"
author recetox
date Fri, 08 Apr 2022 06:34:08 +0000
parents b48c57453a25
children 1d649315904c
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.")
2
4ae5b466a805 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit f09a5b3ee451d78dc025baee5eccb099f71be2b4"
recetox
parents: 0
diff changeset
14 parser.add_argument("--log_file", type=str, help="Path to log with details of the annotation process.")
0
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
15 args = parser.parse_args()
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
16
2
4ae5b466a805 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit f09a5b3ee451d78dc025baee5eccb099f71be2b4"
recetox
parents: 0
diff changeset
17 app = Application(log_file=args.log_file)
0
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
18
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
19 # import .msp file
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
20 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
21
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
22 # curate given metadata
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
23 app.curate_spectra()
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
24
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
25 # specify requested services and jobs
3
b48c57453a25 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 26bede767f65ec97ac84b8cc3309db0aced22d53"
recetox
parents: 2
diff changeset
26 services = ['PubChem', 'CTS', 'CIR', 'NLM', 'RDKit', 'IDSM', 'BridgeDB']
0
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
27
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
28 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
29 jobs = []
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
30 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
31 if len(job) != 0:
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
32 jobs.append(job.split())
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
33 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
34 else:
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
35 # 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
36 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
37
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
38 # export .msp file
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
39 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
40 return 0
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
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
43 if __name__ == "__main__":
053ce79ed564 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/msmetaenhancer commit 2c9c75f7d0c5fcadf1fe0284dd767ea5c6f6be51"
recetox
parents:
diff changeset
44 main(argv=sys.argv[1:])