Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tasks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
biowdl
tasks
Commits
d230e3ff
Commit
d230e3ff
authored
6 years ago
by
Ruben Vorderman
Browse files
Options
Downloads
Patches
Plain Diff
add samplesheet
parent
f7ac6150
No related branches found
No related tags found
1 merge request
!37
Add samplesheet structs
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
samplesheet.wdl
+66
-0
66 additions, 0 deletions
samplesheet.wdl
with
66 additions
and
0 deletions
samplesheet.wdl
0 → 100644
+
66
−
0
View file @
d230e3ff
version 1.0
struct Readgroup {
String id
File R1
String R1_md5
File? R2
String R2_md5
}
struct Library {
String id
Array[Readgroup]+ readgroups
}
struct Sample {
String id
Array[Library]+ libraries
}
task sampleConfigFileToStruct {
input {
File sampleConfigFile
String outputJson = "output.json"
}
command {
python3 <<CODE
import yaml
import json
def nested_dicts_to_lists(dictionary):
new_dict = dict()
for key, value in dictionary.items():
if type(value) == dict:
new_dict[key] = dict_to_item_list_with_id(value)
else:
new_dict[key] = value
return new_dict
def dict_to_item_list_with_id(dictionary):
items = []
for sub_key, sub_dictionary in dictionary.items():
item_dict = dict(id=sub_key, **nested_dicts_to_lists(sub_dictionary))
items.append(item_dict)
return items
with open("~{sampleConfigFile}", "r") as samplesheet:
samplesheet_dict = yaml.load(samplesheet)
sample_struct = nested_dicts_to_lists(samplesheet_dict)
with open("~{outputJson}", "w") as output_json:
output_json.write(json.dumps(sample_struct))
CODE
}
output {
Map[String,Array[Sample]] map = read_json(outputJson)
Array[Sample] samples = map["samples"]
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment