Created
November 25, 2015 11:37
-
-
Save ashgillman/5c26ab35d026e6d7d7c0 to your computer and use it in GitHub Desktop.
Snakemake Dynamic Parallel Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 | |
2 | |
3 | |
4 | |
5 | |
6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rule all: | |
input: 'output.txt' | |
rule clean: | |
shell: 'rm input_* intermediate_* output.txt' | |
rule merge: | |
input: dynamic('intermediate_{n}.txt') | |
output: 'output.txt' | |
shell: 'cat {input} > {output}' | |
rule parallel: | |
input: 'input_{n,\d+}.txt' | |
output: 'intermediate_{n}.txt' | |
shell: 'cat {input} > {output} && echo processed >> {output}' | |
rule split: | |
input: 'input.txt' | |
output: dynamic('input_{n}.txt') | |
run: | |
with open(input[0], 'r') as infile: | |
for n, line in enumerate(infile.readlines()): | |
with open('input_{}.txt'.format(n), 'w+') as outfile: | |
outfile.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment