Pytest的装置,用于使用Cromwell运行WDL工作流。
pytest-wdl的Python项目详细描述
Pytest WDL
此包是pytest单元测试框架的插件,该框架允许测试用Workflow Description Language编写的工作流。
依赖关系
安装库时会安装其他python依赖项。
安装
从pypi安装
$ pip install pytest-wdl
从源安装
您可以克隆存储库并安装:
$ make install
或者使用pip从github安装:
$ pip install git+https://github.com/elilillyco/pytest-wdl.git
安装可选依赖项
Pytest WDL的一些可选功能具有按需加载的附加依赖项。例如,要启用工作流的预期和实际BAM文件输出的比较,需要pysam库。
以下数据类型需要“附加”安装:
- 巴姆
为具有额外依赖项的数据类型安装依赖项:
$ pip install pytest-wdl[<data_type>]
要在本地执行此操作,可以克隆repo并运行:
$ pip install -e .[<data_type>]
安装pytest wdl和all附加依赖项:
$ pip install pytest-wdl[all]
用法
pytest wdl插件提供了一组用于pytest的fixture。下面是一个简单的示例:
# test_variant_caller.pydeftest_variant_caller(workflow_data,workflow_runner):inputs=workflow_data.get_dict("bam","bai")inputs["index"]={"fasta":workflow_data["index_fa"],"organism":"human"}expected=workflow_data.get_dict("vcf")workflow_runner("variant_caller/variant_caller.wdl","call_variants",inputs,expected)
此测试将使用指定的输入执行工作流(如下面的工作流),并将输出与指定的预期输出进行比较。
# variant_caller.wdl version 1.0 struct Index { File fasta String organism } workflow call_variants { input { File bam File bai Index index } ... output { File vcf = variant_caller.vcf } }
输入和输出数据与测试脚本在同一目录下的test_data.json
文件中定义:
{"bam":{"url":"http://example.com/my.bam"},"bai":{"url":"http://example.com/my.bam.bai"},"index_fa":{"name":"chr22.fasta"},"vcf":{"url":"http://example.com/expected.vcf.gz","type":"vcf","allowed_diff_lines":2}}
有关详细信息,read the docs。
开发
要开发pytest wdl,请克隆存储库并安装所有依赖项:
$ git clone https://github.com/EliLillyCo/pytest-wdl.git $ pip install -r requirements.txt
要运行完整的生成和单元测试,请运行:
$ make