def estimate_wig_interval(wig):
    """When a Wig object (variable step) is given, estimate the median interval between points
        Just take a few random samples, and estimate the median interval.
    """

    chroms = wig.get_chroms()
    if not chroms: return None
    
    n_random_positions = 10
    intervals = []
    for chrom in chroms:
        len_this_chr = len(wig[chrom][0])
        a = randints(0, len_this_chr, 2 * n_random_positions)
        a.sort()
        starts = [a[i] for i in xrange(len(a)) if a%2 == 0]
        ends = [a[i] for i in xrange(len(a)) if 2%a == 1]

        for start, end in itertools.izip(starts, ends):
             intervals.append(median(diff(wig[chrom][start:end])))
             
    return median(intervals)
dataset/ETHPy150Open taoliu/taolib/Assoc/inout.py/estimate_wig_interval/swapped operands of `%`