comparison data_manager/funannotate.py @ 0:ef7f9e2f32f2 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_funannotate commit 9613152729099079c7465c3d5d42005ef22ca91e"
author iuc
date Thu, 26 Aug 2021 06:54:45 +0000
parents
children 8dff71edbce5
comparison
equal deleted inserted replaced
-1:000000000000 0:ef7f9e2f32f2
1 #!/usr/bin/env python
2
3 import argparse
4 import json
5 import operator
6 import os
7 import subprocess
8 import sys
9 from datetime import datetime
10
11
12 if __name__ == "__main__":
13
14 parser = argparse.ArgumentParser()
15 parser.add_argument('--partial', dest='partial', action='store_true', help='Only download a small subset of data (for testing)')
16 parser.add_argument("version_id")
17 parser.add_argument("datatable_name")
18 parser.add_argument("galaxy_datamanager_filename")
19 args = parser.parse_args()
20
21 with open(args.galaxy_datamanager_filename) as fh:
22 config = json.load(fh)
23
24 output_directory = config.get("output_data", [{}])[0].get("extra_files_path", None)
25 data_manager_dict = {}
26 data_manager_dict["data_tables"] = config.get("data_tables", {})
27 data_manager_dict["data_tables"][args.datatable_name] = data_manager_dict[
28 "data_tables"
29 ].get(args.datatable_name, [])
30
31 os.mkdir(output_directory)
32 cmd_args = ['funannotate', 'setup', '-d', output_directory, '-b', 'all']
33 if args.partial:
34 cmd_args += ['-i', 'merops', '-b', 'eukaryota']
35 proc = subprocess.Popen(args=cmd_args, shell=False, cwd=output_directory)
36 return_code = proc.wait()
37 if return_code:
38 print("Error downloading Funannotate database.", file=sys.stderr)
39 sys.exit(return_code)
40
41 version_id = datetime.today().strftime('%Y-%m-%d-%H%M%S')
42
43 version = '1.0'
44
45 data_manager_dict["data_tables"][args.datatable_name].append(
46 dict(
47 value=version_id,
48 description="Funannotate database %s" % version_id,
49 format_version=version,
50 path=output_directory,
51 )
52 )
53
54 data_manager_dict["data_tables"][args.datatable_name].sort(
55 key=operator.itemgetter("value"), reverse=True
56 )
57 with open(args.galaxy_datamanager_filename, "w") as fh:
58 json.dump(data_manager_dict, fh, indent=2, sort_keys=True)