Last active
March 20, 2020 14:44
-
-
Save kaspermunch/56e287cd7e52d8fd48a8148820dad422 to your computer and use it in GitHub Desktop.
Separate GWF workflows for two similar analyses
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'], | |
} | |
workflow_name = 'no.masking' | |
wf = Workflow(name=workflow_name) | |
globals()[workflow_name] = wf | |
for pop, paths in input_files.items(): | |
step_one_tasks = wf.map(step_one_template, paths, name=f"step_one_{pop}") | |
step_two_tasks = wf.map(step_two_template, step_one_tasks.outputs, name=f"step_two_{pop}") | |
workflow_name = 'repeat.masking' | |
wf = Workflow(name=workflow_name) | |
globals()[workflow_name] = wf | |
for pop, paths in input_files.items(): | |
mask_tasks = wf.map(mask_template, paths, name=f"mask_{pop}") | |
step_one_tasks = wf.map(step_one_template, mask_tasks.outputs, name=f"step_one_{pop}") | |
step_two_tasks = wf.map(step_two_template, step_one_tasks.outputs, name=f"step_two_{pop}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment