json2cwl.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:gatk-cwl-generator 作者: wtsi-hgi 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号