-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSnakefile
356 lines (291 loc) · 8.01 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
if sys.platform != "linux":
raise WorkflowError("Unsupported operating system: Please execute this workflow only on 64 bit Linux (see README).")
import requests
def get_packages(arch):
repodata = requests.get("https://conda.anaconda.org/bioconda/{arch}/repodata.json".format(arch=arch)).json()
packages = set(p["name"] for p in repodata["packages"].values())
return packages
packages = get_packages("linux-64") | get_packages("osx-64") | get_packages("noarch")
rule all:
input:
"plots/add+del.pdf",
expand("figs/fig{f}.pdf", f=[1, 2]),
expand("plots/{plot}.svg",
plot=["downloads",
"ecosystems",
"contributions",
"downloads_violin",
"age-vs-downloads",
"dag"]),
expand("plots/{pkg}.dag.colored.svg",
# identified via scripts/find-most-deps.py
pkg=[
'multigps',
'cnvkit',
'jaffa',
'gimmemotifs',
'mageck-vispr',
'cap-mirseq',
'qcumber'])
############# Collect data ##############
rule get_package_data:
output:
"package-data/{package}.json"
conda:
"envs/analysis.yaml"
resources:
api_requests=1
shell:
"curl -X GET --header 'Accept: application/json' "
"https://api.anaconda.org/package/bioconda/{wildcards.package} "
"> {output} && sleep 1"
rule collect_package_data:
input:
expand("package-data/{package}.json", package=packages)
output:
"package-data/all.tsv"
conda:
"envs/analysis.yaml"
script:
"scripts/collect-pkg-data.py"
rule clone:
output:
"bioconda-recipes/.git/index"
conda:
"envs/git.yaml"
shell:
"rm -rf bioconda-recipes; "
"git clone https://github.com/bioconda/bioconda-recipes.git bioconda-recipes; "
"cd bioconda-recipes; "
"git reset --hard d819a66147566d31316198f89e7744b7a36356fe"
rule git_log:
input:
"bioconda-recipes/.git/index"
output:
"git-log/bioconda-recipes.log"
conda:
"envs/git.yaml"
shell:
'(cd bioconda-recipes && '
'git log '
'--pretty=format:'
'"%h\t%aN\t%aI" '
'--name-only '
# parsing the full log can take a while; for debugging try this arg:
# '--max-count 10 '
'recipes/*) '
'> {output}'
rule get_dag:
input:
"bioconda-recipes/.git/index"
output:
"dag/dag.dot"
shell:
"cd bioconda-recipes; "
"bioconda-utils dag --hide-singletons --format dot "
"recipes config.yml > ../{output}"
rule parse_git_log:
input:
"git-log/bioconda-recipes.log"
output:
"git-log/parsed-log.tsv"
conda:
"envs/analysis.yaml"
script:
"scripts/parse-log.py"
rule collect_pr_data:
output:
"pr/all.tsv"
conda:
"envs/analysis.yaml"
script:
"scripts/collect-pr-data.py"
# This rule purposefully left off the default DAG because this needs
# bioconda_utils + conda-build to parse recipes, which in turn need to be in
# the root environment.
rule collect_summaries:
input:
"bioconda-recipes/.git/index"
output:
"summary/summaries.tsv"
script:
"scripts/collect-summaries-and-urls.py"
################# Plots #################
if "GITHUB_TOKEN" in os.environ:
rule plot_adddel:
output:
"plots/add+del.svg"
conda:
"envs/analysis.yaml"
script:
"scripts/plot-add-del.py"
rule plot_package_degree:
input:
"package-data/all.tsv"
output:
"plots/package_degrees.svg"
conda:
"envs/analysis.yaml"
script:
"scripts/plot-package-degrees.py"
rule plot_dag:
input:
"dag/dag.dot"
output:
"plots/dag.svg"
conda:
"envs/analysis.yaml"
shell:
"set +o pipefail; ccomps -zX#0 {input} | neato -Tsvg -o {output} "
'-Nlabel="" -Nstyle=filled -Nfillcolor="#1f77b4" '
'-Ecolor="#3333335f" -Nwidth=0.2 -LC10 -Gsize="12,12" '
"-Nshape=circle -Npenwidth=0"
rule plot_colored_dag:
input:
pkg='package-data/all.tsv',
dag='dag/dag.dot'
output:
'plots/{pkg}.dag.colored.svg'
conda:
'envs/analysis.yaml'
script:
'scripts/color-dag.py'
# rule plot_colored_dag:
# input:
# 'dag/{pkg}.colored.dot'
# output:
# 'plots/{pkg}.dag.colored.svg'
# conda:
# 'envs/analysis.yaml'
# shell:
# "set +o pipefail; ccomps -zX#0 {input} | neato -Tsvg -o {output} "
# '-Nlabel="" -Nstyle=filled -Nfillcolor="#7777778f" '
# '-Ecolor="#3333335f" -Nwidth=0.2 -LC10 -Gsize="12,12" '
# '-Earrowhead="none" -Nshape=circle -Npenwidth=0 '
# '-Goutputorder=edgesfirst'
rule plot_downloads:
input:
"package-data/all.tsv",
output:
"plots/downloads.svg",
"plots/downloads_violin.svg",
conda:
"envs/analysis.yaml"
script:
"scripts/plot-downloads.py"
rule plot_ecosystems:
input:
"bioconda-recipes/.git/index",
pkg_data="package-data/all.tsv",
bio="summary/hand-edited-summaries.tsv"
output:
"plots/ecosystems.svg"
conda:
"envs/analysis.yaml"
script:
"scripts/plot-ecosystems.py"
rule plot_comparison:
input:
"summary/hand-edited-summaries.tsv"
output:
counts="plots/pkg-count-comparison.svg",
age="plots/age-comparison.svg",
csv="plots/comparison.tsv"
conda:
"envs/analysis.yaml"
script:
"scripts/plot-comparison.py"
rule plot_contributions:
input:
"git-log/parsed-log.tsv"
output:
"plots/contributions.svg"
conda:
"envs/analysis.yaml"
script:
"scripts/plot-contributions.py"
rule plot_age_vs_downloads:
input:
log="git-log/parsed-log.tsv",
pkg="package-data/all.tsv"
output:
"plots/age-vs-downloads.svg"
conda:
"envs/analysis.yaml"
script:
"scripts/plot-age-vs-downloads.py"
rule plot_turnaround:
input:
"pr/all.tsv"
output:
"plots/turnaround.svg"
conda:
"envs/analysis.yaml"
script:
"scripts/plot-turnaround.py"
########### Tables ##############
rule stats:
input:
"bioconda-recipes/.git/index",
pkg="package-data/all.tsv"
output:
"package-data/stats.tsv"
conda:
"envs/analysis.yaml"
script:
"scripts/stats.py"
rule author_list:
input:
"resources/authors.tsv"
output:
table="resources/authors-commits.tsv"
conda:
"envs/analysis.yaml"
script:
"scripts/author-list.py"
rule author_list_tex:
input:
"resources/authors-commits.tsv"
output:
tex="resources/authors.tex",
xlsx="resources/authors.xlsx"
conda:
"envs/analysis.yaml"
script:
"scripts/author-tex.py"
########### Figures #############
rule fig1:
input:
comp="plots/pkg-count-comparison.svg",
age="plots/age-comparison.svg",
downloads="plots/downloads_violin.svg",
ecosystems="plots/ecosystems.svg"
output:
"figs/fig1.svg"
conda:
"envs/analysis.yaml"
script:
"scripts/fig1.py"
rule fig2:
input:
add_del="plots/add+del.svg",
contributions="plots/contributions.svg",
workflow="plots/workflow.svg",
dag="plots/cnvkit.dag.colored.svg",
turnaround="plots/turnaround.svg",
usage="plots/usage.svg"
output:
"figs/fig2.svg"
conda:
"envs/analysis.yaml"
script:
"scripts/fig2.py"
rule convert_svg:
input:
"{prefix}.svg"
output:
"{prefix}.{fmt,(pdf|png)}"
conda:
"envs/cairosvg.yaml"
shell:
"cairosvg -f {wildcards.fmt} {input} -o {output}"