
rule plotCoverage:
    """
    Summary of bam coverage files in png format. Is part of deeptools http://deeptools.readthedocs.io/en/latest/index.html

    Required input:
        __plotCoverage__input: list of bam files

    Required output:
        __plotCoverage__output: png file
    """
    input:
        __plotCoverage__input
    log:
        __plotCoverage__log
    output:
        tab = __plotCoverage__output_tab,
        file = __plotCoverage__output_file
    threads: 4
    run:
        labels = " ".join(str(os.path.basename(label).split("_")[0]) for label in input.bam)
        shell("plotCoverage --bamfiles {input.bam} --plotFile {output.file} -p 4 --labels " + labels + "--ignoreDuplicates --outRawCounts {output.tab} 2> {log}")
