Calc3DProperties#

nvmolkit.descriptors3d.Calc3DProperties(
mols,
properties: Property3D | str | Sequence[Property3D | str],
*,
coordinates: Device3DResult | None = None,
options: Property3DOptions | None = None,
precision: PrecisionMode = PrecisionMode.SINGLE,
hardwareOptions: HardwareOptions | None = None,
stream: Stream | None = None,
) → Device3DPropertyResult#

Calculate selected 3D properties for every conformer in a molecule batch.

Parameters:
  • mols – One RDKit molecule or an iterable of molecules. Molecules provide atom identity even when coordinates are supplied separately.

  • properties – Ordered selection from Property3D.

  • coordinates – Optional device-resident coordinates from an nvMolKit 3D operation, read in place. When omitted, coordinates are taken from each molecule’s RDKit conformers. Rows whose mol_indices entry is out of range, whose atom_starts range falls outside values, or whose atom count differs from their molecule’s produce NaN rather than an error, so no host synchronization is needed. Device coordinate rows are treated as three-dimensional; molecule conformers keep their RDKit is3D flag, which PBF and GETAWAY’s HIC read. HIC takes its flatness (PBF and is3D) from each molecule’s first conformer for all of its conformers; with coordinates, each row uses its own geometry.

  • options – Per-family options; defaults to Property3DOptions (RDKit’s defaults).

  • precision – PrecisionMode.SINGLE (default) computes and returns float32; PrecisionMode.FULL computes and returns float64. Steps where float32 measurably loses accuracy always compute in float64: coordinate centering (conformers far from the origin), WHIM’s PCA (inverse kurtosis of near-planar conformers), MORSE’s first scattering value (a large sum of positive terms), USR’s reference-atom choice (near-equidistant atoms) and GETAWAY’s leverages (rounded and clustered for ITH and ISH).

  • hardwareOptions – Only preprocessingThreads applies: the CPU threads used to extract coordinates and atom weights from the molecules (default -1, all threads).

  • stream – CUDA stream used for transfers and calculation. Defaults to the coordinate device’s current stream, or the current CUDA stream.

Returns:

A Device3DPropertyResult mapping each requested property name, in request order, to a device vector with one row per conformer, plus the molecule and conformer labels of every row. Without coordinates, rows follow input-molecule order, then RDKit conformer order.

Any subset of Property3D can be requested in one call, mixing families and giving members or names. Each requested family runs once for the whole batch, and a property’s values do not depend on what else is requested. options configures each family independently, and precision applies to every requested property.

Example:

from rdkit import Chem
from rdkit.Chem import rdDistGeom

from nvmolkit.descriptors3d import (
    Calc3DProperties,
    MomentOptions,
    Property3D,
    Property3DOptions,
    WhimOptions,
)
from nvmolkit.types import PrecisionMode

mols = [Chem.AddHs(Chem.MolFromSmiles(s)) for s in ("CCO", "c1ccccc1O", "CC(=O)Nc1ccc(O)cc1")]
for mol in mols:
    rdDistGeom.EmbedMultipleConfs(mol, numConfs=4, randomSeed=42)

result = Calc3DProperties(
    mols,
    [Property3D.NPR1, "NPR2", Property3D.PBF, "WHIM"],
    options=Property3DOptions(
        moments=MomentOptions(useAtomicMasses=False),  # unit-weighted NPR1 and NPR2
        whim=WhimOptions(threshold=0.01),  # looser WHIM symmetry matching
    ),
    precision=PrecisionMode.FULL,
)

result["NPR1"].torch()  # float64, shape (12,): one row per conformer
result[Property3D.WHIM].torch()  # shape (12, 114)
result.mol_indices.torch()  # [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2]
result.conf_indices.torch()  # [0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3]

dense = result.dense()
dense.values["NPR1"].shape  # (3, 4): molecules x conformers
dense.values["WHIM"].shape  # (3, 4, 114)