Creation strategies¶
fes_ml.alchemical.strategies.base_strategy
¶
Base strategy for alchemical state creation.
BaseSystem
dataclass
¶
What a strategy builds before the alchemical modifications: the strategy-specific part (R2).
:meth:AlchemicalStateCreationStrategy._finish_state runs the shared steps on it.
AlchemicalStateCreationStrategy
¶
Bases: ABC
Base class for alchemical state creation strategies.
create_alchemical_state(*args, **kwargs)
abstractmethod
¶
Create an alchemical state for the given λ values.
Returns:
| Type | Description |
|---|---|
AlchemicalState
|
The alchemical state. |
fes_ml.alchemical.strategies.sire_strategy.SireCreationStrategy
¶
Bases: AlchemicalStateCreationStrategy
Strategy for creating alchemical states using Sire.
create_alchemical_state(top_file, crd_file, alchemical_atoms, lambda_schedule, minimise_iterations=1, dynamics_kwargs=None, remove_constraints=True, integrator=None, keep_tmp_files=True, modifications_kwargs=None, work_dir=None, *args, **kwargs)
¶
Create an alchemical state for the given λ values using OpenMM Systems created with Sire.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
top_file
|
str
|
Path to the topology file. |
required |
crd_file
|
str
|
Path to the coordinate file. |
required |
alchemical_atoms
|
list of int or dict of str to list of int
|
Atom indices to be alchemically modified, or a dictionary mapping alchemical
group names (the |
required |
lambda_schedule
|
dict
|
A dictionary mapping the name of the alchemical modification to the λ value. |
required |
minimise_iterations
|
int
|
The number of minimisation iterations to perform before creating the alchemical state. 1 step is enough to bring the geometry to the distances imposed by the restraints. If None, no minimisation is performed. |
1
|
dynamics_kwargs
|
dict
|
Additional keyword arguments to be passed to sire.mol.Dynamics. See https://sire.openbiosim.org/api/mol.html#sire.mol.Dynamics. |
None
|
remove_constraints
|
bool
|
Whether to remove constraints involving the alchemical atoms. |
True
|
integrator
|
Any
|
The OpenMM integrator to use. If None, the integrator is the one used in the dynamics_kwargs, if provided. Otherwise, the default is a LangevinMiddle integrator with a 1 fs timestep and a 298.15 K temperature. |
None
|
keep_tmp_files
|
bool
|
Whether to keep the files written by the strategy. A |
True
|
modifications_kwargs
|
dict
|
A dictionary of keyword arguments for the modifications. |
None
|
work_dir
|
str
|
Directory for the files written by the strategy. By default a new |
None
|
Returns:
| Type | Description |
|---|---|
AlchemicalState
|
The alchemical state. |
fes_ml.alchemical.strategies.openff_strategy.OpenFFCreationStrategy
¶
Bases: AlchemicalStateCreationStrategy
Strategy for creating alchemical states using OpenFF.
is_mapped_smiles(smiles)
staticmethod
¶
Check if the given SMILES string is a mapped SMILES.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
smiles
|
str
|
The smiles to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the smiles is mapped or not. |
create_alchemical_state(alchemical_atoms, lambda_schedule, sdf_file_ligand=None, sdf_file_solvent=None, smiles_ligand=None, smiles_solvent=None, temperature=298.15 * _unit.kelvin, pressure=1.0 * _unit.atmosphere, mdconfig_dict=None, packmol_kwargs=None, hydrogen_mass=1.007947 * _unit.amu, forcefields=None, remove_constraints=True, integrator=None, friction=1.0 / _unit.picosecond, timestep=1.0 * _unit.femtosecond, topology_pdb=None, write_pdb=True, write_system_xml=True, partial_charges_method='am1bcc', keep_tmp_files=True, modifications_kwargs=None, emle_plus=False, work_dir=None, *args, **kwargs)
¶
Create an alchemical state for the given λ values using OpenMM Systems created with Sire.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alchemical_atoms
|
list of int or dict of str to list of int
|
Atom indices to be alchemically modified, or a dictionary mapping alchemical
group names (the |
required |
lambda_schedule
|
dict
|
A dictionary mapping the name of the alchemical modification to the λ value. |
required |
sdf_file_ligand
|
str
|
The path to the SDF file containing the ligand. |
None
|
sdf_file_solvent
|
str
|
The path to the SDF file containing a solvent molecule. |
None
|
smiles_ligand
|
str
|
The SMILES of the ligand (used if |
None
|
smiles_solvent
|
str
|
The SMILES of the solvent. If None, the ligand is assumed to be in vacuum.
For water use |
None
|
temperature
|
float or Quantity
|
The temperature in Kelvin. |
298.15
|
mdconfig_dict
|
Optional[Dict[str, Any]]
|
A dictionary of keyword arguments for the MDConfig object. See: https://docs.openforcefield.org/projects/interchange/en/stable/_autosummary/openff.interchange.components.mdconfig.MDConfig.html#openff.interchange.components.mdconfig.MDConfig |
None
|
packmol_kwargs
|
dict
|
A dictionary of keyword arguments for the Packmol pack_box function. The list of molecules is already passed and should not be provided. An attempt is made to infer the number of molecules from the number of copies if not provided. See: TODO: add docs for packmol_kwargs |
None
|
hydrogen_mass
|
float or Quantity
|
The mass of the hydrogen atom. If None, the mass is not changed. |
None
|
forcefields
|
list of str
|
The list of forcefields to use. If None, those in _DEFAULT_FORCEFIELDS are used. |
None
|
remove_constraints
|
bool
|
Whether to remove constraints involving the alchemical atoms. |
True
|
pressure
|
float or Quantity or None
|
The pressure in bar. If None, the Monte Carlo Barostat is not added. |
1.0
|
integrator
|
Any
|
The OpenMM integrator to use. If None, the default is a LangevinMiddle integrator with a 1 fs timestep and a 298.15 K temperature (if temperature is not None). Otherwise, a Verlet integrator with the provided timestep is used. |
None
|
friction
|
float or Quantity
|
The friction coefficient in 1/ps. Only necessary for Langevin-type integrators. |
1.0 / _unit.picosecond
|
timestep
|
float or Quantity
|
The timestep in ps of the integrator. |
1.0 * _unit.femtosecond
|
topology_pdb
|
str
|
The path to the PDB file containing the topology. If not None, the topology is created from this file, which is assumed to contain all the molecules. |
None
|
write_pdb
|
bool
|
Save coordinates and topology to a PDB file. |
True
|
write_system_xml
|
bool
|
Save the OpenMM system to an XML file. |
True
|
partial_charges_method
|
str
|
The method to use for assigning partial charges to the ligand. See: https://docs.openforcefield.org/projects/toolkit/en/latest/api/generated/openff.toolkit.topology.Molecule.html#openff.toolkit.topology.Molecule.assign_partial_charges |
"am1bcc"
|
keep_tmp_files
|
bool
|
Whether to keep the files written by the strategy. A |
True
|
emle_plus
|
bool
|
Whether to use EMLE+ instead of EMLE. If True, the EMLE+ modifications will be applied to the system. |
False
|
modifications_kwargs
|
dict
|
A dictionary of keyword arguments for the modifications. |
None
|
work_dir
|
str
|
Directory for the files written by the strategy. By default a new |
None
|
Returns:
| Type | Description |
|---|---|
AlchemicalState
|
The alchemical state. |