Skip to content

Commit

Permalink
Merge pull request #144 from biowdl/BIOWDL-309
Browse files Browse the repository at this point in the history
Add "SampleConfigToSampleReadgroupLists" task to common.wdl
  • Loading branch information
DavyCats authored Sep 18, 2019
2 parents 4886c4f + 4b0fbb4 commit 77fd792
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ that users understand how the changes affect the new version.

version 1.0.0-dev
---------------------------
+ Common: Add "SampleConfigToSampleReadgroupLists" task
+ MultiQC: the "interactive" input is now set to true by default
+ Removed deprecated tasks:
+ bioconda.installPrefix
Expand Down
41 changes: 41 additions & 0 deletions common.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,47 @@ task MapMd5 {
}
}

task SampleConfigToSampleReadgroupLists {
input {
File yaml
String outputJson = "samples.json"

String dockerImage = "biowdl/pyyaml:3.13-py37-slim"
}

command <<<
set -e
mkdir -p $(dirname ~{outputJson})
python <<CODE
import json
import yaml
with open("~{yaml}", "r") as input_yaml:
sample_config = yaml.load(input_yaml)
sample_rg_lists = []
for sample in sample_config["samples"]:
new_sample = {"readgroups": [], "id": sample['id']}
for library in sample["libraries"]:
for readgroup in library["readgroups"]:
new_readgroup = {'lib_id': library['id'], 'id': readgroup['id']}
# Having a nested "reads" struct does not make any sense.
new_readgroup.update(readgroup["reads"])
new_sample['readgroups'].append(new_readgroup)
sample_rg_lists.append(new_sample)
sample_mod_config = {"samples": sample_rg_lists}
with open("~{outputJson}", "w") as output_json:
json.dump(sample_mod_config, output_json)
CODE
>>>
output {
File json = outputJson
}
runtime {
docker: dockerImage
}
}
task StringArrayMd5 {
input {
Expand Down

0 comments on commit 77fd792

Please sign in to comment.