rule samtools_depth:
    """
    Samtools Depth creates a BED file with the coverage depth for each base
    position. It can also compute multiple BAM files and concatenate results in
    one BED file.

    Required input:
        - __samtools_depth__input: Sorted BAM file or list of bam file.

    Required output:
        - __samtools_depth__output: BED file with coverage for each base.

    Required log:
        - __samtools_depth__log: Log file with stderr of samtools.

    Reference:
        - http://www.htslib.org/doc/samtools.html
    """
    input:
        __samtools_depth__input
    output:
        __samtools_depth__output
    log:
        __samtools_depth__log
    shell:
        """
        samtools depth -aa {input} > {output} 2> {log}
        """
