code: def locate_range(self, chrom, start=None, stop=None):
          
  
          slice_chrom = self.locate_key(chrom)
  
          if start is None and stop is None:
              return slice_chrom
  
          else:
  
              pos_chrom = SortedIndex(self.pos[slice_chrom])
              try:
                  slice_within_chrom = pos_chrom.locate_range(start, stop)
              except KeyError:
                  raise KeyError(chrom, start, stop)
              loc = slice(slice_chrom.start + slice_within_chrom.start,
                          slice_chrom.start + slice_within_chrom.stop)
              return loc
docs: Locate slice of index containing all entries within the range
          `key`:`start`-`stop` **inclusive**.
  
          Parameters
          ----------
          chrom : object
              Chromosome or contig.
          start : int, optional
              Position start value.
          stop : int, optional
              Position stop value.
  
          Returns
          -------
          loc : slice
              Slice object.
  
          Examples
          --------
  
          >>> import allel
          >>> chrom = ['chr2', 'chr2', 'chr1', 'chr1', 'chr1', 'chr3']
          >>> pos = [1, 4, 2, 5, 5, 3]
          >>> idx = allel.ChromPosIndex(chrom, pos)
          >>> idx.locate_range('chr1')
          slice(2, 5, None)
          >>> idx.locate_range('chr2', 1, 4)
          slice(0, 2, None)
          >>> idx.locate_range('chr1', 3, 7)
          slice(3, 5, None)
          >>> try:
          ...     idx.locate_range('chr3', 4, 9)
          ... except KeyError as e:
          ...     print(e)
          ('chr3', 4, 9)