class openfe.ChemicalSystem(components: dict[str, Component], name: str | None = '')#

A combination of Components that form a system

Containing a combination of SmallMoleculeComponent, SolventComponent and ProteinComponent, this object typically represents all the molecules in a simulation box.

Used as a node for an AlchemicalNetwork.

Parameters:
  • components – The molecular representation of the chemical state, including connectivity and coordinates. Given as a dict with user-defined labels as keys, Components as values.

  • name – Optional identifier for the chemical state; included with the other attributes as part of the (hashable) graph node itself when the chemical state is added to an AlchemicalNetwork.

property components: dict[str, Component]#

The individual components of the chemical system.

Components include atomic connectivity and coordinates. This is a dict with user-defined labels as keys and Component instances as values.

component_diff(other) tuple[tuple[Component, ...], tuple[Component, ...]]#

Compare the Components of this ChemicalSystem with the Components of another ChemicalSystem.

Parameters:

other (ChemicalSystem) – The ChemicalSystem to compare to.

Returns:

A tuple containing two tuples. The first tuple contains the components that are unique to this ChemicalSystem, and the second tuple contains the components that are unique to the other ChemicalSystem.

Return type:

tuple[tuple[Component, …], tuple[Component, …]]

Raises:

TypeError – If other is not an instance of ChemicalSystem.

property name#

Optional identifier for the chemical system.

Used as part of the (hashable) graph node itself when the chemical state is added to an AlchemicalNetwork.

property total_charge#

Formal charge for the ChemicalSystem.

contains(item: Component | type[Component]) bool#

Check if a Component or Component type is in this ChemicalSystem.

Parameters:

item (Component or type of Component) – The Component instance or class to check for.

Returns:

Returns True if the item is found in the ChemicalSystem, False otherwise.

Return type:

bool

Examples

To check if a specific Component instance is in a ChemicalSystem:

>>> chem_sys = ChemicalSystem(components={"ligand": ligand_comp, "solvent": solvent_comp})
>>> is_present = chem_sys.contains(ligand_comp)
>>> print(is_present)  # True if ligand_comp is in chem_sys, False otherwise
get_components_of_type(item: type[Component]) list[Component]#

Get all Components of a specific type in this ChemicalSystem

Parameters:

item (type of Component) – The class of Component to search for.

Returns:

A list of all Components in the ChemicalSystem that are instances of the specified type. If no Components of the specified type are found, an empty list is returned.

Return type:

list of Component

Examples

To get all SmallMoleculeComponents in a ChemicalSystem:

>>> chem_sys = ChemicalSystem(components={"ligand": ligand_comp, "solvent": solvent_comp})
>>> small_molecules = chem_sys.get_components_of_type(SmallMoleculeComponent)
>>> print(small_molecules)  # List of SmallMoleculeComponent instances