Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Support removal of Hydrogens when using gaff forcefield #60

Merged
merged 5 commits into from
Jul 29, 2021
Merged

Support removal of Hydrogens when using gaff forcefield #60

merged 5 commits into from
Jul 29, 2021

Conversation

chrisjonesBSU
Copy link
Member

This PR should allow users to run united atom simulations while using the gaff force field. Since we still have the custom-gaff force field to deal with, this basically results in 2 different methods of hydrogen being removed, but this really only adds one extra if statement. This can be cleaned up once #59 is resolved.

This solves #45

@codecov
Copy link

codecov bot commented Jul 6, 2021

Codecov Report

Merging #60 (5f624e2) into master (311c4af) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #60      +/-   ##
==========================================
- Coverage   98.95%   98.91%   -0.04%     
==========================================
  Files           6        6              
  Lines         191      184       -7     
==========================================
- Hits          189      182       -7     
  Misses          2        2              
Impacted Files Coverage Δ
planckton/init.py 100.00% <100.00%> (ø)

@chrisjonesBSU chrisjonesBSU linked an issue Jul 6, 2021 that may be closed by this pull request
@@ -182,7 +177,7 @@ def pack(self, box_expand_factor=5):
typed_system : ParmEd structure
ParmEd structure of filled box
"""
if self.remove_hydrogen_atoms:
if self.remove_hydrogen_atoms and self.ff == FORCEFIELD["gaff-custom"]:
self._remove_hydrogen()
Copy link
Member

Choose a reason for hiding this comment

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

Does this work on a typed system? It may be better to type the system, then check if we want to remove hydrogens, then do it the gaff way or the non gaff way instead of doing it in two different parts of the code

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, the existing function to remove hydrogens does so from the mbuild compound before the forcefield is applied by foyer. This only works if someone is using one of the pre-existing *_typed.mol2 compounds along with the gaff-custom forcefield.

The other scenario is if someone is generating a compound from SMILES, or a file that hasn't been typed using the old ambertools method. These compounds can't have hydrogens removed from the mbuild compound before being typed by foyer since they are typed using SMARTS matching.

We could check if removing the hydrogens from the parmed structure works for the *_typed.mol2 compounds, and get rid of or change the _remove_hydrogens to only use this method.

typed_system.strip([a.atomic_number == 1 for a in typed_system.atoms])

Ultimately, this is just a temporary solution that allows someone to do UA sims if they are simulating systems outside of the existing group we have (e.g. the REUs this summer), but I think the goal is to move away from having the pre-typed mol2 files and the custom gaff forcefield #59. Once that happens then there would only be one way of

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks like typed_system.strip([a.atomic_number == 1 for a in typed_system.atoms]) would still work on one of the typed mol2 files after playing around real quick in a jupyter notebook. I'll try it out in the PR and see how it works.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I tested it out in planckton and it looks like that works. Keep the hydrogens on until after the forcefield is applied by foyer and just remove them from the resulting parmed structure.

Copy link
Member

Choose a reason for hiding this comment

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

Perfect that should be much more simple!

Copy link
Member

@jennyfothergill jennyfothergill left a comment

Choose a reason for hiding this comment

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

This is so much cleaner--thanks @chrisjonesBSU! We might notice a slowdown with large systems (removing H from one compound vs. from whole system) but I'm not sure. Anyway, using the element number is much better than maintaining a list of all the H types, and this gives us much more flexibility! :)

@jennyfothergill jennyfothergill merged commit f633184 into cmelab:master Jul 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change the way remove hydrogens works
3 participants