-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimputation_server_submit.wdl
114 lines (98 loc) · 3.26 KB
/
imputation_server_submit.wdl
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
version 1.0
workflow imputation_server_submit {
input {
String hostname
String token
Array[File] vcf_files
Boolean multi_chrom_file
String build
String refpanel
String population
String password
Boolean? meta_imputation
Float? r2_filter
}
if (multi_chrom_file) {
call split_by_chrom {
input: vcf_file = vcf_files[0]
}
}
Array[File] inp_files = select_first([split_by_chrom.chrom_files, vcf_files])
call submit {
input: hostname = hostname,
token = token,
vcf_files = inp_files,
build = build,
refpanel = refpanel,
population = population,
password = password,
meta_imputation = meta_imputation,
r2_filter = r2_filter
}
output {
String job_id = submit.job_id
}
meta {
author: "Stephanie Gogarten"
email: "[email protected]"
}
}
task split_by_chrom {
input {
File vcf_file
}
String vcf_basename = basename(vcf_file, ".vcf.gz")
command {
bcftools index ${vcf_file}
bcftools query -f '%CHROM\n' ${vcf_file} | sort -u > chroms.txt
while read -r c; do
bcftools view --regions "$c" -Oz -o ${vcf_basename}".$c.vcf.gz" ${vcf_file}
done < chroms.txt
}
output {
Array[File] chrom_files = glob("*.vcf.gz")
}
runtime {
docker: "staphb/bcftools:1.16"
}
}
task submit {
input {
String hostname
String token
Array[File] vcf_files
String build
String refpanel
String population
String password
Boolean meta_imputation = true
Float r2_filter = 0
}
String server = hostname + "/api/v2/jobs/submit/" + if (hostname == "https://imputation.biodatacatalyst.nhlbi.nih.gov") then "imputationserver" else "minimac4"
String panel = if (refpanel == "topmed-r3") then "apps@" + refpanel else refpanel
command {
#mkdir ~/.imputationbot
#printf -- "- hostname: %s\n token: %s\n" ${hostname} ${token} > ~/.imputationbot/imputationbot.instances
#imputationbot impute --file ${sep=' ' vcf_files} --build ${build} --refpanel ${refpanel} --population ${population} --password ${password} > tmp
#grep -o \'job.*\' tmp | sed "s/'//g" > job_id.txt
curl ${server} \
-X "POST" \
-H "X-Auth-Token: ${token}" \
-F "files=@${sep='" -F "files=@' vcf_files}" \
-F "build=${build}" \
-F "refpanel=${panel}" \
-F "population=${population}" \
-F "meta=${true='yes' false ='no' meta_imputation}" \
-F "r2Filter=${r2_filter}" \
-F "password=${password}" \
> submission_results.json
cat submission_results.json | json id > job_id.txt
}
output {
String job_id = read_string("job_id.txt")
File submission_results = "submission_results.json"
}
runtime {
docker: "uwgac/primed-imputation:0.2.0"
}
}