Skip to content

Instantly share code, notes, and snippets.

@kaspermunch
Last active March 20, 2020 14:42
Show Gist options
  • Save kaspermunch/bced04b24761b7264f419613338fa943 to your computer and use it in GitHub Desktop.
Save kaspermunch/bced04b24761b7264f419613338fa943 to your computer and use it in GitHub Desktop.
Manual naming reused GWF templates
from gwf import Workflow, AnonymousTarget
def mask_template(path):
inputs = {'path': path}
outputs = {'path': path + '.masked'}
options = {}
spec = """./some_command {}""".format(path)
return AnonymousTarget(inputs=inputs, outputs=outputs, options=options, spec=spec)
def step_one_template(path):
inputs = {'path': path}
outputs = {'path': path + '.first'}
options = {}
spec = """./some_command {}""".format(path)
return AnonymousTarget(inputs=inputs, outputs=outputs, options=options, spec=spec)
def step_two_template(path):
inputs = {'path': path}
outputs = {'path': path + '.second'}
options = {}
spec = """./some_command {}""".format(path)
return AnonymousTarget(inputs=inputs, outputs=outputs, options=options, spec=spec)
input_files = {'CEU': ['ceu_chr1.txt', 'ceu_chr2.txt'],
'CHB': ['chb_chr1.txt', 'chb_chr2.txt'],
}
gwf = Workflow()
for pop, paths in input_files.items():
step_one_tasks = gwf.map(step_one_template, paths, name=f"no_repeats_step_one_{pop}")
step_two_tasks = gwf.map(step_two_template, step_one_tasks.outputs, name=f"no_repeats_step_two_{pop}")
for pop, paths in input_files.items():
mask_tasks = gwf.map(mask_template, paths, name=f"with_repeats_{pop}")
step_one_tasks = gwf.map(step_one_template, mask_tasks.outputs, name=f"with_repeats_step_one_{pop}")
step_two_tasks = gwf.map(step_two_template, step_one_tasks.outputs, name=f"with_repeats_step_two_{pop}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment