def json2cwl(GATK_json, cwl_dir, cmd_line_options):
"""
Make a cwl file with a given GATK json file in the cwl directory
"""
skeleton_cwl = {
'id': GATK_json['name'],
'cwlVersion': 'v1.0',
'baseCommand': ['java', '-jar', cmd_line_options.gatk_location],
'class': 'CommandLineTool',
'requirements': [
{
"class": "ShellCommandRequirement"
},
{
"class": "InlineJavascriptRequirement",
"expressionLib": [
# Allows you to add annotations
"""function parseTags(param, tags){
if(tags == undefined){
return ' ' + param
}
else{
return ':' + tags.join(',') + ' ' + param
}
}""".replace(" ", "").replace("\n", "")
]
},
{
"class": "DockerRequirement",
"dockerPull": cmd_line_options.docker_container_name
}
]
}
# Create and write the cwl file
fname = GATK_json['name'] + '.cwl'
f = open(os.path.join(cwl_dir, fname), 'a')
cwl_generator(
GATK_json,
skeleton_cwl,
cmd_line_options
)
yaml.round_trip_dump(skeleton_cwl, f) # write the file
f.close()
评论列表
文章目录