code: func (i *Index) Chunks(rid int, beg, end int) []bgzf.Chunk {
  	if rid < 0 || rid >= len(i.refs) {
  		return nil
  	}
  	i.sort()
  	ref := i.refs[rid]
  
  	// Collect candidate chunks according to a scheme modified
  	// from the one described in the SAM spec under section 5
  	// Indexing BAM.
  	var chunks []bgzf.Chunk
  	for _, bin := range reg2bins(int64(beg), int64(end), i.minShift, i.depth) {
  		b := uint32(bin)
  		c := sort.Search(len(ref.bins), func(i int) bool { return ref.bins[i].bin >= b })
  		if c < len(ref.bins) && ref.bins[c].bin == b {
  			left := vOffset(ref.bins[c].left)
  			for _, chunk := range ref.bins[c].chunks {
  				if vOffset(chunk.End) > left {
  					chunks = append(chunks, chunk)
  				}
  			}
  		}
  	}
  
  	// Sort and merge overlaps.
  	if !sort.IsSorted(byBeginOffset(chunks)) {
  		sort.Sort(byBeginOffset(chunks))
  	}
  
  	return adjacent(chunks)
  }
docs: // Chunks returns a []bgzf.Chunk that corresponds to the given interval.