def getOffsets(chroms, cj):
    """
    chroms: a sorted list of chromnames, in oreder of chromosomes
    cj: a cooler object.
    returns a dictionary with the offset for each chromosome
    in a submatrix that contains only the listed chromosomes.
    """
    n = len(chroms)
    offset = {}
    offset[chroms[0]] = 0
    for i in range(1,n):
        offset[chroms[i]] = offset[chroms[i-1]] + cj.chromsizes[chroms[i-1]] // cj.binsize + 1
    return offset