snakemake进阶 - 2.调用容器 - singularity

业务需求,目前docker方案在所使用的集群中不可行,所以使用的是singularity 解决方案。
首先我们看一个没有使用镜像的rule

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
rule VEP_anno:
input:
vcf = "{product}__{sample}/Analyze/{type}/{muttype}.final.vcf",
output:
anno_out = "{product}__{sample}/Analyze/{type}/{muttype}.vcfanno.tab",
benchmark:
"benchmark/anno__{product}__{sample}__{type}__{muttype}"
resources:
mem_mb = 4000
threads: 4
shell:
"""

export PERL5LIB=""
export PATH={bin_path}/bin:$PATH

{config[conda][vep]} \
--fork 4 --assembly GRCh37 --offline --refseq --exclude_predicted --cache --format vcf --vcf_info_field ANN --force_overwrite --tab --verbose --no_escape --everything --shift_3prime 1 --dir_plugins /ifstj2/B2C_RD_H1/Research_and_Development/03.database/VEP_plugins/VEP_plugins-release-108 --plugin TSSDistance --plugin TERT --custom /ifstj2/B2C_RD_H1/Personal/liubo/0.Pipeline/aio.NewAnnotation/subpipeline/submodel_annotation_vep/Database/human_maked.gene.gff.gz,,gff --custom /ifstj2/B2C_RD_H1/Research_and_Development/03.database/vep_inhouse_data/clinvar.vcf.gz,ClinVar,vcf,exact,0,CLNSIG,CLNREVSTAT,CLNDN \
--dir_cache /ifstj2/B2C_RD_H1/Research_and_Development/03.database/vep_cache_dir --fasta /ifstj2/B2C_RD_H1/Research_and_Development/03.database/Hg19/hg19.fa
-i {input.vcf} -o {output.anno_out}

可以看到这是一个使用vep进行注释的rule,如果需要在snakemake中使用镜像,rule层面,只需要添加 singularity字段,并说明需要使用的镜像,其中镜像可以是本地的 sif文件,也可以是远程仓库docker镜像 docker://ensembl-vep:release_108.2 (会从远程仓库拉去镜像,需要机器能链接网络)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
rule VEP_anno:
input:
vcf = "/ifstj2/B2C_RD_H1/Personal/liubo/singularity/22S03467478.indel.final.vcf",
output:
anno_out = "/ifstj2/B2C_RD_H1/Personal/liubo/singularity/22S03467478.indel.vcfanno.tab",
resources:
mem_mb = 4000
threads: 4
singularity: "ensembl-vep_release_108.2.sif",
singularity: "docker://ensembl-vep:release_108.2",
shell:
"""
vep --fork 4 --cache --dir_cache /ifstj2/B2C_RD_H1/Research_and_Development/03.database/vep_cache_dir --assembly GRCh37 --offline --refseq --exclude_predicted --fasta /ifstj2/B2C_RD_H1/Research_and_Development/03.database/Hg19/hg19.fa -i {input.vcf} -o {output.anno_out} --format vcf --vcf_info_field ANN --force_overwrite --tab --verbose --no_escape --everything --shift_3prime 1 --dir_plugins /ifstj2/B2C_RD_H1/Research_and_Development/03.database/VEP_plugins/VEP_plugins-release-108 --plugin TSSDistance --plugin TERT --custom /ifstj2/B2C_RD_H1/Personal/liubo/0.Pipeline/aio.NewAnnotation/subpipeline/submodel_annotation_vep/Database/human_maked.gene.gff.gz,,gff --custom /ifstj2/B2C_RD_H1/Research_and_Development/03.database/vep_inhouse_data/clinvar.vcf.gz,ClinVar,vcf,exact,0,CLNSIG,CLNREVSTAT,CLNDN
"""

但是使用镜像时,由于会在虚拟环境进行任务分析,所以这时候,有些数据库文件我们需要在进行任务投递时,通过–singularity-args 进行显性的声明

1
2
3
4
/ifstj2/B2C_COM_H1/PipeAdmin/02.software/Conda/bin/snakemake \
--use-singularity \#使用镜像启动容器分析
--singularity-args " -B /ifstj2/B2C_RD_H1/Personal/liubo " \#配置启动容器时的参数,可以借此完成目录的挂载
-s VEP_anno.smk

-------------本文结束感谢您的阅读-------------