gufe.chemicalsystem¶
Classes
|
A combination of Components that form a system |
- class gufe.chemicalsystem.ChemicalSystem(components: dict[str, Component], name: str | None = '')¶
A combination of Components that form a system
Containing a combination of
SmallMoleculeComponent,SolventComponentandProteinComponent, 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
Componentinstances 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:
- 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
- get(k[, d]) D[k] if k in D, else d. d defaults to None.¶
- items() a set-like object providing a view on D's items¶
- keys() a set-like object providing a view on D's keys¶
- values() an object providing a view on D's values¶