forked from broadinstitute/seqr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_new_project_from_vcf_and_ped.py
executable file
·67 lines (56 loc) · 2.75 KB
/
add_new_project_from_vcf_and_ped.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
66
#!/usr/bin/env python2.7
import sys
import os
import argparse
import yaml
from datetime import datetime, date
p = argparse.ArgumentParser("")
p.add_argument("-i", "--project-id", help="Project id", required=True)
p.add_argument("-n", "--project-name", help="Project name", required=True)
p.add_argument("-v", "--vcf", help="The vcf file", required=True)
p.add_argument("-p", "--ped", help="The ped file. If not specified, the sample ids from the VCF will be used instead of the ped file.")
p.add_argument("--no-phenotips", action="store_true", help="don't add to phenotips")
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")
opts = p.parse_args()
vcf = opts.vcf
ped = opts.ped
project_id = opts.project_id
project_name = opts.project_name
if not os.path.isfile(vcf):
p.error("Invalid vcf: " + vcf)
if ped and 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 '%(project_name)s' ",
"python2.7 -u manage.py add_custom_population_to_project %(project_id)s gnomad-exomes",
"python2.7 -u manage.py add_custom_population_to_project %(project_id)s gnomad-genomes",
"python2.7 -u manage.py add_individuals_to_project %(project_id)s " + ("--ped %(ped)s" if ped else "--vcf %(vcf)s"),
"python2.7 -u manage.py add_vcf_to_project %(project_id)s %(vcf)s",
]
if not opts.no_phenotips:
commands += [
"python2.7 -u manage.py add_project_to_phenotips %(project_id)s '%(project_name)s' ",
"python2.7 -u manage.py add_individuals_to_phenotips %(project_id)s --ped %(ped)s ",
]
commands += [
"python2.7 -u manage.py generate_pedigree_images %(project_id)s",
"python2.7 -u manage.py add_default_tags %(project_id)s",
"python2.7 -u manage.py load_project %(project_id)s" + (" --force-annotations --force-clean " if opts.force else ""),
"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 &"
]
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)
#i = input("Do you want to continue? [y/n] ")
if opts.run:
for c in commands:
print(date.strftime(datetime.now(), "%m/%d/%Y %H:%M:%S") + " -- Running: " + c)
sys.stdout.flush()
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