BWA-mem not working with Snakemake + singularity
0
1
Entering edit mode
16 months ago
brunobsouzaa ▴ 830

Hi everyone, good morning. I'm falling into an issue using bwa mem inside Snakemake + Singularity, which I've investigated and can't find a way to override. BWA works fine outside singularity. The code is:

    import os                                                               
    import snakemake.io                                                     
    import glob                                                             

    configfile: "../config.yaml"                                            

    (SAMPLES,) = glob_wildcards("/home/ubuntu/samples/{sample}_R1.fastq.gz")

    # generate dag.svg diagram                                              
    # snakemake --dag all | dot -Tsvg > dag.svg                             

    rule all:                                                               
           input:
                    expand("/home/ubuntu/Germinativo/aln/inter_files/SAM/{sample}.aln.sam", sample=SAMPLES)

    rule bwa_map:
        input:
            R1="/home/ubuntu/samples/{sample}_R1.fastq.gz",
            R2="/home/ubuntu/samples/{sample}_R2.fastq.gz",
            ref=config['REF']
        output:
            sam_out="/home/ubuntu/Germinativo/aln/inter_files/SAM/{sample}.aln.sam"
        params:
            rg="@RG\\tID:lab\\tLB:AGILENT\\tSM:{sample}\\tPL:ILLUMINA"
        threads: 2
        singularity:
            "docker://biocontainers/bwa:v0.7.17_cv1"
        shell:
            "bwa mem -M -t {threads} -R '{params.rg}' {input.ref} {input.R1} {input.R2} > {output.sam_out}"

I've already followed this thread and this other thread but nothing seems to work. So, that's probably something I'm missing.

The error it shows is :

RuleException:
CalledProcessError in line 29 of /home/ubuntu/scripts/snakemake/singularity/Snakefile:
Command ' singularity exec --home /home/ubuntu/scripts/snakemake/singularity -B /home/ubuntu/samples:/data --bind /usr/lib/python3/dist-packages:/mnt/snakemake /home/ubuntu/scripts/snakem
ake/singularity/.snakemake/singularity/6443b3814f9b68bb6a33e838b8d4b84c.simg bash -c 'set -euo pipefail;  bwa mem -M -t 2 /home/ubuntu/Germinativo/GenRef/hg19/chromFa/hg19.fa /home/ubuntu
/samples/1124274_R1.fastq.gz /home/ubuntu/samples/1124274_R2.fastq.gz > /home/ubuntu/Germinativo/aln/inter_files/SAM/1124274.aln.sam'' returned non-zero exit status 1.
  File "/home/ubuntu/scripts/snakemake/singularity/Snakefile", line 29, in __rule_bwa_map
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run

Code is being run with:

snakemake -j2 --use-singularity --singularity-args "-B /home/ubuntu/samples/:/data" --verbose

Appreciate any help. Thanks in advance.

snakemake bwa singularity • 1.3k views
ADD COMMENT
0
Entering edit mode

how would Snakemake know you are now using /data instead of /home/ubuntu/samples/? and what about /home/ubuntu/Germinativo/aln/inter_files/SAM/?

ADD REPLY
0
Entering edit mode

I'm mounting /data inside container using --singularity-args "-B /home/ubuntu/samples/:/data" The output dir is located on my local server, it should have no problem saving on it!

ADD REPLY
0
Entering edit mode

normally binding syntax source_on_host:destination_in_container. so Snakemake doesn't know anything about a directory called "data" because your script hardcodes the host directories.

  1. Write a hello world script that is just bash to confirm your input and output directories exist as you think
  2. Write a simpler recipe in Snakemake that just moves /data/foo to /data/bar. maybe just use relative paths.
  3. Build toward your bwa_map
ADD REPLY
0
Entering edit mode

did you resolve this?

ADD REPLY
0
Entering edit mode

I did not... I'm using Docker instead.

ADD REPLY

Login before adding your answer.

Traffic: 1225 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6