SmallMoleculeComponent#

class gufe.components.smallmoleculecomponent.SmallMoleculeComponent(rdkit: rdkit.Chem.rdchem.Mol, name: str = '')#

Component representing a small molecule, used for ligands and cofactors.

This class supports reading/writing to the .sdf format, which is suited to smaller molecules. Ligands in a free energy calculation are represented with this class, along with cofactors.

The name can be explicitly set by the name keyword argument on create, or implicitly set based on the tags in the input molecular representation (if supported, as with RDKit). If not explicitly set on creation, the molecule will first look for an OpenFE-specific tag ofe-name, and if that doesn’t exist, for a commonly-used naming tag (e.g., the _Name property for RDKit molecules). If no name is found, the empty string is used.

Parameters:
  • rdkit (rdkit.Chem.rdchem.Mol) – rdkit representation of the molecule

  • name (str, optional) – A human readable tag for this molecule. This name will be used in the hash.

Note

This class is a read-only representation of a molecule, if you want to edit the molecule do this in an appropriate toolkit before creating an instance from this class.

Methods

copy_with_replacements

Make a modified copy of this object.

from_openff

Construct from an OpenFF toolkit Molecule

from_sdf_file

Create SmallMoleculeComponent from SDF file.

from_sdf_string

Create :class:SmallMoleculeComponent from SDF-formatted string.

to_openff

OpenFF Toolkit Molecule representation of this molecule

to_sdf

Create a string based on SDF.

copy_with_replacements(**replacements)#

Make a modified copy of this object.

Since GufeTokenizables are immutable, this is essentially a shortcut to mutate the object. Note that the keyword arguments it takes are based on keys of the dictionaries used in the the _to_dict/_from_dict cycle for this object; in most cases that is the same as parameters to __init__, but not always.

This will always return a new object in memory. So using obj.copy_with_replacements() (with no keyword arguments) is a way to create a shallow copy: the object is different in memory, but its attributes will be the same objects in memory as the original.

Parameters:

replacements (Dict) – keyword arguments with keys taken from the keys given by the output of this object’s to_dict method.

classmethod from_json(json_str)#
classmethod from_openff(openff, name: str = '')#

Construct from an OpenFF toolkit Molecule

classmethod from_rdkit(rdkit: rdkit.Chem.rdchem.Mol, name: str = '')#

Create a Component, copying from an RDKit Mol

classmethod from_sdf_file(filename: str)#

Create SmallMoleculeComponent from SDF file.

Parameters:

filename (str) – name of SDF file

Returns:

the deserialized molecule

Return type:

SmallMoleculeComponent

classmethod from_sdf_string(sdf_str: str)#

Create :class:SmallMoleculeComponent from SDF-formatted string.

Parameters:

sdf_str (str) – input string in SDF format

Returns:

the deserialized molecule

Return type:

SmallMoleculeComponent

property name: str#
property smiles: str#
to_json()#
to_openff()#

OpenFF Toolkit Molecule representation of this molecule

Note

This is a copy of this object, and modifying the OpenFF copy does not alter the original object.

to_rdkit() rdkit.Chem.rdchem.Mol#

Return an RDKit copied representation of this molecule

to_sdf() str#

Create a string based on SDF.

See also

from_sdf_string()

create an object from the output of this

property total_charge#

Net formal charge for the Component, if defined.