comparison data_manager/fetch_vep_cache_data.py @ 0:de3516853bde draft default tip

Uploaded
author davidvanzessen
date Fri, 30 Nov 2018 09:56:38 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:de3516853bde
1 import argparse
2 import os
3 import json
4 import re
5 import pprint
6 import subprocess
7 import sys
8
9 if __name__ == "__main__":
10 parser = argparse.ArgumentParser(description="Use VEP INSTALL.pl to download/process the cache for an assembly")
11 parser.add_argument("--output-file")
12 parser.add_argument("--output-dir")
13 parser.add_argument("--assembly")
14 args = parser.parse_args()
15
16 output_file = args.output_file
17 output_dir = args.output_dir
18 assembly = args.assembly
19 extra = args.assembly
20
21 with open(output_file) as output_file_handle:
22 params = json.loads(output_file_handle.read())
23
24 print(output_file)
25 print(output_dir)
26 print(assembly)
27 pprint.pprint(params)
28
29 if not os.path.exists(output_dir):
30 os.makedirs(output_dir)
31
32 vep_install_cmd = ["vep_install", "--NO_HTSLIB", "-a alcf", "--CACHEDIR", output_dir, "--SPECIES", assembly]
33 vep_install_cmd = "vep_install --NO_HTSLIB -a alcf --CACHEDIR {0} --SPECIES {1}".format(output_dir, assembly)
34 print("Running INSTALL.pl")
35 #print(" ".join(vep_install_cmd))
36 print(vep_install_cmd)
37 exit_code = subprocess.call(vep_install_cmd, cwd=output_dir, shell=True)
38 #process = subprocess.Popen(vep_install_cmd, shell=True, cwd=output_dir)
39
40 print(exit_code)
41
42 output_dict = dict(
43 data_tables=dict(
44 vep_cache_data=[{
45 "path": output_dir,
46 "dbkey": assembly,
47 "name": assembly,
48 "value": assembly
49 }]
50 )
51 )
52 with open(output_file, 'w') as output_file_handle:
53 output_file_handle.write(json.dumps(output_dict))
54 sys.exit(0)