-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSnakefile
95 lines (71 loc) · 2.21 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
######################################################
# #
# Cluster Tutorial Snakefile: #
# Analyzing and plotting book text #
# #
######################################################
# # Setting the workflow config file (if desired)
# # NOTE: If using, uncomment lines 12 and 13 then
# # comment out line 18
# configfile: "config/config.yaml"
# BOOKS = config['BOOKS']
# OR
# Defining book names within workflow
BOOKS = glob_wildcards('books/{book}.txt').book
# Defining which rules to run locally when submitted to cluster
# (will not be ran as job submissions)
localrules: all, clean, make_archive
### Running the Workflow ###
# Run the entire workflow
rule all:
input:
'results/zipf_analysis.tar.gz'
# Delete everything so we can re-run things
rule clean:
shell:
'''
rm -rf results/ __pycache__/
'''
### Workflow Rules ###
### 1. Generating Results ###
# Count words in one of our "books"
rule count_words:
input:
script='code/wordcount.py',
book='books/{book}.txt'
output:
data='results/{book}.dat'
shell:
'python {input.script} {input.book} {output.data}'
# Create a plot for each book
rule make_plot:
input:
script='code/plotcount.py',
book=rules.count_words.output.data
output:
plot='results/{book}.png'
shell:
'python {input.script} {input.book} {output.plot}'
# Generate summary table
rule zipf_test:
input:
script='code/zipf_test.py',
book=expand(rules.count_words.output.data,
book=BOOKS)
output:
table='results/results.txt'
shell:
'python {input.script} {input.book} > {output.table}'
### 2. Archiving Results ###
# Create an archive with all of our results
rule make_archive:
input:
data=expand(rules.count_words.output.data,
book=BOOKS),
plot=expand(rules.make_plot.output.plot,
book=BOOKS),
table=rules.zipf_test.output.table
output:
tar='results/zipf_analysis.tar.gz'
shell:
'tar -czvf {output.tar} {input}'