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

Protocol to run plain MD simulations #516

Merged
merged 78 commits into from
Dec 28, 2023
Merged

Protocol to run plain MD simulations #516

merged 78 commits into from
Dec 28, 2023

Conversation

hannahbaumann
Copy link
Contributor

@hannahbaumann hannahbaumann commented Aug 7, 2023

Developers certificate of origin

@codecov
Copy link

codecov bot commented Aug 8, 2023

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (2213b71) 92.82% compared to head (b16d91d) 91.38%.

Files Patch % Lines
.../tests/protocols/test_openmm_plain_md_protocols.py 95.08% 9 Missing ⚠️
openfe/protocols/openmm_md/plain_md_methods.py 97.14% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #516      +/-   ##
==========================================
- Coverage   92.82%   91.38%   -1.44%     
==========================================
  Files         128      132       +4     
  Lines        8711     9114     +403     
==========================================
+ Hits         8086     8329     +243     
- Misses        625      785     +160     
Flag Coverage Δ
fast-tests 91.38% <96.52%> (?)
slow-tests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@richardjgowers
Copy link
Contributor

@hmacdope MD stuff here

@dotsdl
Copy link
Member

dotsdl commented Aug 17, 2023

Is this a Protocol intended for use with a NonTransformation? What is the meaning of having a stateA and stateB ChemicalSystem for this Protocol? Would they just be the same ChemicalSystem?

@hannahbaumann
Copy link
Contributor Author

Yes, this is intended for use with NonTransformation and stateA and stateB are the same ChemicalSystem (which I should probably make more clear).

@richardjgowers richardjgowers self-assigned this Oct 2, 2023
Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

Super super late review - sorry @hannahbaumann

Finally got to looking at this last night. Overall this looks great thanks!

Just a couple of things, mostly some updates for changes that occured in main.

openfe/protocols/openmm_md/plain_md_methods.py Outdated Show resolved Hide resolved
openfe/protocols/openmm_md/plain_md_methods.py Outdated Show resolved Hide resolved
openfe/protocols/openmm_md/plain_md_methods.py Outdated Show resolved Hide resolved
openfe/protocols/openmm_md/plain_md_methods.py Outdated Show resolved Hide resolved
openfe/protocols/openmm_md/plain_md_methods.py Outdated Show resolved Hide resolved
openfe/protocols/openmm_md/plain_md_methods.py Outdated Show resolved Hide resolved
openfe/protocols/openmm_md/plain_md_methods.py Outdated Show resolved Hide resolved
Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
@pep8speaks
Copy link

pep8speaks commented Nov 3, 2023

Hello @hannahbaumann! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 157:80: E501 line too long (89 > 79 characters)
Line 392:80: E501 line too long (91 > 79 characters)
Line 396:80: E501 line too long (88 > 79 characters)
Line 493:80: E501 line too long (89 > 79 characters)
Line 550:80: E501 line too long (83 > 79 characters)
Line 595:80: E501 line too long (84 > 79 characters)
Line 596:80: E501 line too long (84 > 79 characters)
Line 597:80: E501 line too long (84 > 79 characters)
Line 598:80: E501 line too long (84 > 79 characters)
Line 599:80: E501 line too long (84 > 79 characters)
Line 600:80: E501 line too long (94 > 79 characters)

Line 386:76: W291 trailing whitespace
Line 400:80: E501 line too long (86 > 79 characters)
Line 402:62: W291 trailing whitespace
Line 405:67: W291 trailing whitespace
Line 408:67: W291 trailing whitespace

Line 1:1: W391 blank line at end of file

Line 220:80: E501 line too long (81 > 79 characters)

Line 51:80: E501 line too long (91 > 79 characters)
Line 108:80: E501 line too long (83 > 79 characters)
Line 317:52: E251 unexpected spaces around keyword / parameter equals
Line 318:9: E128 continuation line under-indented for visual indent
Line 319:63: E251 unexpected spaces around keyword / parameter equals
Line 320:9: E128 continuation line under-indented for visual indent
Line 322:52: E251 unexpected spaces around keyword / parameter equals
Line 323:9: E128 continuation line under-indented for visual indent
Line 323:80: E501 line too long (94 > 79 characters)
Line 379:80: E501 line too long (90 > 79 characters)
Line 380:80: E501 line too long (81 > 79 characters)
Line 397:80: E501 line too long (90 > 79 characters)
Line 398:80: E501 line too long (81 > 79 characters)
Line 427:80: E501 line too long (93 > 79 characters)
Line 437:5: E303 too many blank lines (2)

Line 527:1: W391 blank line at end of file

Comment last updated at 2023-12-28 00:03:29 UTC

@IAlibay
Copy link
Member

IAlibay commented Nov 23, 2023

@hannahbaumann - I think I know what's going on with that runner, I'm just going to push an extra __init__.py file to debug.

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

I still need to do a proper review later, but here's a couple of things re: the __init__.py files.

openfe/protocols/openmm_md/__init__.py Outdated Show resolved Hide resolved
openfe/tests/data/openmm_md/__init__.py Outdated Show resolved Hide resolved
Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

Reviewing in chunks to make it easier 😅 - here's the protocol results, just needs better return information.

"""String of trajectory file name"""
traj = [pus[0].outputs['nc'] for pus in self.data.values()]

return traj
Copy link
Member

Choose a reason for hiding this comment

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

Definitely not for this PR, but something we should consider next is getting access to the various other files (e.g. equilibration, etc...). Then we should expand to do things like getting energy values etc...

openfe/protocols/openmm_md/plain_md_methods.py Outdated Show resolved Hide resolved

return None

def get_traj_filename(self):
Copy link
Member

Choose a reason for hiding this comment

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

If possible, could you put a return annotation on this and/or in the docstring so that folks can easily check what they are getting back?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this, does that look ok?

openfe/protocols/openmm_md/plain_md_methods.py Outdated Show resolved Hide resolved
Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

second set of comments - protocol looks great, mostly a few comments about names in settings, but nothing major / that I think should significantly change

openfe/protocols/openmm_md/plain_md_methods.py Outdated Show resolved Hide resolved
openfe/protocols/openmm_md/plain_md_methods.py Outdated Show resolved Hide resolved

# Set barostat frequency to zero for NVT
for x in simulation.context.getSystem().getForces():
if x.getName() == 'MonteCarloBarostat':
Copy link
Member

Choose a reason for hiding this comment

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

Future TODO (not in this PR): we should expand this to cover all the barostats (I assume it won't work with flexible/anisotropic/membrane, etc.. variants).

# Save last frame NPT equilibration
positions = to_openmm(
from_openmm(simulation.context.getState(
getPositions=True, enforcePeriodicBox=False
Copy link
Member

Choose a reason for hiding this comment

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

Curiosity question - I've not played around with enforcePeriodicBox much, does it bring along significant advantages to disable it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, I'm not sure, this might depend on what the user wants to do with the trajectory/structure?
False is the default here and means "the position of each particle will be whatever position is stored in the Context, regardless of periodic boundary conditions".
So if the users want to e.g. visualize the structure afterwards, they might want to first remove pbc/make things whole.
Do you have a preference here?

Copy link
Member

Choose a reason for hiding this comment

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

We don't really expose this file currently, and it's likely only going to really get used for debugging purposes. I think it's probably fine to leave it as it is.

simulation.reporters.append(openmm.app.CheckpointReporter(
file=str(shared_basepath / simulation_settings.checkpoint_storage),
reportInterval=simulation_settings.checkpoint_interval.m))
simulation.reporters.append(openmm.app.StateDataReporter(
Copy link
Member

Choose a reason for hiding this comment

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

TODO: as discussed in a call a few weeks back, in a next PR we should hook up the results object to point to these and maybe have methods for reading data out for commonly needed things (reduced potential etc..)

openfe/protocols/openmm_utils/omm_settings.py Outdated Show resolved Hide resolved
openfe/protocols/openmm_utils/omm_settings.py Outdated Show resolved Hide resolved
openfe/protocols/openmm_utils/omm_settings.py Outdated Show resolved Hide resolved
openfe/protocols/openmm_utils/omm_settings.py Outdated Show resolved Hide resolved
Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

Just the one question on tests, otherwise it looks good to me :)

openfe/tests/protocols/test_openmm_plain_md_protocols.py Outdated Show resolved Hide resolved
Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

Just the one thing, but otherwise this lgtm!

openfe/protocols/openmm_md/plain_md_methods.py Outdated Show resolved Hide resolved
# Save last frame NPT equilibration
positions = to_openmm(
from_openmm(simulation.context.getState(
getPositions=True, enforcePeriodicBox=False
Copy link
Member

Choose a reason for hiding this comment

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

We don't really expose this file currently, and it's likely only going to really get used for debugging purposes. I think it's probably fine to leave it as it is.

@IAlibay
Copy link
Member

IAlibay commented Dec 28, 2023

Going ahead with a merge here - waiting on this longer will hold up, amongst other things, #614

@IAlibay
Copy link
Member

IAlibay commented Dec 28, 2023

Thanks so much for getting this done @hannahbaumann !

@IAlibay IAlibay merged commit 5a2c339 into main Dec 28, 2023
8 of 9 checks passed
@IAlibay IAlibay deleted the plain_md branch December 28, 2023 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants