rule multiqc:
    """
    MultiQC aggregates results from bioinformatics analyses across many
    samples into a single report.

    It searches a given directory for analysis logs and compiles a HTML
    report. It's a general use tool, perfect for summarising the output from
    numerous bioinformatics tools.

    :reference: http://multiqc.info/

    Required input:
         __multiqc__input_dir: an input directory where to find data and logs

    Required output:
        __multiqc__output: multiqc_report.html in the input directory

    Config:

        .. code-block:: yaml

            multiqc:
                options: "-c multiqc_config.yaml -f -x *.zip -e htseq" #any options recognised by multiqc
                output-directory:  " " #name of the output directory where to write results

    :note: if the directory exists, it is overwritten
    """

    input:
        __multiqc__input
    log:
        __multiqc__logs
    output:
        __multiqc__output
    params:
        inputdir = __multiqc__input_dir,
        options = config['multiqc']['options'],
        outdir = config['multiqc']['output-directory']
    shell:
        """
        multiqc {params.inputdir} -o {params.outdir} {params.options}  2> {log}
        """

