NAGLToolkitWrapper
- class openff.toolkit.utils.toolkits.NAGLToolkitWrapper[source]
NAGL toolkit wrapper for applying partial charges with a GCN model.
OpenFF NAGL computes partial charges directly from the molecular graph and independent of conformer coordinates using a Graph Convolutional Network.
- __init__()[source]
Methods
__init__
()assign_partial_charges
(molecule, ...[, ...])Compute partial charges with NAGL and store in
self.partial_charges
from_file
(file_path, file_format[, ...])Return an openff.toolkit.topology.Molecule from a file using this toolkit.
from_file_obj
(file_obj, file_format[, ...])Return an openff.toolkit.topology.Molecule from a file-like object (an object with a ".read()" method using this toolkit.
Check whether the corresponding toolkit can be imported
requires_toolkit
()Attributes
supported_charge_methods
List of file formats that this toolkit can read.
List of file formats that this toolkit can write.
Instructions on how to install the wrapped toolkit.
Return the name of the toolkit wrapped by this class as a str
Return the version of the wrapped toolkit as a str
- classmethod is_available() bool [source]
Check whether the corresponding toolkit can be imported
- Returns:
is_installed – True if corresponding toolkit is installed, False otherwise.
- assign_partial_charges(molecule: Molecule, partial_charge_method: str, use_conformers: list['Quantity'] | None = None, strict_n_conformers: bool = False, normalize_partial_charges: bool = True, _cls: type['FrozenMolecule'] | None = None)[source]
Compute partial charges with NAGL and store in
self.partial_charges
Warning
This API is experimental and subject to change.
- Parameters:
molecule – Molecule for which partial charges are to be computed
partial_charge_method – The NAGL model to use. May be a path or the name of a model in a directory from the
openforcefield.nagl_model_path
entry point.use_conformers – This argument is ignored as NAGL does not generate or consider coordinates during inference.
strict_n_conformers – This argument is ignored as NAGL does not generate or consider coordinates during inference.
normalize_partial_charges (bool, default=True) – Whether to offset partial charges so that they sum to the total formal charge of the molecule. This is used to prevent accumulation of rounding errors when the partial charge generation method has low precision.
_cls (class) – Molecule constructor
- Raises:
ChargeMethodUnavailableError – if the requested charge method can not be handled by this toolkit
ChargeCalculationError – if the charge method is supported by this toolkit, but fails
- from_file(file_path, file_format, allow_undefined_stereo=False)
Return an openff.toolkit.topology.Molecule from a file using this toolkit.
- Parameters:
file_path – The file to read the molecule from
file_format – Format specifier, usually file suffix (eg. ‘MOL2’, ‘SMI’) Note that not all toolkits support all formats. Check ToolkitWrapper.toolkit_file_read_formats for details.
allow_undefined_stereo – If false, raises an exception if any molecules contain undefined stereochemistry.
_cls – Molecule constructor
- Returns:
molecules – a list of Molecule objects is returned.
- from_file_obj(file_obj, file_format, allow_undefined_stereo=False, _cls=None)
Return an openff.toolkit.topology.Molecule from a file-like object (an object with a “.read()” method using this toolkit.
- Parameters:
file_obj – The file-like object to read the molecule from
file_format – Format specifier, usually file suffix (eg. ‘MOL2’, ‘SMI’) Note that not all toolkits support all formats. Check ToolkitWrapper.toolkit_file_read_formats for details.
allow_undefined_stereo – If false, raises an exception if any molecules contain undefined stereochemistry. If false, the function skips loading the molecule.
_cls – Molecule constructor
- Returns:
molecules – a list of Molecule objects is returned.