Commit afc509c3 authored by Sander Bollen's avatar Sander Bollen
Browse files

Add fastqc wrapper

fastqc gives exit code zero and a corrupted
zip file on empty uncompressed fastq files.
The wrapper checks if the zip file exists. If so,
it checks its integrity. If that fails, it empties
the file. If the zip file does not exist, it
creates an empty file.
parent 34d84603
......@@ -29,6 +29,7 @@ mpy = fsrc_dir("src", "merge_stats.py")
seq = fsrc_dir("src", "seqtk.sh")
fqpy = fsrc_dir("src", "fastqc_stats.py")
tsvpy = fsrc_dir("src", "stats_to_tsv.py")
fqsc = fsrc_dir("src", "safe_fastqc.sh")
if FASTQ_COUNT is None:
fqc = "python {0}".format(fsrc_dir("src", "fastq-count.py"))
......@@ -412,30 +413,32 @@ rule fastqc_merged:
"""Run fastqc on merged fastq files"""
input:
r1=out_path("{sample}/pre_process/{sample}.merged_R1.fastq.gz"),
r2=out_path("{sample}/pre_process/{sample}.merged_R2.fastq.gz")
r2=out_path("{sample}/pre_process/{sample}.merged_R2.fastq.gz"),
fq=fqsc
params:
odir=out_path("{sample}/pre_process/merged_fastqc")
output:
r1=out_path("{sample}/pre_process/merged_fastqc/{sample}.merged_R1_fastqc.zip"),
r2=out_path("{sample}/pre_process/merged_fastqc/{sample}.merged_R2_fastqc.zip")
conda: "envs/fastqc.yml"
shell: "fastqc --nogroup -o {params.odir} {input.r1} {input.r2} "
"&& touch {output.r1} && touch {output.r2}"
shell: "bash {input.fq} {input.r1} {input.r2} "
"{output.r1} {output.r2} {params.odir}"
rule fastqc_postqc:
"""Run fastqc on fastq files post pre-processing"""
input:
r1=out_path("{sample}/pre_process/{sample}.cutadapt_R1.fastq"),
r2=out_path("{sample}/pre_process/{sample}.cutadapt_R2.fastq")
r2=out_path("{sample}/pre_process/{sample}.cutadapt_R2.fastq"),
fq=fqsc
params:
odir=out_path("{sample}/pre_process/postqc_fastqc")
output:
r1=out_path("{sample}/pre_process/postqc_fastqc/{sample}.cutadapt_R1_fastqc.zip"),
r2=out_path("{sample}/pre_process/postqc_fastqc/{sample}.cutadapt_R2_fastqc.zip")
conda: "envs/fastqc.yml"
shell: "fastqc --nogroup -o {params.odir} {input.r1} {input.r2} "
"&& touch {output.r1} && touch {output.r2}"
shell: "bash {input.fq} {input.r1} {input.r2} "
"{output.r1} {output.r2} {params.odir}"
## fastq-count
......
#!/usr/bin/env bash
set -eu
set -o pipefail
input_r1=${1}
input_r2=${2}
output_r1=${3}
output_r2=${4}
odir=${5}
fastqc --nogroup -o ${odir} ${input_r1} ${input_r2}
if [[ -f ${output_r1} ]]; then
unzip -t ${output_r1} || truncate -s0 ${output_r1}
else
touch ${output_r1}
fi
if [[ -f ${output_r2} ]]; then
unzip -t ${output_r2} || truncate -s0 ${output_r2}
else
touch ${output_r2}
fi
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment