xnn.ffnn.common.typing.assign_atom_types#

xnn.ffnn.common.typing.assign_atom_types(structure, forcefield, *, charge=0, bonds=None, return_mol=False, return_details=False, orders=True)[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()).

  • orders (bool, optional) – Perceive bond orders when bonds are given (see to_rdkit()).

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

  • return_details (bool, optional) – Also return what the fragments assigned besides the types: a dict with "charges" (per-atom partial charge from the matching fragment’s charges list, None where no fragment matched), "residues" (per atom, (fragment match index, position in the fragment) or None; the position is the atom-map number of the pattern atom when the fragment SMARTS carries atom maps, else the pattern atom’s index), "fragment_names" (per atom, the fragment name or None) and "mol". Residue-based force fields (AMBER) read their charges and improper ordering from these.

Returns:

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

  • rdkit.Chem.Mol – Only when return_mol is set (and return_details is not).

  • dict – Only when return_details is set.

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

  • ValueError – If the force field has no templates.