Get all the bin numbers for a particular interval defined by
        (start, end]
486363
def bins(start, end):
        
        if end - start < 536870912:
            offsets = [585, 73, 9, 1]
        else:
            raise BigException
            offsets = [4681, 585, 73, 9, 1]
        binFirstShift = 17
        binNextShift = 3

        start = start >> binFirstShift
        end = (end - 1)  >> binFirstShift

        bins = [1]
        for offset in offsets:
            bins.extend(range(offset + start, offset + end + 1))
            start >>= binNextShift
            end >>= binNextShift
        return frozenset(bins)
1078977
def _getSnapshotIndex(self, t):
        
        if t>self.tmax or t<self.tmin:
            raise ValueError("Requested time outside of baseline stored in binary file.")
        # Bisection method
        l = 0
        r = len(self)
        while True:
            bi = l+(r-l)//2
            if self.t[bi]>t:
                r = bi
            else:
                l = bi
            if r-1<=l:
                bi = l
                break
        return bi, self.t[bi]
423153
def intervals_union(S):
    
    E = [(low, -1) for (low, high) in S]
    E += [(high, +1) for (low, high) in S]
    nb_open = 0
    last = None
    retval = []
    for x, _dir in sorted(E):
        if _dir == -1:
            if nb_open == 0:
                last = x
            nb_open += 1
        else:
            nb_open -= 1
            if nb_open == 0:
                retval.append((last, x))
    return retval
1113587
def find_range(self, interval):
        """"""
        return self.find(self.tree, interval, self.start, self.end)
179269
def intersectingInterval(self, start, end):
    
    # find all intervals in this node that intersect start and end
    l = []
    for x in self.data.starts:
      xStartsAfterInterval = (x.start > end and not self.openEnded) or \
                             (x.start >= end and self.openEnded)
      xEndsBeforeInterval = (x.end < start and not self.openEnded) or \
                            (x.end <= start and self.openEnded)
      if ((not xStartsAfterInterval) and (not xEndsBeforeInterval)):
        l.append(x)

    # process left subtree (if we have one) if the requested interval begins
    # before mid
    if self.left is not None and start <= self.data.mid:
      l += self.left.intersectingInterval(start, end)

    # process right subtree (if we have one) if the requested interval ends
    # after mid
    if self.right is not None and end >= self.data.mid:
      l += self.right.intersectingInterval(start, end)

    return l
1110463
def get_bin(self, *args, **kwargs):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.BinLookupSession.get_bin
        return Bin(
            self._provider_manager,
            self._get_provider_session('bin_lookup_session').get_bin(*args, **kwargs),
            self._runtime,
            self._proxy)
1137963
def _get_children_path_interval(cls, path):
        """"""
        return (path + cls.alphabet[0] * cls.steplen,
                path + cls.alphabet[-1] * cls.steplen)
1323422
def getbyteslice(self, start, end):
        """"""
        c = self._rawarray[start:end]
        return c
651450
def gen_time_intervals(start, end, delta):
    
    curr = start
    while curr < end:
        yield curr
        curr += delta
1005760
def find(self, start, end, chrom=None):
        """"""
        intervals = self.intervals[chrom]
        ilen = len(intervals)
        # NOTE: we only search for starts, since any feature that starts within max_len of
        # the query could overlap, we must subtract max_len from the start to get the needed
        # search space. everything else proceeds like a binary search.
        # (but add distance calc for candidates).
        if not chrom in self.max_len: return []
        ileft  = binsearch_left_start(intervals, start - self.max_len[chrom], 0, ilen)
        iright = binsearch_right_end(intervals, end, ileft, ilen)
        query = Feature(start, end)
        # we have to check the distance to make sure we didnt pick up anything 
        # that started within max_len, but wasnt as long as max_len
        return [f for f in intervals[ileft:iright] if distance(f, query) == 0]
1301447
def binned_bitsets_by_chrom( f, chrom, chrom_col=0, start_col=1, end_col=2):
    """"""
    bitset = BinnedBitSet( MAX )
    for line in f:
        if line.startswith("#"): continue
        fields = line.split()
        if fields[chrom_col] == chrom:
            start, end = int( fields[start_col] ), int( fields[end_col] )
            bitset.set_range( start, end-start )
    return bitset
118993
def range_end(self):
        '''
        '''
        count = self.count
        range_end = self.range_start + self.limit - 1
        if count < range_end:
            range_end = count
        return range_end
1048101
def containsi(self, begin, end, data=None):
        
        return Interval(begin, end, data) in self
1227612
def readpartial(self, start, end):
        ''
        #return self.jfs.raw('%s?mode=bin' % self.path,
        return self.jfs.raw(url=self.path, params={'mode':'bin'},
                            # note that we deduct 1 from end because
                            # in http Range requests, the end value is included in the slice,
                            # whereas in python, it is not
                            extra_headers={'Range':'bytes=%s-%s' % (start, end-1)})
1255208
def get_bins(self):
        
        if self.retrieved:
            raise errors.IllegalState('List has already been retrieved.')
        self.retrieved = True
        return objects.BinList(self._results, runtime=self._runtime)
86781
def _get_content_range(start: Optional[int], end: Optional[int], total: int) -> str:
    
    start = start or 0
    end = (end or total) - 1
    return "bytes %s-%s/%s" % (start, end, total)
909998
def _get_bin_width(stdev, count):
    

    w = int(round((3.5 * stdev) / (count ** (1.0 / 3))))
    if w:
        return w
    else:
        return 1