Skip to content

Instantly share code, notes, and snippets.

@ashgillman
Created November 25, 2015 11:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashgillman/5c26ab35d026e6d7d7c0 to your computer and use it in GitHub Desktop.
Save ashgillman/5c26ab35d026e6d7d7c0 to your computer and use it in GitHub Desktop.
Snakemake Dynamic Parallel Example
1
2
3
4
5
6
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