LibraryChargeType

class openff.toolkit.typing.engines.smirnoff.parameters.LibraryChargeType(**kwargs)

A SMIRNOFF Library Charge type.

Warning

This API is experimental and subject to change.

__init__(**kwargs)

Create a ParameterType.

Parameters:
  • smirks – The SMIRKS match for the provided parameter type.

  • allow_cosmetic_attributes – Whether to permit non-spec kwargs (“cosmetic attributes”). If True, non-spec kwargs will be stored as an attribute of this parameter which can be accessed and written out. Otherwise an exception will be raised.

Methods

__init__(**kwargs)

Create a ParameterType.

add_cosmetic_attribute(attr_name, attr_value)

Add a cosmetic attribute to this object.

attribute_is_cosmetic(attr_name)

Determine whether an attribute of this object is cosmetic.

delete_cosmetic_attribute(attr_name)

Delete a cosmetic attribute from this object.

from_molecule(molecule)

Construct a LibraryChargeType from a molecule with existing partial charges.

to_dict([discard_cosmetic_attributes, ...])

Convert this object to dict format.

Attributes

charge

id

name

parent_id

smirks

add_cosmetic_attribute(attr_name, attr_value)

Add a cosmetic attribute to this object.

This attribute will not have a functional effect on the object in the OpenFF Toolkit, but can be written out during output.

Warning

The API for modifying cosmetic attributes is experimental and may change in the future (see issue #338).

Parameters:
  • attr_name – Name of the attribute to define for this object.

  • attr_value – The value of the attribute to define for this object.

attribute_is_cosmetic(attr_name)

Determine whether an attribute of this object is cosmetic.

Warning

The API for modifying cosmetic attributes is experimental and may change in the future (see issue #338).

Parameters:

attr_name – The attribute name to check

Returns:

is_cosmetic – Returns True if the attribute is defined and is cosmetic. Returns False otherwise.

delete_cosmetic_attribute(attr_name)

Delete a cosmetic attribute from this object.

Warning

The API for modifying cosmetic attributes is experimental and may change in the future (see issue #338).

Parameters:

attr_name – Name of the cosmetic attribute to delete.

classmethod from_molecule(molecule: Molecule)

Construct a LibraryChargeType from a molecule with existing partial charges.

Parameters:

molecule – The molecule to create the LibraryChargeType from. The molecule must have partial charges.

Returns:

library_charge_type – A LibraryChargeType that is expected to match this molecule and its partial charges.

Raises:

MissingPartialChargesError

to_dict(discard_cosmetic_attributes: bool = False, duplicate_attributes: list[str] | None = None) dict

Convert this object to dict format.

The returning dictionary contains all the ParameterAttribute and IndexedParameterAttribute as well as cosmetic attributes if discard_cosmetic_attributes is False.

Parameters:
  • discard_cosmetic_attributes – Whether to discard non-spec attributes of this object

  • duplicate_attributes – A list of names of attributes that redundantly decsribe data and should be discarded during serializaiton

Returns:

smirnoff_dict – The SMIRNOFF-compliant dict representation of this object.