Skip to content
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

Alchemical Transfer Method #327

Merged
merged 96 commits into from
Oct 24, 2024
Merged

Alchemical Transfer Method #327

merged 96 commits into from
Oct 24, 2024

Conversation

mb2055
Copy link
Contributor

@mb2055 mb2055 commented Aug 7, 2024

This PR adds functionality for creating, running and analysing RBFE calculations using the Alchemical Transfer Method (AToM).

Functionality is contained in a pair of key locations and is as follows:

  • BioSimSpace.FreeEnergy.AToM is a class that facilitates the creation of AToM-compatible systems, the use of the BioSimSpace runner to run full sets of production simulations, and analysis using UWHAM.
    • Users can pass a set of three BioSimSpace molecules, and use ...AToM.prepare() to create an AToM-compatible system. Users can pass a vector to the prepare function that defines the displacement of the free ligand relative to the bound ligand. If this vector is not provided a best-fit vector will be automatically calculated.
    • The choice of rigid core atoms, which define the alignment of the two ligands and are vital to the stability of simulations, can be tricky. To aid in the choice of these atoms the AToM class includes a helper function called viewRigidCores which allows the user to view their choice of rigid core atoms within a notebook.
  • BioSimSpace.Protocol.AToM{} contains a series of protocols for minimisation, equilibration and annealing of AToM systems. Equilibration and annealing protocols allow users to manually set the large number of constants and lambda-dependent values used in AToM simulations, any that are not set have sane defaults chosen for them.
    • BioSimSpace.Protocol.AToMEquilibration allows the user to run with or without the ATMForce present, simply by setting use_atm_force.
    • BioSimSpace.Protocol.AToMAnnealing allows the user to anneal any number of the lambda-dependent values, these are set through a dictionary. If not set the system is annealed from lambda1,lambda2 = 0 to lambda1,lambda2 = 0.5.
    • AToM production protocols are highly sensitive to starting structure, as such its vital that care it taken in the minimisation, equilibration and annealing of systems. As a rule of thumb the protocol used should be Minimisation->Equilibration without ATMForce -> annealing to lambda1,lambda2=0.5 -> equilibration with ATMForce with lamdba1,lambda2 = 0.5. Any systems in which instability is experienced in systems with direction=-1 should be addressed by increasing the runtime of post-annealing equilibration.
  • Once production simulations have been run (either externally or using BioSimSpace.FreeEnergy.AToM.run()) analysis can be performed using BioSimSpace.FreeEnergy.AToM.analyse() - this uses an internal UWHAM implementation to find the overall ddg.

Very roughly, a full start to finish AToM run would look like this:

import BioSimSpace as BSS

lig1 = BSS.IO.readMolecules({ligand1 files})[0]
lig2 = BSS.IO.readMolecules({ligand2 files})[0]
prot = BSS.IO.readMolecules({protein files})[0]

AToM = BSS.FreeEnergy.AToM(protein = prot, ligand1 = lig1, ligand2 = lig2)
AToM_system, data = AToM.prepare(
    ligand1_rigid_core=[a, b, c],
    ligand2_rigid_core=[d, e, f],
    displacement="20A",
)
...
#### solvate AToM_system ####
...
min_protocol = BSS.Protocol.AToMMinimisation(data, {options})
minimise = BSS.Process.OpenMM(AToM_system, min_protocol)
minimise.start()
minimise.wait()
minimised = minimise.getSystem()
...
#### now do equilibration, annealing and ATM equilibration, API same as minimisation, 
#### setting the required options) ####
...
production_atm = BSS.Protocol.AToMProduction(
    data=data,
    {options}
)
production = AToM.run(
    {minimised and equilibrated AToM_system},
    production_atm,
    work_dir = {output directory},
)
production.wait()

BSS.FreeEnergy.Analyse({output directory})

This PR also includes (hopefully) full API docs, as well as a brief summary of AToM within the docs for BioSimSpace.FreeEnergy.


  • I confirm that I have merged the latest version of devel into this branch before issuing this pull request (e.g. by running git pull origin devel): [y/n]
  • I confirm that I have added a test for any new functionality in this pull request: [y/n]
  • I confirm that I have added documentation (e.g. a new tutorial page or detailed guide) for any new functionality in this pull request: [y/n]
  • I confirm that I have permission to release this code under the GPL3 license: [y/n]

Suggested reviewers:

@lohedges

Begins to add support for serial AToM simulations in BioSimSpace OpenMM.
Several bug fixes, production simulations now run (contingent on minimisation and equilibration).
The introduction of this lever means that guesses have to be made regarding underlying details of the lambda schedule.

Current assumptions are made using the base configs of both the Gallacchio lab and femto protocols
… argument to BSS.FreeEnergy.AToM.relativeATM
…to increase the stability of high lambda value calculations
…of AToM systems.

Includes large amounts of re-factoring of ATM code.
…tential well used to positonally restrain atoms
…protein.

this is acheived by adding the ability to parse 'protein_index' as a list of ints.

Required for the eralpha test system as it is truncated
Copy link
Contributor

@lohedges lohedges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for this heroic effort, @mb2055. Things are looking really good and the new tutorial is great.

python/BioSimSpace/FreeEnergy/_atm.py Outdated Show resolved Hide resolved
doc/source/api/index_FreeEnergy.rst Outdated Show resolved Hide resolved
Comment on lines 1013 to 1020
def run(
system,
protocol,
platform="CPU",
work_dir=None,
setup_only=False,
property_map={},
):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still isn't resolved, but I don't see any easy way to do it given the state stored by the AToM class. Perhaps it's easiest to leave like this, since it is similar to the logic for the MD and Metadynamics modules. (Just a bit confusing if you're used to the FreeEnergy.Relative API. I'll have think before merging.

@lohedges lohedges added the enhancement New feature or request label Oct 24, 2024
@lohedges lohedges merged commit 85e7f36 into devel Oct 24, 2024
5 checks passed
@lohedges lohedges deleted the feature_AToM branch October 24, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request exscientia Related to work with Exscientia
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants