-
Notifications
You must be signed in to change notification settings - Fork 37
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
Example notebooks for HydrogenBondAnalysis #133
Conversation
* Fixes issue MDAnalysis#100 * adds examples of selecting residues from each segment, or atoms from each residue
* Fixes MDAnalysis#93 * Adds tutorials on various ways to do analysis in parallel
- Changed 'selection' keyword to 'select' - Added radius_cut_q and explained results more - Added background section - Added bit more intro to readme
- added `match_atoms` keyword - clarified some of the `in_memory`/filename reasons
Changes: - Added links to API docs for each class/function in each tutorial - Updated links in Quickstart guide - Fixed link to alignment example notebook
Add Binder badge
… hbonds Merge latest commits from upstream master
I've just seen that @lilyminium has already created a PR with a notebook showing how to perform the hydrogen bond analysis (PR #125) - sorry again I took so long! I'm not sure what's easiest - perhaps I could remove the first notebook I've written (hbonds.ipynb) and keep the second and third to complement @lilyminium's? |
I don't know what the best way forward is but I do know that we desperately need a proper example for HydrogenBondAnalysis. @p-j-smith @lilyminium could you two figure out how to get the work here and/or in PR #125 into the User Guide rather sooner than later? I was just reminded by a comment on the mailing list https://groups.google.com/g/mdnalysis-discussion/c/p2vFYvXBM78/m/suZUf_fWBAAJ |
Tomorrow I will use @lilyminium's notebook as a base and add a couple of things from my first notebook (e.g. how to plot hbonds as a function of ,z and an image showing the geometric criteria for an hbond). Although I'm open to other suggestions too? Should the notebooks be designed to work with the new develop for 2.0? I mean, should the results be accessed via Also, I think I created a branch off develop rather than off master, so on this PR there are a couple of commits from @lilyminium. Should I create a new branch off master and submit a new PR? And sorry about how confusing the docs are for people - they clearly need improving. I don't have much experience writing documentation, so I'd be happy to hear about how the docs can be made better. |
Thank you! Docs should be for 2.x at this stage. For anything else @lilyminium will have better answers than I. |
Many apologies for the delay on this.
@p-j-smith that depends a little on what you would like to include in your notebook. Master is at 1.1.1 for now and develop is still for 2.x, so it's up to you if you want to make a PR to one and I can back/forwardport it to the other -- but if you're planning to include the new |
hbonds notebook review (diff is too large to review on GitHub and I haven't worked out how to do this in VS Code yet): Overall a great introduction to hbond analysis, thank you! I think you need to make this PR to develop as you use f-strings (python 3.6+) and make reference to pickling. --- We will load a small water-only systems containing 5 water molecules and 10 frames then find the hydrogen bonds present at each frame.
+++ We will load a small water-only system containing 5 water molecules and 10 frames, and find the hydrogen bonds present at each frame.
"For a small performance boost, update_selections can always be set to False. However, always set update_selections to True if you think that your selection will update over time -- for example, the number of oxygens within 3.0 angstrom may update over time if you choose acceptors_sel="name OH2 and around 3.0 protein"".
for frame, donor_indices, *_ in hbonds.hbonds:
u.trajectory[frame]
donors = u.atoms[donor_indices.astype(int)]
zpos = donors.positions[:,2]
hist, *_ = np.histogram(zpos, bins=bin_edges)
counts += hist
df = pd.DataFrame(hbonds.hbonds.T[:4].astype(int),
columns=["Frame",
"Donor_ix",
"Hydrogen_ix",
"Acceptor_ix",])
df["Distances"] = hbonds.hbonds.T[5]
df["Angles"] = hbonds.hbonds.T[6]
df["Donor resname"] = u.atoms[df.Donor_ix].resnames
df["Acceptor resname"] = u.atoms[df.Acceptor_ix].resnames
... and so on
|
hbonds_selections:
That's all I have to say for this one, short and sweet :) Perhaps you could link to it from the hbonds notebook though, as an "if you want more specific selections please see this notebook"? |
hbonds-selections: Nice notebook, I like all the graphs. Just a few notes:
|
Thank you for the thorough reviews @lilyminium! I'll work on the notebooks later today |
Hi, Following https://www.lammps.org/tutorials/italy14/HandsonAnalysisScripting.pdf I compare your notebook with mine, they are similar. My simulation ran for 10ps. As the other properties were converged I thought it was enough. Moreover, when I plot the number of hbonds with respect to time it is converged after the 4th time step. Do you have any idea why I do not get 3.3 ? [edit] Here is the code I used. I compare with your notebook, the result is the same.
|
Hi @yannclaveau, generally you should ask questions related to usage of MDAalysis on the Google group (https://groups.google.com/g/mdnalysis-discussion) or on Discord (you can sign up to the MDAnalysis server here: https://discord.gg/fXTSfDJyxE). But to answer your question, |
I think I've made all the changes you suggested in your review @lilyminium. For the hbonds intro notebook:
Yep! Your way is much more readable. It does involve iterating over every hydrogen bond individually, rather than every frame, but I guess for the tutorial readability takes precedence. |
hbonds-selections:
I think there is currently no protein-water system in the data files, but there is discussion about it in MDAnalysis/MDAnalysisData#45 Perhaps for now we can use the protein-only system, and when there is a protein-water system available I'll update the notebook?
At the top of the notebook there are links to the other two hbond notebooks, although I can make them more prominent? |
hbonds-lifetimes:
So |
Oh I see, my bad, thanks for explaining. |
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.
Thank you so much for adding these notebook examples, and your patience in waiting. HBond analysis is a very popular part of MDAnalysis and many, many people will benefit greatly by having these at reference!
I'm happy to have added them, I hope they're useful for people. And thank you for improving them with your reviews! |
Sorry for that, I thought it may be a problem with hbondsanalysis or with the notebook, that's why I asked it here. |
No need to apologise, and you're right that is was a problem with the initial notebook.
I think it should be okay to use 1.1.
Is your system a box of pure water? Have you tried comparing the output to that of e.g. VMD HBonds plugin? If you find a different result, or if you have a simple system where you know the number of hydrogen bonds but |
@p-j-smith Thanks, that's fine now. Thanks to the final version, I understand why : I thought the distance Rda was between the H and O. (I think it was pictured like that in the previous version?). Choosing Rda = 3.5 A (as staded in https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.76.928 ), instead of 3.0, gives me 1.6, so 3.2 H bonds / H2O. So everything is fine. |
Hi, sorry it has been so long since we spoke about this in #105. I have finally written a couple of notebooks to illustrate how to use HydrogenBondAnalysis and to calculate hydrogen bond lifetimes.
I wasn't sure exactly what to include/how much detail to go into for the examples, but I've add three notebooks:
https://p-j-smith.github.io/UserGuide/examples/analysis/hydrogen_bonds/hbonds.html This shows the basic usage the class, including the helper methods. It also shows how to use the results for further analysis - in this case, plotting the number of hbonds as a function of z. The final thing is how to store data, including saving it in a pandas DataFrame.
https://p-j-smith.github.io/UserGuide/examples/analysis/hydrogen_bonds/hbonds-selections.html This shows some advanced selections, including use of the
between
argument.https://p-j-smith.github.io/UserGuide/examples/analysis/hydrogen_bonds/hbonds-lifetimes.html This shows how to calculate hydrogen bond lifetimes.
For now I've used the current protein-only trajectory rather than adding a new system (as was suggested in #105), but am happy to change this if people think it will provide a better example.