SolvationYankProtocol

class openff.evaluator.protocols.yank.SolvationYankProtocol(protocol_id)[source]

A protocol for estimating the change in free energy upon transferring a solute into a solvent (referred to as solvent 1) from a second solvent (referred to as solvent 2) by performing an alchemical free energy calculation using the YANK framework.

This protocol can be used for box solvation free energies (setting the solvent_1 input to the solvent of interest and setting solvent_2 as an empty Substance) or transfer free energies (setting both the solvent_1 and solvent_2 inputs to different solvents).

__init__(protocol_id)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(protocol_id)

Initialize self.

apply_replicator(replicator, template_values)

Applies a ProtocolReplicator to this protocol.

can_merge(other[, path_replacements])

Determines whether this protocol can be merged with another.

execute([directory, available_resources])

Execute the protocol.

from_json(file_path)

Create this object from a JSON file.

from_schema(schema)

Initializes a protocol from it’s schema definition.

get_attributes([attribute_type])

Returns all attributes of a specific attribute_type.

get_class_attribute(reference_path)

Returns one of this protocols, or any of its children’s, attributes directly (rather than its value).

get_value(reference_path)

Returns the value of one of this protocols inputs / outputs.

get_value_references(input_path)

Returns a dictionary of references to the protocols which one of this protocols inputs (specified by input_path) takes its value from.

json([file_path, format])

Creates a JSON representation of this class.

merge(other)

Merges another Protocol with this one.

parse_json(string_contents[, encoding])

Parses a typed json string into the corresponding class structure.

replace_protocol(old_id, new_id)

Finds each input which came from a given protocol

set_uuid(value)

Prepend a unique identifier to this protocols id.

set_value(reference_path, value)

Sets the value of one of this protocols inputs.

validate([attribute_type])

Validate the values of the attributes.

Attributes

allow_merging

Input - Defines whether this protocols is allowed to merge with other protocols.

checkpoint_interval

Input - The number of iterations between saving YANK checkpoint files.

dependencies

A list of pointers to the protocols which this protocol takes input from.

electrostatic_lambdas_1

Input - The list of electrostatic alchemical states that YANK should sample at.

electrostatic_lambdas_2

Input - The list of electrostatic alchemical states that YANK should sample at.

free_energy_difference

Output - The estimated free energy difference between the solute in thefirst solvent and the second solvent (i.e.

gradient_parameters

Input - An optional list of parameters to differentiate the estimated free energy with respect to.

id

The unique id of this protocol.

number_of_equilibration_iterations

Input - The number of iterations used for equilibration before production run.

number_of_iterations

Input - The number of YANK iterations to perform.

outputs

A dictionary of the outputs of this property.

required_inputs

The inputs which must be set on this protocol.

schema

A serializable schema for this object.

setup_only

Input - If true, YANK will only create and validate the setup files, but not actually run any simulations.

solute

Input - The substance describing the composition of the solute.

solution_1_coordinates

Input - The file path to the coordinates of the solute embedded in the first solvent.

solution_1_free_energy

Output - The free energy change of transforming the an ideal solute molecule into a fully interacting molecule in the first solvent.

solution_1_system

Input - The parameterized system object of the solute embedded in the first solvent.

solution_1_trajectory_path

Output - The file path to the trajectory containing the solute in the first solvent.

solution_2_coordinates

Input - The file path to the coordinates of the solute embedded in the second solvent.

solution_2_free_energy

Output - The free energy change of transforming the an ideal solute molecule into a fully interacting molecule in the second solvent.

solution_2_system

Input - The parameterized system object of the solute embedded in the second solvent.

solution_2_trajectory_path

Output - The file path to the trajectory containing the solute in the second solvent.

solvent_1

Input - The substance describing the composition of the first solvent.

solvent_1_coordinate_path

Output - The file path to the coordinates of only the first solvent.

solvent_1_trajectory_path

Output - The file path to the trajectory containing only the first solvent.

solvent_2

Input - The substance describing the composition of the second solvent.

solvent_2_coordinate_path

Output - The file path to the coordinates of only the second solvent.

solvent_2_trajectory_path

Output - The file path to the trajectory containing only the second solvent.

steps_per_iteration

Input - The number of steps per YANK iteration to perform.

steric_lambdas_1

Input - The list of steric alchemical states that YANK should sample at.

steric_lambdas_2

Input - The list of steric alchemical states that YANK should sample at.

thermodynamic_state

Input - The state at which to run the calculations.

timestep

Input - The length of the timestep to take.

verbose

Input - Controls whether or not to run YANK at high verbosity.

solute

Input - The substance describing the composition of the solute. This should include the solute molecule as well as any counter ions. The default value of this attribute is not set and must be set by the user..

Type

Substance

solvent_1

Input - The substance describing the composition of the first solvent. The default value of this attribute is not set and must be set by the user..

Type

Substance

solvent_2

Input - The substance describing the composition of the second solvent. The default value of this attribute is not set and must be set by the user..

Type

Substance

solution_1_coordinates

Input - The file path to the coordinates of the solute embedded in the first solvent. The default value of this attribute is not set and must be set by the user..

Type

str

solution_1_system

Input - The parameterized system object of the solute embedded in the first solvent. The default value of this attribute is not set and must be set by the user..

Type

ParameterizedSystem

solution_2_coordinates

Input - The file path to the coordinates of the solute embedded in the second solvent. The default value of this attribute is not set and must be set by the user..

Type

str

solution_2_system

Input - The parameterized system object of the solute embedded in the second solvent. The default value of this attribute is not set and must be set by the user..

Type

ParameterizedSystem

electrostatic_lambdas_1

Input - The list of electrostatic alchemical states that YANK should sample at. These values will be passed to the YANK lambda_electrostatics option. If no option is set, YANK will use trailblaze algorithm to determine this option automatically. The default value of this attribute is not set. This attribute is optional.

Type

list

steric_lambdas_1

Input - The list of steric alchemical states that YANK should sample at. These values will be passed to the YANK lambda_sterics option. If no option is set, YANK will use trailblaze algorithm to determine this option automatically. The default value of this attribute is not set. This attribute is optional.

Type

list

electrostatic_lambdas_2

Input - The list of electrostatic alchemical states that YANK should sample at. These values will be passed to the YANK lambda_electrostatics option. If no option is set, YANK will use trailblaze algorithm to determine this option automatically. The default value of this attribute is not set. This attribute is optional.

Type

list

steric_lambdas_2

Input - The list of steric alchemical states that YANK should sample at. These values will be passed to the YANK lambda_sterics option. If no option is set, YANK will use trailblaze algorithm to determine this option automatically. The default value of this attribute is not set. This attribute is optional.

Type

list

solution_1_free_energy

Output - The free energy change of transforming the an ideal solute molecule into a fully interacting molecule in the first solvent. The default value of this attribute is not set and must be set by the user..

Type

Observable

solvent_1_coordinate_path

Output - The file path to the coordinates of only the first solvent. The default value of this attribute is not set and must be set by the user..

Type

str

solvent_1_trajectory_path

Output - The file path to the trajectory containing only the first solvent. The default value of this attribute is not set and must be set by the user..

Type

str

solution_1_trajectory_path

Output - The file path to the trajectory containing the solute in the first solvent. The default value of this attribute is not set and must be set by the user..

Type

str

solution_2_free_energy

Output - The free energy change of transforming the an ideal solute molecule into a fully interacting molecule in the second solvent. The default value of this attribute is not set and must be set by the user..

Type

Observable

solvent_2_coordinate_path

Output - The file path to the coordinates of only the second solvent. The default value of this attribute is not set and must be set by the user..

Type

str

solvent_2_trajectory_path

Output - The file path to the trajectory containing only the second solvent. The default value of this attribute is not set and must be set by the user..

Type

str

solution_2_trajectory_path

Output - The file path to the trajectory containing the solute in the second solvent. The default value of this attribute is not set and must be set by the user..

Type

str

free_energy_difference

Output - The estimated free energy difference between the solute in thefirst solvent and the second solvent (i.e. ΔG = ΔG_1 - ΔG_2). The default value of this attribute is not set and must be set by the user..

Type

Observable

allow_merging

Input - Defines whether this protocols is allowed to merge with other protocols. The default value of this attribute is True.

Type

bool

apply_replicator(replicator, template_values, template_index=- 1, template_value=None, update_input_references=False)

Applies a ProtocolReplicator to this protocol. This method should clone any protocols whose id contains the id of the replicator (in the format $(replicator.id)).

Parameters
  • replicator (ProtocolReplicator) – The replicator to apply.

  • template_values (list of Any) –

    A list of the values which will be inserted into the newly replicated protocols.

    This parameter is mutually exclusive with template_index and template_value

  • template_index (int, optional) –

    A specific value which should be used for any protocols flagged as to be replicated by the replicator. This option is mainly used when replicating children of an already replicated protocol.

    This parameter is mutually exclusive with template_values and must be set along with a template_value.

  • template_value (Any, optional) –

    A specific index which should be used for any protocols flagged as to be replicated by the replicator. This option is mainly used when replicating children of an already replicated protocol.

    This parameter is mutually exclusive with template_values and must be set along with a template_index.

  • update_input_references (bool) –

    If true, any protocols which take their input from a protocol which was flagged for replication will be updated to take input from the actually replicated protocol. This should only be set to true if this protocol is not nested within a workflow or a protocol group.

    This option cannot be used when a specific template_index or template_value is providied.

Returns

A dictionary of references to all of the protocols which have been replicated, with keys of original protocol ids. Each value is comprised of a list of the replicated protocol ids, and their index into the template_values array.

Return type

dict of ProtocolPath and list of tuple of ProtocolPath and int

can_merge(other, path_replacements=None)

Determines whether this protocol can be merged with another.

Parameters
  • other (Protocol) – The protocol to compare against.

  • path_replacements (list of tuple of str, optional) – Replacements to make in any value reference protocol paths before comparing for equality.

Returns

True if the two protocols are safe to merge.

Return type

bool

checkpoint_interval

Input - The number of iterations between saving YANK checkpoint files. When two protocols are merged, the largest value of this attribute from either protocol is retained. The default value of this attribute is 1.

Type

int

property dependencies

A list of pointers to the protocols which this protocol takes input from.

Type

list of ProtocolPath

execute(directory='', available_resources=None)

Execute the protocol.

Parameters
  • directory (str) – The directory to store output data in.

  • available_resources (ComputeResources) – The resources available to execute on. If None, the protocol will be executed on a single CPU.

classmethod from_json(file_path)

Create this object from a JSON file.

Parameters

file_path (str) – The path to load the JSON from.

Returns

The parsed class.

Return type

cls

classmethod from_schema(schema)

Initializes a protocol from it’s schema definition.

Parameters

schema (ProtocolSchema) – The schema to initialize the protocol using.

Returns

The initialized protocol.

Return type

cls

classmethod get_attributes(attribute_type=None)

Returns all attributes of a specific attribute_type.

Parameters

attribute_type (type of Attribute, optional) – The type of attribute to search for.

Returns

The names of the attributes of the specified type.

Return type

list of str

get_class_attribute(reference_path)

Returns one of this protocols, or any of its children’s, attributes directly (rather than its value).

Parameters

reference_path (ProtocolPath) – The path pointing to the attribute to return.

Returns

The class attribute.

Return type

object

get_value(reference_path)

Returns the value of one of this protocols inputs / outputs.

Parameters

reference_path (ProtocolPath) – The path pointing to the value to return.

Returns

The value of the input / output

Return type

Any

get_value_references(input_path)

Returns a dictionary of references to the protocols which one of this protocols inputs (specified by input_path) takes its value from.

Notes

Currently this method only functions correctly for an input value which is either currently a ProtocolPath, or a list / dict which contains at least one ProtocolPath.

Parameters

input_path (ProtocolPath) – The input value to check.

Returns

A dictionary of the protocol paths that the input targeted by input_path depends upon.

Return type

dict of ProtocolPath and ProtocolPath

gradient_parameters

Input - An optional list of parameters to differentiate the estimated free energy with respect to.

Type

list

id

The unique id of this protocol. The default value of this attribute is not set and must be set by the user..

Type

str

json(file_path=None, format=False)

Creates a JSON representation of this class.

Parameters
  • file_path (str, optional) – The (optional) file path to save the JSON file to.

  • format (bool) – Whether to format the JSON or not.

Returns

The JSON representation of this class.

Return type

str

merge(other)

Merges another Protocol with this one. The id of this protocol will remain unchanged.

Parameters

other (Protocol) – The protocol to merge into this one.

Returns

A map between any original protocol ids and their new merged values.

Return type

Dict[str, str]

number_of_equilibration_iterations

Input - The number of iterations used for equilibration before production run. Only post-equilibration iterations are written to file. The default value of this attribute is 1.

Type

int

number_of_iterations

Input - The number of YANK iterations to perform. The default value of this attribute is 5000.

Type

int

property outputs

A dictionary of the outputs of this property.

Type

dict of ProtocolPath and Any

classmethod parse_json(string_contents, encoding='utf8')

Parses a typed json string into the corresponding class structure.

Parameters
  • string_contents (str or bytes) – The typed json string.

  • encoding (str) – The encoding of the string_contents.

Returns

The parsed class.

Return type

Any

replace_protocol(old_id, new_id)
Finds each input which came from a given protocol

and redirects it to instead take input from a new one.

Notes

This method is mainly intended to be used only when merging multiple protocols into one.

Parameters
  • old_id (str) – The id of the old input protocol.

  • new_id (str) – The id of the new input protocol.

property required_inputs

The inputs which must be set on this protocol.

Type

list of ProtocolPath

property schema

A serializable schema for this object.

Type

ProtocolSchema

set_uuid(value)

Prepend a unique identifier to this protocols id. If the id already has a prepended uuid, it will be overwritten by this value.

Parameters

value (str) – The uuid to prepend.

set_value(reference_path, value)

Sets the value of one of this protocols inputs.

Parameters
  • reference_path (ProtocolPath) – The path pointing to the value to return.

  • value (Any) – The value to set.

setup_only

Input - If true, YANK will only create and validate the setup files, but not actually run any simulations. This argument is mainly only to be used for testing purposes. The default value of this attribute is False.

Type

bool

steps_per_iteration

Input - The number of steps per YANK iteration to perform. The default value of this attribute is 500.

Type

int

thermodynamic_state

Input - The state at which to run the calculations. The default value of this attribute is not set and must be set by the user..

Type

ThermodynamicState

timestep

Input - The length of the timestep to take. When two protocols are merged, the largest value of this attribute from either protocol is retained. The default value of this attribute is 2 fs.

Type

Quantity

validate(attribute_type=None)

Validate the values of the attributes. If attribute_type is set, only attributes of that type will be validated.

Parameters

attribute_type (type of Attribute, optional) – The type of attribute to validate.

Raises

ValueError or AssertionError

verbose

Input - Controls whether or not to run YANK at high verbosity. The default value of this attribute is False.

Type

bool