Snakefile "ymp/rules/fastqc.rules"

Env(name="fastqc", base="bioconda", packages=["fastqc"])


with Stage("qc_fastqc") as S:
    S.doc("""
    Quality screen reads using FastQC

    >>> ymp make toy.qc_fastqc
    """)

    rule qc_fastqc:
        """Run FastQC on read files"""
        message:
            "Creating QC report for {input}"
        input:
            "{:prev:}/{:target:}.{:pairnames:}.fq.gz"
        output:
            "{:this:}/{target}.{:pairnames:}_fastqc.html",
            "{:this:}/{target}.{:pairnames:}_fastqc.zip"
        log:
            "{:this:}/{target}_fastqc.log"
        threads:
            1  # fastqc cannot use more than 1 thread per file
        params:
            k=7,
            mem=icfg.mem("4g")
        conda:
            "fastqc"
        shell: """
        fastqc \
         -t {threads} \
         -o $(dirname {output[0]}) \
         {input} \
         -k {params.k} \
         >{log} 2>&1
        """

    rule all_fastqc:
        message:
            "Finished {output}"
        input:
            "{:this:}/{:targets:}.{:pairnames:}_fastqc.zip"
        output:
            touch("{:this:}/all_targets.stamp")