forked from broadinstitute/seqr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_new_project_by_chromosomes.py
executable file
·65 lines (50 loc) · 2.18 KB
/
add_new_project_by_chromosomes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python2.7
import sys
import os
import argparse
import yaml
from datetime import datetime, date
import subprocess
p = argparse.ArgumentParser("")
p.add_argument("-i", "--project-id", help="Project id", required=True)
p.add_argument("-p", "--ped", help="The ped file", required=True)
p.add_argument("-j", "--json", help="JSON files to deserialize", action="append")
p.add_argument("-f", "--force", help="Force annotation", action="store_true")
p.add_argument("-r", dest="run", action="store_true", help="Actually run the commands")
p.add_argument("vcfs", nargs="+", help="The vcf files")
opts = p.parse_args()
ped = opts.ped
project_id = opts.project_id
for vcf in opts.vcfs:
if not os.path.isfile(vcf):
p.error("Invalid vcf: " + vcf)
if not os.path.isfile(ped):
p.error("Invalid ped: " + ped)
commands = [
"kill `pgrep -f continuously_reload_all_projects_daemon.sh`",
"python2.7 -u manage.py add_project %(project_id)s",
"python2.7 -u manage.py add_individuals_to_project %(project_id)s --ped %(ped)s",
#"python2.7 -u manage.py load_project_datastore %(project_id)s",
# "nohup ./continuously_reload_all_projects_daemon.sh &> logs/continuously_load_all_projects_daemon.log &"
]
parallel_commands = ["python2.7 -u manage.py add_vcf_to_project --load %s %s > logs/%s_weisburd__load_%s.log" % (project_id, vcf, date.strftime(datetime.now(), "%Y_%m_%d"), os.path.basename(vcf))
for vcf in opts.vcfs]
commands = map(lambda s: s % globals(), commands)
print(date.strftime(datetime.now(), "%m/%d/%Y %H:%M:%S -- Will run: "))
for c in commands:
print(c)
print("\nIn parallel:")
for p in parallel_commands:
print(p)
#i = input("Do you want to continue? [y/n] ")
if opts.run:
# add metadata
for c in commands:
print(date.strftime(datetime.now(), "%m/%d/%Y %H:%M:%S") + " -- Running: " + c)
r = os.system(c)
if "continuously_reload_all_projects_daemon.sh" not in c and r != 0:
print(date.strftime(datetime.now(), "%m/%d/%Y %H:%M:%S") + " -- Command failed: " + c + "\nExiting.." )
break
# load VCFs
for c in parallel_commands:
subprocess.call("nohup " + c + "&", shell=True)