I'm trying to use Singularity within one of my Snakemake rules. This works as expected when running my Snakemake pipeline locally. However, when I try to submit using sbatch onto my computing cluster, I run into errors. I'm wondering if you have any suggestions about how to translate the local pipeline to one that can work on the cluster. Thank you in advance!
The rule which causes errors uses Singularity to call variants with DeepVariant:
# Call variants with DeepVariant.
rule deepvariant_call:
input:
ref_path='/labs/jandr/walter/varcal/data/refs/{ref}.fa',
bam='results/{samp}/bams/{samp}_{mapper}_{ref}.rmdup.bam'
params:
nshards='1',
version='0.7.0'
threads: 8
output:
vcf='results/{samp}/vars/{samp}_{mapper}_{ref}_deep.g.vcf.gz'
shell:
'singularity exec --bind /srv/gsfs0 --bind /labs/jandr/walter/ /home/kwalter/.singularity/shub/deepvariant-docker-deepvariant:0.7.0.simg \
/labs/jandr/walter/tb/test/scripts/call_deepvariant.sh {input.ref_path} {input.bam} {params.nshards} {params.version} {output.vcf} '
#
# Error in rule deepvariant_call:
# jobid: 17
# output: results/T1-XX-2017-1068_S51/vars/T1-XX-2017-1068_S51_bowtie2_H37Rv_deep.g.vcf.gz
# shell:
# singularity exec --bind /srv/gsfs0 --bind /labs/jandr/walter/ /home/kwalter/.singularity/shub/deepvariant-docker-deepvariant:0.7.0.simg; /labs/jandr/walter/tb/test/scripts/call_deepvariant.sh /labs/jandr/walter/varcal/data/refs/H37Rv.fa results/T1-XX-2017-1068_S51/bams/T1-XX-2017-1068_S51_bowtie2_H37Rv.rmdup.bam 1 0.7.0 results/T1-XX-2017-1068_S51/vars/T1-XX-2017-1068_S51_bowtie2_H37Rv_deep.g.vcf.gz
# (one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)
I submit jobs to the cluster with the following:
snakemake -j 128 --cluster-config cluster.json --cluster "sbatch -A {cluster.account} --mem={cluster.mem} -t {cluster.time} -c {threads}"
As seen in the resolved command of error message where semi-colon separates two lines of shell:
instead of whitespace, this error is due to string formatting in shell:
.
You could use triple-quoted format:
shell:
'''
singularity exec --bind /srv/gsfs0 --bind /labs/jandr/walter/ /home/kwalter/.singularity/shub/deepvariant-docker-deepvariant:0.7.0.simg \
/labs/jandr/walter/tb/test/scripts/call_deepvariant.sh {input.ref_path} {input.bam} {params.nshards} {params.version} {output.vcf}
'''
Or, each line within single quotes:
shell:
'singularity exec --bind /srv/gsfs0 --bind /labs/jandr/walter/ /home/kwalter/.singularity/shub/deepvariant-docker-deepvariant:0.7.0.simg \'
'/labs/jandr/walter/tb/test/scripts/call_deepvariant.sh {input.ref_path} {input.bam} {params.nshards} {params.version} {output.vcf}'