rule igvtools:
    """
    The count command (from igvtools) computes average feature density over a specified window size across the genome.
    Common usages include computing coverage for alignment files and counting hits in Chip-seq experiments.
    By default, the resulting file will be displayed as a bar chart when loaded into IGV.


    Required input:
        __igvtools__input: bam file (Supported input file formats are: .sam, .bam, .aligned, .psl, .pslx, and .bed.)

    Required output:
        __igvtools__output:  The output file, which can be binary "tdf" or ascii "wig" format.

    config:

        .. code-block:: yaml

            coverage:
                chromSize_file: A genome id or path to a .chrom.sizes or .genome file.  Default is hg18.

    """
    input:
        __igvtools__input
    params:
        chromSize = config['coverage']['chromSize_file']
    log:
        __igvtools__log
    output:
        __igvtools__output
    threads: 4
    shell:
        """
            igvtools count -z 5 -w 25 -f mean,max --includeDuplicates {input} {output} {params.chromSize}
        """