1

I am trying to run a shell command with snakemake that requires an output directory defined in the command. Specifically, I am trying to use fastqc which has the following required parameters:

fastqc {input} -o {output.dir}

Below are the three versions of my snakefile, none of which worked.

Version 1:

rule QC_rawdata:
    input:
         expand("raw_reads/{sample}_{replicate}.fastq.gz", sample=SAMPLE, replicate=REPLICATE)
    output:
         directory("fastqc_raw_reads/")
    shell:
        "fastqc {input} -o {output}"

Version 2:

rule QC_rawdata:
    input:
         expand("raw_reads/{sample}_{replicate}.fastq.gz", sample=SAMPLE, replicate=REPLICATE)
    output:
         zip=expand("fastqc_raw_reads/{sample}_{replicate}_fastqc.zip", sample=SAMPLE, replicate=REPLICATE),
         html=expand("AA-041_Mus_Sat_Cells_Nelfb-{sample}_{replicate}_fastqc.html", sample=SAMPLE, replicate=REPLICATE)
    shell:
        "fastqc {input} -o {output}"

Error: Syntax error

Version 3:

rule QC_rawdata:
    input:
         expand("raw_reads/{sample}_{replicate}.fastq.gz", sample=SAMPLE, replicate=REPLICATE)
    output:
         directory("fastqc_raw_reads/"),
         zip=expand("fastqc_raw_reads/{sample}_{replicate}_fastqc.zip", sample=SAMPLE, replicate=REPLICATE),
         html=expand("AA-041_Mus_Sat_Cells_Nelfb-{sample}_{replicate}_fastqc.html", sample=SAMPLE, replicate=REPLICATE)
    shell:
        "fastqc {input} -o {output}"

Error: Syntax error

I was using https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#directories-as-outputs as a reference.

I think I am missing some fundamental way in which output directories are defined in snakemake. If I can't point to a specific output file in my shell command then how do I write my snakemake file?

  • Easiest is to define the directory as params: https://stackoverflow.com/a/59771025/9544516 (`rule sortMeRNA`). – Maarten-vd-Sande Jan 20 '20 at 15:57
  • Hi Maarten, If I define my directory as {params}, then should I still define my the 'zip' and 'html' output files in my {output}? or not define output at all? – Hina Bandukwala Jan 20 '20 at 16:23
  • 1
    `output` still needs to be defined, or else snakemake wouldn't execute the rule unless you call it by its name. Either/both of zip and html can be used in `output`. – Manavalan Gajapathy Jan 20 '20 at 18:59
  • Defining my directory as `params` and zip/html files in `output` worked. Thanks @Maarten-vd-Sande – Hina Bandukwala Jan 20 '20 at 21:00

0 Answers0