code: def to_intermol(self, molecule_types=None):
          
          from intermol.atom import Atom as InterMolAtom
          from intermol.molecule import Molecule
          from intermol.system import System
          import simtk.unit as u
  
          if isinstance(molecule_types, list):
              molecule_types = tuple(molecule_types)
          elif molecule_types is None:
              molecule_types = (type(self),)
          intermol_system = System()
  
          last_molecule_compound = None
          for atom_index, atom in enumerate(self.particles()):
              for parent in atom.ancestors():
                  # Don't want inheritance via isinstance().
                  if type(parent) in molecule_types:
                      # Check if we have encountered this molecule type before.
                      if parent.name not in intermol_system.molecule_types:
                          self._add_intermol_molecule_type(
                              intermol_system, parent)
                      if parent != last_molecule_compound:
                          last_molecule_compound = parent
                          last_molecule = Molecule(name=parent.name)
                          intermol_system.add_molecule(last_molecule)
                      break
              else:
                  # Should never happen if molecule_types only contains
                  # type(self)
                  raise ValueError(
                      'Found an atom {} that is not part of any of '
                      'the specified molecule types {}'.format(
                          atom, molecule_types))
  
              # Add the actual intermol atoms.
              intermol_atom = InterMolAtom(atom_index + 1, name=atom.name,
                                           residue_index=1, residue_name='RES')
              intermol_atom.position = atom.pos * u.nanometers
              last_molecule.add_atom(intermol_atom)
          return intermol_system
docs: Create an InterMol system from a Compound.
  
          Parameters
          ----------
          molecule_types : list or tuple of subclasses of Compound
  
          Returns
          -------
          intermol_system : intermol.system.System