def get_samples():
samples = Path("/root").glob("*fastqc.zip")
return samples
WORKDIR = "/root/"
rule fastqc:
input: join(WORKDIR, 'fastq', 'raw', "{sample}.fastq")
output:
html = join(WORKDIR, "QC", "fastqc", 'raw', "Sample_{sample}", "_{sample}_fastqc.html")
# Specify zip as the output for every sample from fastqc
zip = join(WORKDIR, "QC", "fastqc", 'raw', "Sample_{sample}", "_{sample}_fastqc.zip")
params:
join(WORKDIR, "QC","fastqc", 'raw', "Sample_{sample}")
run:
if not os.path.exists(join(WORKDIR, str(params))):
os.makedirs(join(WORKDIR, str(params)))
shell("fastqc -o {params} --noextract -k 5 -t 8 -f fastq {input} 2>{log}")
rule multiqc:
input:
aligned_sequences = join(WORKDIR, "plasmid_wells_aligned_sequences.csv")
# Specify zip as the input for every sample from fastqc
zip = expand(
join(WORKDIR, "QC", "fastqc", 'raw', "Sample_{sample}", "_{sample}_fastqc.zip"), sample=get_samples()
)
output: directory(join(WORKDIR, "QC", "multiqc_report", 'raw'))
params:
join(WORKDIR, "QC", "fastqc", 'raw')
benchmark:
join(BENCHMARKDIR, "multiqc.txt")
log:
join(LOGDIR, "multiqc.log")
shell:
# Explicitly pass the input into the script instead of the Snakefile rule `params`
# Before: "multiqc {params} -o {output} --force"
# After
"multiqc {input.zip} -o {output} --force"