xnn.ffnn.common.typing#

Atom typing from a force field’s SMARTS templates.

A .frc force field carries, in its #templates section, one or more SMARTS patterns per atom type; the atom-mapped atoms of a pattern ([C:1]) receive that type wherever the pattern matches. This module applies those templates to a structure with RDKit, following the procedure of SEAMM’s FFAssigner: fragments (whole-molecule patterns with a fixed type list) are assigned first and are never overwritten; then the templates are applied in file order, each later match overriding earlier ones, which is why the files list general patterns before specific ones. An atom left untyped is an error – the force field cannot describe the structure.

RDKit is an optional dependency (pip install "xnn[ffnn]"); everything here imports it lazily and raises a clear error without it.

Functions

assign_atom_types(structure, forcefield, *)

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

perceive_bond_orders(mol)

Bond orders of an RDKit molecule, aligned with perceive_bonds().

perceive_bonds(mol)

Sorted (i, j) bond list (i < j) of an RDKit molecule.

to_rdkit([structure, positions, ...])

Build an RDKit molecule with explicit hydrogens from a structure.

Exceptions

AtomTypingError

The force field's templates do not cover (part of) the structure.