def ring_atoms(mol):
  """Return a number that describes the ring membership of `mol`.

  The number encodes the number of each kind of atom that is in a ring.
  The algorithm below works because there will never be >9 atoms in
  a molecule.
  Args:
    mol: Molecule

  Returns:
    a whole number
  """
  result = 0
  for atom in mol.GetAtoms():
    if atom.IsInRing():
      z = atom.GetAtomicNum()
      if z == 6:
        result += 1
      elif z == 7:
        result += 100
      elif z == 8:
        result += 1000

  return result