You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: toy_example/README.md
+32-25
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
# Snakemake toy example
1
+
# Snakemake toy example
2
2
3
-
This is a simple toy example that can be used to start learning the basics of snakemake. This folder contains some data files with simple contents. For example, file 123.txt contains three lines of data, with values 1, 2, and 3. We'll use these simple data along with core command-line tools, included by default in most unix environments, to illustrate the basics of snakemake.
3
+
This is a simple toy example that can be used to start learning the basics of snakemake. This folder contains some extremely simple input files. For example, sampleA.txt contains three lines of data, with values 1, 2, and 3, respectively. We'll use these simple data along with core command-line tools, included by default in most unix environments, to illustrate the basics of snakemake.
4
4
5
5
Note: If you haven't installed snakemake yet, I'd suggest using [conda](https://docs.conda.io/en/latest/miniconda.html) to do so.
6
6
@@ -13,14 +13,14 @@ Get started by expanding Example 1a
13
13
14
14
<details><summary>Expand - Ex. 1a</summary>
15
15
16
-
Create a file named toy.snakefile with the following contents:
16
+
ex-1a.smk has the following contents:
17
17
18
18
rule all:
19
19
input:
20
-
"output/123_rsorted.txt",
21
-
"output/345_rsorted.txt",
22
-
"output/567_rsorted.txt"
23
-
20
+
"output/sampleA_rsorted.txt",
21
+
"output/sampleB_rsorted.txt",
22
+
"output/sampleC_rsorted.txt"
23
+
24
24
rule rsort:
25
25
input:
26
26
"{basename}.txt"
@@ -29,6 +29,10 @@ Create a file named toy.snakefile with the following contents:
29
29
shell:
30
30
"sort -r {input} > {output}"
31
31
32
+
<details><summary>Ex. 1a rulegraph</summary>
33
+

34
+
</details>
35
+
32
36
Topics covered:
33
37
* Targets & dependencies
34
38
* Writing rules
@@ -42,13 +46,13 @@ Writing rules - Generally will have 'input', 'output', and 'shell' blocks (more
42
46
43
47
The rule 'all' is placed at the top of the file (the first rule, anyway), and this is always executed by default. It's being used to define the targets for the workflow.
44
48
45
-
Now perform a dry-run:
49
+
To perform a dry-run:
46
50
47
-
snakemake --snakefile toy.snakefile --dry-run
51
+
snakemake --snakefile ex-1a.smk --dry-run
48
52
49
53
Notice that snakemake keeps track of the wildcards during the evaluation of each rule
50
54
* experiment by changing the targets so they don't match the input files
51
-
55
+
52
56
## You have reached the end of example 1a ✅
53
57
54
58
</details>
@@ -59,7 +63,7 @@ Now we'll make the workflow a bit more interesting. We'll add more rules, use a
59
63
<details><summary>Expand - Ex. 1b</summary>
60
64
61
65
62
-
toy.snakefile contents:
66
+
ex-1b.smk contents:
63
67
64
68
rule all:
65
69
input:
@@ -87,7 +91,7 @@ toy.snakefile contents:
87
91
88
92
rule randsort:
89
93
input:
90
-
"{base}.txt"
94
+
"output/{base}_appended.txt"
91
95
output:
92
96
"output/{base}_randsorted.txt"
93
97
shell:
@@ -100,34 +104,38 @@ toy.snakefile contents:
100
104
"output/{base}_fsorted.txt"
101
105
shell:
102
106
"sleep 2 ; sort -n {input} > {output}"
103
-
104
-
toy_config.yml contents:
107
+
108
+
config-ex-1b.yml contents:
105
109
106
110
basenames:
107
-
- '123'
108
-
- '345'
109
-
- '567'
111
+
- 'sampleA'
112
+
- 'sampleB'
113
+
- 'sampleC'
110
114
append_val: 42
111
115
116
+
<details><summary>Ex. 1b rulegraph</summary>
117
+

118
+
</details>
119
+
112
120
The config
113
121
* How is the config used with this snakefile?
114
-
122
+
115
123
The expand statement
116
124
* The various uses of curly braces can be confusing at first (at least for me)
117
125
*`expand` is distinct from `wildcards`
118
126
* can be thought of as "expand this string (arg 1) into an array of strings, filling in all combinations of values (args 2+ as key-value pairs)
0 commit comments