polymerist.mdtools.openfftools.topology

Utilities for serializing, converting, and extracting info from OpenFF topologies

Attributes

LOGGER

Functions

get_largest_offmol(→ openff.toolkit.topology.Molecule)

Return the largest molecule in a Topology

copy_atom_metadata(→ None)

Copies all attributes from the metadata dict of an OpenFF-type Atom as Props of an RDKit-type atom

to_rdkit_with_metadata(→ rdkit.Chem.rdchem.Mol)

Converts an OpenFF molecule to an RDKit molecule, preserving atomic metadata

package_atom_metadata(→ None)

Collect atom metadata into a serializable property of the parent Molecule

unpackage_atom_metadata(→ None)

Reassign atom metadata from a "packaged" metadata property dict belonging to the parent Molecule

save_molecule(→ None)

Syntactic sugar for annoying suffix re-specification when saving OpenFF Molecules

topology_to_sdf(→ None)

Save an OpenFF Topology to an SDF file, preserving all atom metadata

topology_from_sdf(→ openff.toolkit.topology.Topology)

Load an OpenFF Topology from an SDF file, assigning metadata and partial charges if stored

topology_from_molecule_onto_lattice(...)

Copy and tile an OpenFF Molecule onto a set of specified lattice sites

Module Contents

polymerist.mdtools.openfftools.topology.LOGGER
polymerist.mdtools.openfftools.topology.get_largest_offmol(offtop: openff.toolkit.topology.Topology) openff.toolkit.topology.Molecule[source]

Return the largest molecule in a Topology

polymerist.mdtools.openfftools.topology.copy_atom_metadata(offatom: openff.toolkit.topology.Atom, rdatom: rdkit.Chem.rdchem.Atom, preserve_type: bool = True) None[source]

Copies all attributes from the metadata dict of an OpenFF-type Atom as Props of an RDKit-type atom

polymerist.mdtools.openfftools.topology.to_rdkit_with_metadata(offmol: openff.toolkit.topology.Molecule, preserve_type: bool = True) rdkit.Chem.rdchem.Mol[source]

Converts an OpenFF molecule to an RDKit molecule, preserving atomic metadata

polymerist.mdtools.openfftools.topology.package_atom_metadata(offmol: openff.toolkit.topology.Molecule) None[source]

Collect atom metadata into a serializable property of the parent Molecule

polymerist.mdtools.openfftools.topology.unpackage_atom_metadata(offmol: openff.toolkit.topology.Molecule) None[source]

Reassign atom metadata from a “packaged” metadata property dict belonging to the parent Molecule

polymerist.mdtools.openfftools.topology.save_molecule(path: pathlib.Path, offmol: openff.toolkit.topology.Molecule, toolkit_registry: openff.toolkit.ToolkitRegistry = GTR) None[source]

Syntactic sugar for annoying suffix re-specification when saving OpenFF Molecules

polymerist.mdtools.openfftools.topology.topology_to_sdf(path: pathlib.Path, offtop: openff.toolkit.topology.Topology, toolkit_registry: openff.toolkit.ToolkitRegistry = GTR) None[source]

Save an OpenFF Topology to an SDF file, preserving all atom metadata

Parameters:
  • path (Path) – The path of the SDF file to save to

  • offtop (Topology) – An OpenFF Topology

  • toolkit_registry (ToolkitRegistry, default=GLOBAL_TOOLKIT_REGISTRY) – The toolkit registry to use for serializing each Molecule object within the Topology Defaults to the Global Toolkit Registry supplied by the OpenFF toolkit

polymerist.mdtools.openfftools.topology.topology_from_sdf(path: pathlib.Path, *args, **kwargs) openff.toolkit.topology.Topology[source]

Load an OpenFF Topology from an SDF file, assigning metadata and partial charges if stored

Parameters:
  • path (Path) – The path of the SDF file to load

  • *args, **kwargs (Any) – Additional positional arguments to pass to Molecule.from_file()

Returns:

An OpenFF Topology object containing the molecule(s) found in the SDF, each with its associated metadata and partial charges from the SDF bound

Return type:

Topology

polymerist.mdtools.openfftools.topology.topology_from_molecule_onto_lattice(offmol: openff.toolkit.topology.Molecule, lattice_points: numpy.ndarray, rotate_randomly: bool = True, unique_mol_ids: bool = True) openff.toolkit.topology.Topology[source]

Copy and tile an OpenFF Molecule onto a set of specified lattice sites For each lattice site provided, a copy of the Molecule will be placed with its center of mass coincident to that site

Parameters:
  • offmol (Molecule) – The OpenFF Molecule to tile onto the lattice

  • lattice_points (np.ndarray) – An Nx3 array where each row is the xyz coordinate of a lattice site

  • rotate_randomly (bool, default=True) – Whether to apply a random SO(3) rotation to each copy of the Molecule

  • unique_mol_ids (bool, default=True) – Whether to assign unique IDs to each copy of the Molecule

Returns:

A Topology containing all tiled copies of the original molecule

Return type:

Topology