-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add coordinate wrapping #48
Conversation
I might be missing something, but could you please explain how the coordinate wrapping treats PBC? As far as I can tell you're still not treating the boundary rows and columns of the surface grid? I'm also not convinced that you can validly wrap atom coordinates when they have been rotated and translated as I believe you preprocess your trajectories to do. Perhaps you could instead get the translation, or translation + rotation matrix (to center on the protein if any) for each frame, and use that to transform your surface? This is indirectly related to @orbeckst's project 5 of GSoC (https://github.com/MDAnalysis/mdanalysis/wiki/Project-Ideas-2021#project-5-general-unit-cell-representation), by the way. I'm just pointing that out of interest and as more motivation for the project to go forward rather than suggesting you implement it (although you are welcome to, of course!) Just storing the matrix for each frame of this analysis would be a great starting point. Edit: sorry if I'm a bit short here, just trying to catch a few bars of signal when I can find it -- which is less than I originally expected |
I pushed changes to use |
@orbeckst @lilyminium @IAlibay @richardjgowers do I have a green light here? Thanks. |
@ojeda-e looks good but I'd clarify what wrapping is doing here. PBC treatment is confusing as it means one of two very different things |
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 would also add some documentation explaining when you should use wrap=True
and explain in words what it achieves.
Thanks, @orbeckst, initially I was planning to add the explanation of when to use Now that you point it out I'll add a brief description here in |
Can I have an approval here, please? @richardjgowers @orbeckst @lilyminium |
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.
@ojeda-e just a few suggestions :-)
@@ -211,7 +212,7 @@ def test_get_z_surface(x_bin, y_bin, x_range, y_range, expected_surface): | |||
class TestMembraneCurvature(object): | |||
@pytest.fixture() | |||
def universe(self): | |||
return mda.Universe(GRO_PO4_SMALL, XTC_PO4_SMALL) |
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 deleted the trajectory for now since I would need to create a new trajectory test with u.dimensions[2]=30
. Skipping the trajectory the tests pass.
I discover a "little" bug in my Thanks to @lilyminium for asking me to add tests with |
I added two fixtures for universes:
Intentionally, I made the two fixtures match with the derived
For each test that involves curvature, I calculated I also discover another bug in Thanks again @lilyminium |
Thank you for adding the new tests @ojeda-e! |
The pushed changes include:
Thanks @lilyminium |
n_y_bins=y_bin).run() | ||
avg_surface = mc.results.average_z_surface | ||
def test_analysis_get_z_surface_wrap(self, curvature_unwrapped_universe, dummy_surface): | ||
avg_surface = curvature_unwrapped_universe.results.average_z_surface | ||
assert_almost_equal(avg_surface, dummy_surface) | ||
|
||
# test surface in universe with atoms out of bounds in x and y |
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.
You could use the curvature_unwrapped_universe_xy
fixture here too, right? (the line after)
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.
Oh, yeah, I missed that, thanks!
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.
Thanks @ojeda-e, the new indices are much easier to understand! I found another place you could use a fixture, but otherwise, this looks good to me :D
Would it make sense to add a logger there?
This might come down to personal preference. I don't ever log warnings because users can just logging.captureWarnings(True)
in their scripts if they really want it to log. @orbeckst might have a different opinion.
Thanks for checking this @lilyminium! This was a very buggy PR 🐛 but glad it's all fixed now! :D |
In this PR I added PBC conditions. Changes in this PR fix #36 and possibly #22
self.ag.wrap()
added to__init__
and_single_frame
.results.z_surface
andresults.mean
were updated.xfail(reason="PBC conditions not applied.")
(See line 276 istests_membrane_curvature.py
.@orbeckst @lilyminium @IAlibay are there any other relevant tests I am missing here?
Thanks