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

Feature Multiple Distance Restraints #178

Merged
merged 25 commits into from
Dec 4, 2023
Merged

Conversation

fjclark
Copy link
Contributor

@fjclark fjclark commented Oct 2, 2023

Is this pull request to fix a bug, or to introduce new functionality?

This PR introduces functionality for setting up and running ABFE calculations with multiple distance restraints. This requires the functionality in this Sire PR.

If this introduces new functionality...

Changes proposed in this pull request:

  • Extend the Restraint class to hold multiple distance restraints and to write input files for calculations of this type with SOMD
  • Implement a restraint search algorithm for multiple distance restraints. This currently:
    • Selects distance restraints for all heavy atoms in the ligand
    • Prioritises restraints between pairs of atoms with low SD of distance based on a simulation of the fully interacting complex
    • Promotes diversity of direction of the distance restraints by clustering candidate restraints by direction and selecting only one restraint per directional cluster
    • Chooses the flat-bottomed radius of the restraints to encompass 95 % of the distance sampled during the simulation of the fully interacting complex, so that the free energy of introducing the restraints is negligible
  • 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
  • I confirm that I have added a test for any new functionality in this pull request: y
  • I confirm that I have added documentation (e.g. a new tutorial page or detailed guide) for any new functionality in this pull request: n (I will added a section to the ABFE tutorial if approved)
  • I confirm that I have permission to release this code under the GPL3 license: y

When testing locally, all tests that I've added or that are related to functionality that I've changed pass. However, the following tests fail:

FAILED tests/Sandpit/Exscientia/Trajectory/test_trajectory.py::test_rmsd - AttributeError: 'TrajectoryIterator' object has no attribute 'rmsd'
FAILED tests/Sandpit/Exscientia/_SireWrappers/test_system.py::test_set_box - assert False
FAILED tests/Sandpit/Exscientia/_SireWrappers/test_system.py::test_rotate_box_vectors - AttributeError: 'TriclinicBox' object has no attribute 'rotate'

Suggested reviewers:

@lohedges, @chryswoods

Any additional context of information?

As shown in the Sire PR, so far my tests show no evidence of a significant difference compared to Boresch restraints. My test input scripts are here.

Thanks very much.

fjclark and others added 15 commits August 8, 2023 09:38
This includes specifying the format of the restraints dictionary
and implementing the numerical correction.
Allow correct SOMD config and pert files to be written for multiple
distance restraints. Accompanying tests have also been introduced.
This involved introducing an additional perturbation type
"release_restraint", used exclusively with multiple distance restraints
to remove all distance restraints but the "permanent" distance
restraint.
Ensure that "endmolecule" is written for all SOMD pert files, and
make the tests on the SOMD pert files more detailed (added checks
for start and end atom and molecule lines).
Increase the number of directional clusters until the restraint search
succeeds or hits the maximum.
@fjclark fjclark temporarily deployed to biosimspace-build October 2, 2023 16:45 — with GitHub Actions Inactive
@fjclark fjclark temporarily deployed to biosimspace-build October 2, 2023 16:45 — with GitHub Actions Inactive
@fjclark fjclark temporarily deployed to biosimspace-build October 2, 2023 16:45 — with GitHub Actions Inactive
@fjclark fjclark temporarily deployed to biosimspace-build October 2, 2023 16:45 — with GitHub Actions Inactive
@fjclark fjclark temporarily deployed to biosimspace-build October 2, 2023 16:45 — with GitHub Actions Inactive
@lohedges lohedges added the enhancement New feature or request label Oct 3, 2023
@lohedges
Copy link
Contributor

lohedges commented Oct 3, 2023

Thanks, @fjclark:

When testing locally, all tests that I've added or that are related to functionality that I've changed pass. However, the following tests fail:

Since the same tests passed during the CI here, I can only assume that locally you are testing against outdated versions of Sire and BioSimSpace? The TriclinicBox changes are fairly recent, so it's possible that you hadn't pulled them across to your fork.

@fjclark
Copy link
Contributor Author

fjclark commented Oct 3, 2023

Yes, thanks - I had pulled the changes but forgotten to reinstall Sire (they now pass as expected).

@chryswoods
Copy link
Contributor

Thanks - we are about to release 2023.4.0 (likely end of this week or early next week - it will depend on when we squash these last bugs).

Do you want this included in 2023.4.0? Or do you want more time to test it? I don't mind either way and am happy to review and merge this this week if you are happy for it to be included.

@lohedges
Copy link
Contributor

lohedges commented Oct 3, 2023

I think @xiki-tempula might like to test this implementation soon, so I guess it might depend on whether he'd prefer that to be in 2023.4.0, or 2024.1.0.dev (or whatever it is).

@chryswoods
Copy link
Contributor

chryswoods commented Oct 3, 2023

2023.4.0 would mean we could further test and then fix bugs as part of 2023.4.1+. Going for 2023.5.0.dev would mean that it will be stuck in the dev package until we release 2023.5.0 (end of December).

The risk of going early is if this regresses or breaks existing functionality in any way. Do we have good regression tests for this code to demonstrate it will be safe to merge?

@xiki-tempula
Copy link
Contributor

Thanks for informing me. I'm fine either way but I noticed that the implementation for the new restraint is for SOMD only and our pipeline currently only supports Gromacs, so I might not be testing it in the near future.

@fjclark
Copy link
Contributor Author

fjclark commented Oct 4, 2023

Thanks - we are about to release 2023.4.0 (likely end of this week or early next week - it will depend on when we squash these last bugs).

Do you want this included in 2023.4.0? Or do you want more time to test it? I don't mind either way and am happy to review and merge this this week if you are happy for it to be included.

Thanks very much. I think slightly more time to test it would be best. I'll also look into implementing this in Gromacs. I'll let you know once I've done this.

@xiki-tempula
Copy link
Contributor

@fjclark Thanks

@chryswoods
Copy link
Contributor

I reviewed and merged in the sire part of this so that it would make 2023.4.0 (sorry for not seeing the above first). The changes looked orthogonal to existing functionality, so relatively safe to include. I agree to wait for the next release for the BioSimSpace part - this will give you more time to test the interface before making this feature more public.

This is done by using restraint potentials (function type 10)
for the flat-bottomed restraints which are affected by lambda-
restraint, and a distance restraint for the permanent restraint
which is not affected by any lambdas. See
https://manual.gromacs.org/documentation/2019-rc1/reference-manual/topologies/topology-file-formats.html#id31
for details. Note that the distance restraint requires the force
constant to be written to the mdp file.
@fjclark fjclark temporarily deployed to biosimspace-build November 14, 2023 16:58 — with GitHub Actions Inactive
@fjclark fjclark temporarily deployed to biosimspace-build November 14, 2023 16:58 — with GitHub Actions Inactive
@fjclark fjclark temporarily deployed to biosimspace-build November 14, 2023 16:59 — with GitHub Actions Inactive
@fjclark fjclark temporarily deployed to biosimspace-build November 14, 2023 17:00 — with GitHub Actions Inactive
@fjclark fjclark temporarily deployed to biosimspace-build November 14, 2023 17:16 — with GitHub Actions Inactive
@fjclark
Copy link
Contributor Author

fjclark commented Nov 18, 2023

Hi @lohedges, I've now finished implementing this for SOMD and for GROMACS and have validated both implementations by comparing with Boresch restraints. In both cases, I ran 5 independent replicates of the bound leg with each type of restraint and the errors are 95 % t-based confidence intervals:

SOMD

Boresch

Multiple Distance Restraints

However, I observed a couple of crashes during the release restraint stage. To investigate these further, I ran 90 release restraint windows (10 replicates of 9 windows), and observed 10 crashes:

These crashes are sometimes observed when there are no restraints, and seem to occur much more frequently with open force fields compared to GAFF. As no crashes were observed with GROMACS, this seems to be a strange SOMD bug. More discussion is given here.

For now, I've added a warning about potential instabilities whenever multiple distance restraints are used with SOMD.

GROMACS

Boresch

Multiple Distance Restraints

Overall

There is no evidence for a significant difference between Boresch restraints and multiple distance restraints for either engine. @lohedges and @xiki-tempula, once you're happy with this PR I'll add a section to the tutorials showing how to use these. It's slightly different to Boresch restraints for GROMACS as a) The user has to specify restraint-lambda instead of bonded-lambda b) the calculation has to be split into two stages. This is because the only way I could see to do this was using a combination of bond restraint potentials (affected by restraint-lambda) and distance restraints (not affected by restraint-lambda).

fjclark added a commit to fjclark/biosimspace_tutorials_openbiosim that referenced this pull request Nov 18, 2023
This requires the changes to BioSimSpace implemented
here: OpenBioSim/biosimspace#178.
@jmichel80
Copy link
Contributor

That’s great work ! There seems to be a surprising difference in precision between the two engines, something to think about.

@lohedges lohedges changed the title [WIP] Feature Multiple Distance Restraints Feature Multiple Distance Restraints Nov 21, 2023
@lohedges
Copy link
Contributor

Thanks @fjclark. Given the tests pass and this only touches sandpit functionality, I'd be happy to merge. Perhaps @xiki-tempula would like to check that it doesn't cause any issues with the internal Exs test suite before merging?

@xiki-tempula
Copy link
Contributor

I have skim through the PR and I think it looks ok.

@lohedges lohedges merged commit 755103e into OpenBioSim:devel Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants