xnn.ffnn.common.typing.assign_atom_types#

xnn.ffnn.common.typing.assign_atom_types(structure, forcefield, *, charge=0, bonds=None, return_mol=False)[source]#

Assign the force field’s atom types to a structure.

Parameters:
  • structure (object) – Anything to_rdkit() accepts.

  • forcefield (ForceField, str or object) – A resolved force field, a spec for read_forcefield() ("oplsaa", a .frc path, …), or any object exposing templates / fragments dicts in the same shape (an OPLSLibrary read from a .frc file does). It must carry templates.

  • charge (int, optional) – Total charge, for bond perception from coordinates.

  • bonds (sequence of (int, int), optional) – Known connectivity (see to_rdkit()).

  • return_mol (bool, optional) – Also return the RDKit molecule (whose bonds give the topology).

Returns:

  • list of str – The atom type per atom, in input order.

  • rdkit.Chem.Mol – Only when return_mol is set.

Raises:
  • AtomTypingError – If any atom matches no template, or two fragments disagree.

  • ValueError – If the force field has no templates.