calculate coverage for positions in range start -> end

def calc_coverage(ref, start, end, length, nucs):
    """
    calculate coverage for positions in range start -> end
    """
    ref = ref[start - 1:end]
    bases = 0
    for pos in ref:
        for base, count in list(pos.items()):
            if base in nucs:
                bases += count
    return float(bases)/float(length)