def center_middle(r, window_size):
  """
  Center a region on its middle and expand it to window_size bases.

  :return: the new region.
  """
  res = copy.copy(r)
  mid = res.start + (len(res) / 2)
  res.start = mid - (window_size / 2)
  res.end = res.start + window_size
  return res
Center a region on its middle and expand it to window_size bases.

  :return: the new region.