Snakefile "ymp/rules/multiqc.rules"

Env(name="multiqc", base="bioconda", packages=[
    "multiqc >=1.4"
])

with Stage("qc_multiqc") as S:
    S.doc("""
    Aggregate QC reports using MultiQC
    """)
    rule multiqc_fastqc:
        """Assemble report on all FQ files in a directory"""
        message:
            "Aggregating QC reports for {params.pdir}"
        input:
            fastqc  = "{:prev:}/{:fq_names:}_fastqc.zip"
        output:
            flist   = "{:this:}/file_list.txt",
            report  = "{:this:}/multiqc_report.html",
        log:
                     "{:this:}/multiqc.log"
        params:
            pdir   = "{:prev:}"
        threads:
            1
        conda:
            "multiqc"
        shell: """
        echo {input.fastqc} | tr ' ' '\n' > {output.flist}
        multiqc \
          --verbose \
          --module fastqc \
          --file-list {output.flist} \
          --filename {output.report} \
          --title  {params.pdir} \
          --force \
          > {log} 2>&1
        cp {output.report} {output.report2}
        """