This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Snakemake error AttributeError: 'Resources' object has no attribute 'tmpdir'

I have built a Snakemake pipeline which has been designed for paired-end reads. I have made a trial with single-end reads, and got this error. I am not sure it is related to the change of reads design, and to be honest I do not understand the error message! Is it looking familiar to anyone?

rule bwa_mem:           
    input: reads/Beg9_1.fastq.gz, genome.amb, genome.ann, genome.bwt, genome.pac, genome.sa
    output: mapped/Beg9_1.bam 
    log: logs/bwa_mem/Beg9_1.log     
    jobid: 267                  
    wildcards: sample=Beg9_1        
    threads: 2                

Activating conda environment: /mnt/shared/scratch/usr/pipeline/experiment_1/.snakemake/conda/f436a072                                                                  
Traceback (most recent call last):           
  File "/mnt/shared/scratch/usr/pipeline/experiment_1/.snakemake/scripts/tmpqwgv8exe.wrapper.py", line 25, in <module>                                                 
    java_opts = get_java_opts(snakemake)
                ^^^^^^^^^^^^^^^^^^^^^^^^                                                   
  File "/mnt/shared/home/usr/miniforge3/envs/snakemake/lib/python3.6/site-packages/snakemake_wrapper_utils/java.py", line 38, in get_java_opts                                     
    java_opts += f" -Djava.io.tmpdir={snakemake.resources.tmpdir}"                         
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^                           
AttributeError: 'Resources' object has no attribute 'tmpdir'                               
[Tue Dec 19 10:59:39 2023]
Error in rule bwa_mem:                       
    jobid: 267                                                                                                                                                                         
    output: mapped/Beg9_1.bam                                                              
    log: logs/bwa_mem/Beg9_1.log (check log file(s) for error message)                     
    conda-env: /mnt/shared/scratch/usr/pipeline/experiment_1/.snakemake/conda/f436a072                                                                                 

RuleException:   
CalledProcessError in line 92 of /mnt/shared/scratch/usr/pipeline/experiment_1/workflow/Snakefile:                                                                     
Command 'source /mnt/shared/training/conda/bin/activate '/mnt/shared/scratch/usr/pipeline/experiment_1/.snakemake/conda/f436a072'; set -euo pipefail;  python /mnt/shared/scratch/usr/pipeline/experiment_1/.snakemake/scripts/tmpqwgv8exe.wrapper.py' returned non-zero exit status 1.                                                       
  File "/mnt/shared/scratch/usr/pipeline/experiment_1/workflow/Snakefile", line 92, in __rule_bwa_mem                                                                  
  File "/mnt/shared/home/usr/miniforge3/envs/snakemake/lib/python3.6/concurrent/futures/thread.py", line 56, in run                                                                
Shutting down, this might take some time.
Exiting because a job execution failed. Look above for error message 
python bwa snakemake

Can you post the code for the rule?

Here it is:

# https://snakemake-wrappers.readthedocs.io/en/stable/wrappers/bwa/mem.html
rule bwa_mem:
        input:
                reads=["reads/{sample}.fastq.gz"],
                idx=multiext("genome", ".amb", ".ann", ".bwt", ".pac", ".sa"),
        output:
                "mapped/{sample}.bam",
        log:
                "logs/bwa_mem/{sample}.log",
        params:
                extra=r"-R '@RG\tID:{sample}\tSM:{sample}'",
                sorting="none",  # Can be 'none', 'samtools' or 'picard'.
                sort_order="queryname",  # Can be 'queryname' or 'coordinate'.
                sort_extra="",  # Extra args for samtools/picard.
        threads: 8
        wrapper:
                "v2.9.1/bio/bwa/mem"

Since it's complaining about tmpdir and resources my only guess would be to try explicitly defining it in the resources directive.

resources:
    tmpdir='/path/to/tmp/dir'

0 answers

No answers yet.

Log in to answer this question.