import warnings


def get_chromosome_reads(bam):
    """ This function returns statistics about mapped/unmapped reads per chromosome as they are stored in the index.
    It makes use of the method get_index_statistics() from the pysam module. 
    Parameters
    ----------
    bam : dict, It is the output of the function  pysam.AlignmentFile(bamfile, "rb")              

    Returns
    -------
    mapped_reads : dict[str, list]
        Syntax 'I' | [mapped, unmapped, total reads]

    """
    stats = bam.get_index_statistics()
    mapped_reads = {}
    for stat in stats:
        mapped_reads[stat[0]] = [stat[1], stat[2], stat[3]]
        if stat[2] != 0:
            warnings.warn("Unmapped reads found in chromosome " + stat[0])

    return mapped_reads