import ast


def chromosomesInCluster(hotspots):
    """
    Determine chromosomes in a hotspots file

    :param hotspots: str
        Hotspots filename

    :return: dict
        Chromosomes and first last positions within the chromosomes in the cluster
    """
    chromosomes = dict();

    with open(hotspots, 'r') as fhandle:
        for line in fhandle:
            point = ast.literal_eval(line);
            chromosome = point['chromosome'];
            position = point['position'];
            if chromosome in chromosomes:
                values = chromosomes[chromosome];
                chromosomes[chromosome] = (min(values[0], position), max(values[1], position + 1));
            else:
                chromosomes[chromosome] = (position, position + 1);

    return chromosomes;