-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REST scaling for protein-ligand systems with the CLI #1197
Draft
ijpulidos
wants to merge
8
commits into
0.10.x
Choose a base branch
from
rest-tmax-cli
base: 0.10.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cb77074
Default to current temperature. Add docstring. Raise meaningful excep…
ijpulidos 6e84d0c
Use openmmtools CODATA 2018 constants
ijpulidos 99f7384
Handling rest max temperature YAML parameter in CLI
ijpulidos 97c97c0
Adding HTF input parameter to yaml template
ijpulidos e09f5e5
handling units for REST parameters. REST parameters in YAML template.
ijpulidos f497d9d
Merge branch '0.10.x' into rest-tmax-cli
ijpulidos 05c204b
Using not water instead for rest region
ijpulidos 7250cc8
Merge branch 'rest-tmax-cli' of github.com:choderalab/perses into res…
ijpulidos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,8 +32,40 @@ def __init__(self, *args, hybrid_factory=None, **kwargs): | |
# TODO: Should this overload the create() method from parent instead of being setup()? | ||
def setup(self, n_states, temperature, storage_file, minimisation_steps=100, | ||
n_replicas=None, lambda_schedule=None, | ||
lambda_protocol=None, endstates=True, t_max=300 * unit.kelvin): | ||
|
||
lambda_protocol=None, endstates=True, t_max=None): | ||
""" | ||
Set up the simulation with the specified parameters. | ||
|
||
Parameters: | ||
----------- | ||
n_states : int | ||
The number of alchemical states to simulate. | ||
temperature : openmm.unit.Quantity | ||
The temperature of the simulation in Kelvin. | ||
storage_file : str | ||
The path to the storage file to store the simulation results. | ||
minimisation_steps : int, optional | ||
The number of minimisation steps to perform before simulation. Default is 100. | ||
n_replicas : int, optional | ||
The number of replicas for replica exchange. If not specified, it will be set to `n_states`. | ||
lambda_schedule : array-like, optional | ||
The schedule of lambda values for the alchemical states. Default is a linear schedule from 0 to 1. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change this to something like "Default is None, in which case a linear schedule from 0 to 1 will be used" |
||
lambda_protocol : object, optional | ||
The lambda protocol object that defines the alchemical transformation protocol. Default is None. | ||
endstates : bool, optional | ||
Whether to generate unsampled endstates. Default is True. | ||
t_max : openmm.unit.Quantity, optional | ||
The maximum temperature for REST scaling. Default is None. | ||
|
||
Raises: | ||
------- | ||
ValueError | ||
If the hybrid factory name is not supported. | ||
|
||
Returns: | ||
-------- | ||
None | ||
""" | ||
from perses.dispersed import feptasks | ||
|
||
# Retrieve class name, hybrid system, and hybrid positions | ||
|
@@ -50,11 +82,15 @@ def setup(self, n_states, temperature, storage_file, minimisation_steps=100, | |
lambda_zero_alchemical_state = RESTCapableRelativeAlchemicalState.from_system(hybrid_system) | ||
lambda_protocol = RESTCapableLambdaProtocol() if lambda_protocol is None else lambda_protocol | ||
|
||
# Default to current temperature if t_max is not specified (no REST scaling) | ||
if t_max is None: | ||
t_max = temperature | ||
|
||
# Set beta_0 and beta_m | ||
beta_0 = 1 / (kB * temperature) | ||
beta_m = 1 / (kB * t_max) | ||
else: | ||
raise Exception(f"{factory_name} not supported") | ||
raise ValueError(f"{factory_name} not supported") | ||
|
||
# Create reference compound thermodynamic state | ||
thermostate = ThermodynamicState(hybrid_system, temperature=temperature) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the right way to change this function to work for small molecules. Specifying "not water" will include solvent ions, which we definitely don't want to include as part of the REST region.
We first need to determine what the desired behavior is. The current behavior of this function for small molecules is to automatically include all small molecule atoms in the REST region, and also include protein atoms within X angstroms (where X is user specified) of the small molecule. I think we discussed that you would run some experiments testing this approach, though this will require finding transformations where REST is known to improve sampling / speed up convergence.
One worry I have with this approach is that including all small molecule atoms in the REST region is not the best practices approach (Schrodinger papers typically choose the alchemically-changing (aka unique old and new) atoms and some nearby protein atoms) and there may be risk of small molecule unbinding. Therefore, I think the desired approach should be to modify these lines:
such that for small molecule transformations only,
query_indices
is all unique old/new atoms/core atoms. This may requiring introducing an argument to the function likeis_small_molecule
that tells the function whether its dealing with a small molecule transformation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the things that we noticed is that the
solute_atoms
after the selection is empty forsolvent
phase. But we probably want to have the option to do REST scaling in solvent phase as well, such that the neighboring part is not needed, but the molecule atoms are still scaled according to the REST protocol.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notes from discussion:
rest_atoms_all
. Will need to make sure the relevant small molecule atoms are included in this.