def boxes_to_atoms(coords, boxes):
  """Maps each box to a list of atoms in that box.

  Given the coordinates of a macromolecule, and a collection of boxes,
  returns a dictionary which maps boxes to the atom indices of the
  atoms in them.

  Parameters
  ----------
  coords: np.ndarray
    Of shape `(N, 3)
  boxes: list
    list of `CoordinateBox` objects.

  Returns
  -------
  dictionary mapping `CoordinateBox` objects to lists of atom coordinates
  """
  mapping = {}
  for box_ind, box in enumerate(boxes):
    box_atoms = []
    for atom_ind in range(len(coords)):
      atom = coords[atom_ind]
      if atom in box:
        box_atoms.append(atom_ind)
    mapping[box] = box_atoms
  return mapping