xnn.gnn.featurizers.molgraph#

Molecular graphs for networks that read the two-dimensional structure (ByteFF, ByteFF-Pol).

A graph-parameterized force field predicts its parameters from the two-dimensional molecular graph alone. molecular_graph() turns an RDKit molecule (explicit hydrogens, atoms in the order of the coordinates) into the integer features and term lists such a model reads:

  • the Lewis structure is standardized first: a few hypervalent groups are written in charge-separated form (sulfoxides, trivalent sulfur, deprotonated sulfonamides, azides, odd N-oxides) and the resonance structure with the fewest formal charges is chosen (canonical_resonance()), so that equivalent inputs give the same graph;

  • per atom: element, number of bonded neighbors, formal charge, number of ring bonds and the size of the smallest ring through the atom; per bond: whether it lies in a ring and its order (single, double, triple, aromatic). Rings are the simple cycles of at most MAX_RING_SIZE atoms;

  • the bonds, angles, proper torsions and impropers (one per carbon or nitrogen with three neighbors, center first) with the directed edges along each term;

  • the classes of topologically equivalent atoms and bonds (symmetric atoms of the graph with every bond made single and every charge removed);

  • the pairs separated by one to four bonds, and the torsions through linear centers (sp carbon, two-coordinated N+), whose barriers vanish.

RDKit is an optional dependency (pip install "xnns[ffnn]").

Module Attributes

MAX_RING_SIZE

Largest ring whose bonds count as ring bonds.

BOND_ORDERS

Bond orders of the bond-order feature, in feature order.

Functions

canonical_resonance(mol)

The resonance structure of mol with the fewest formal charges.

graph_key(mol)

A key identifying the topology of mol with its atom order (mapped SMILES).

molecular_graph(mol, *[, prepare])

Build the MolecularGraph of an RDKit molecule.

prepare_molecule(mol)

The standardized structure the graph of mol is built from.

sanitized(mol)

A sanitized copy of mol with RDKit's aromaticity model.

split_molecules(mol)

The connected components of mol with their atom indices.

standardize_groups(mol)

Write the hypervalent groups of mol in charge-separated form.

Classes

MolecularGraph(atomic_numbers, ...[, smiles])

The graph of one molecule as read by a graph-parameterized force field.