-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSnakefile
199 lines (150 loc) · 4.66 KB
/
Snakefile
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
import datetime
localrules:
all,
clean,
clean_all,
deploy_nodate,
deploy_date,
deploy_all,
dump_config, #, deploy_force, deploy_all_force
if "builds" not in config:
config["builds"] = {}
if "files" not in config:
configfile: "defaults/parameters.yaml"
if "origins" in config:
include: "workflow/snakemake_rules/preprocess.smk"
if "reference-builds" in config:
config["builds"].update(config["reference-builds"])
# Include rules to handle primary build logic from multiple sequence alignment
# to output of auspice JSONs for a default build.
include: "workflow/snakemake_rules/reference_build.smk"
if "templated-builds" in config:
include: "workflow/snakemake_rules/templated_build.smk"
if len(config["builds"]):
include: "workflow/snakemake_rules/subsampling.smk"
include: "workflow/snakemake_rules/core.smk"
auspice_prefix = config.get("auspice_prefix", "ncov")
auspice_dir = config.get("auspice_dir", "auspice")
build_dir = config.get("build_dir", "builds")
date = datetime.date.today()
suffixes = ["", "_root-sequence", "_tip-frequencies"]
rule all:
input:
[
f"{auspice_dir}/{build}/latest/{auspice_prefix}_{build}{suffix}.json"
for build in config["builds"]
for suffix in suffixes
],
params:
slack_hook=config.get("slackHook", "google.com"),
shell:
"""
curl -X POST -H 'Content-type: application/json' \
--data '{{"text":"Builds done, ready for deployment"}}' \
{params.slack_hook}
"""
# def deploy_files(w):
# return " ".join([f"{auspice_dir}/{w.build}/{auspice_prefix}_{w.build}{w.date}{suffix}.json" for suffix in suffixes])
# rule deploy_force:
# # input: ancient([f"{auspice_dir}/{auspice_prefix}_{{build}}{{date}}{suffix}.json" for suffix in suffixes])
# output: 'deploy-force/{build,[^_]+}{date,.{0}|_.+}_force',
# # nexde url1 input; nexde url2 input
# params: lambda w, input, output: " ; ".join([f'nextstrain deploy {url} {deploy_files(w)} 2>&1 | tee -a {output}' for url in config["builds"][w.build]["deploy_urls"]])
# shell: '{params}'
rule deploy_nodate:
input:
[
f"{auspice_dir}/{{build}}/latest/{auspice_prefix}_{{build}}{suffix}.json"
for suffix in suffixes
],
output:
"deploy/{build}/latest",
# nexde url1 input; nexde url2 input
params:
lambda w, input, output: " ; ".join(
[
f"nextstrain remote upload {url}/{w.build} {input} 2>&1 | tee -a {output}"
for url in config["builds"][w.build]["deploy_urls"]
]
),
shell:
"{params}"
rule deploy_date:
input:
[
auspice_dir
+ f"/{{build}}/{{date}}/{auspice_prefix}_{{build}}_{{date}}{suffix}.json"
for suffix in suffixes
],
output:
"deploy/{build}/{date,[\d-]+}",
# nexde url1 input; nexde url2 input
params:
lambda w, input, output: " ; ".join(
[
f"nextstrain remote upload {url}/{w.build}_{w.date} {input} 2>&1 | tee -a {output}"
for url in config["builds"][w.build]["deploy_urls"]
]
),
shell:
"{params}"
rule deploy_all:
input:
expand("deploy/{build}/latest", build=config["builds"]),
expand("deploy/{build}/{date}", build=config["builds"], date=date),
# rule deploy_all_force:
# input:
# expand("deploy/{build}_force", build=config["builds"])
def dated_deploy(build_name: str):
return f"deploy/{build_name}/{date}"
def undated_deploy(build_name: str):
return f"deploy/{build_name}/latest"
deploy_test_list = [
"europe",
"switzerland",
"germany",
"na-usa",
"united-kingdom",
"global",
"south-america",
"north-america",
"asia",
"africa",
"oceania",
]
rule deploy_test:
input:
[dated_deploy(build_name) for build_name in deploy_test_list],
[undated_deploy(build_name) for build_name in deploy_test_list],
rule clean_all:
params:
"pre-processed",
"data",
"log/*",
"logs/*",
"benchmarks",
auspice_dir,
build_dir,
"deploy/*",
"freezed",
"builds*",
"auspice*",
shell:
"rm -rfv {params}"
rule clean:
params:
"log/*",
"logs/*",
"benchmarks",
auspice_dir,
build_dir,
"deploy/*",
"freezed",
shell:
"rm -rfv {params}"
rule dump_config:
run:
import sys
import ruamel.yaml
yaml = ruamel.yaml.YAML()
yaml.dump(config["builds"], sys.stdout)