xnn.ffnn.common.typing.to_rdkit#

xnn.ffnn.common.typing.to_rdkit(structure=None, *, positions=None, atomic_numbers=None, bonds=None, charge=0, smiles=None)[source]#

Build an RDKit molecule with explicit hydrogens from a structure.

Accepts, in order of preference: an RDKit Mol (returned as is, after adding explicit hydrogens if it has implicit ones); a SMILES string; an ase.Atoms; a dict with "pos" / "atomic_numbers"; or positions + atomic_numbers arrays. For geometric input the connectivity and bond orders are perceived with RDKit’s DetermineBonds (the xyz2mol algorithm); if bonds are given only the bond orders are determined, keeping that connectivity.

Parameters:
  • structure (object, optional) – See above.

  • positions (array_like, optional) – Cartesian coordinates (N, 3) in Angstrom.

  • atomic_numbers (array_like, optional) – Atomic numbers (N,).

  • bonds (sequence of (int, int), optional) – Known connectivity; bond orders are then perceived, not connectivity.

  • charge (int, optional) – Total charge of the structure (needed to perceive bond orders).

  • smiles (str, optional) – A SMILES string (hydrogens are added explicitly).

Returns:

A sanitized molecule whose atom order matches the input order (for SMILES input, the RDKit order with hydrogens appended).

Return type:

rdkit.Chem.Mol