Last active
March 20, 2020 14:44
-
-
Save kaspermunch/4b68113df3d07ebd226f141d2a6439c7 to your computer and use it in GitHub Desktop.
Separate GWF workflows for each population
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
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'], | |
} | |
for pop, paths in input_files.items(): | |
workflow_name = pop | |
wf = Workflow(name=workflow_name) | |
globals()[workflow_name] = wf | |
step_one_tasks = wf.map(step_one_template, paths) | |
step_two_tasks = wf.map(step_two_template, step_one_tasks.outputs) | |
# The advantage/drawback is that you need to run each workflow separately like this: | |
# gwf -f workflow.py:CEU run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment