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

Opening universe described in HBondAnalysis docs causes error #838

Closed
jdetle opened this issue May 2, 2016 · 7 comments
Closed

Opening universe described in HBondAnalysis docs causes error #838

jdetle opened this issue May 2, 2016 · 7 comments

Comments

@jdetle
Copy link
Contributor

jdetle commented May 2, 2016

Expected behaviour

Running HBondAnalysis as specified in the docs should work as expected, if I am missing something simple please let me know.

Actual behaviour

error

Code to reproduce the behaviour

import MDAnalysis as mda
u = mda.Universe(PSF, PDB)
....

Current version of MDAnalysis:

0.14.1-dev0

@jdetle jdetle changed the title Opening universe described in docs causes error Opening universe described in HBondAnalysis docs causes error May 2, 2016
@kain88-de
Copy link
Member

Do PSF and PDB contain the same protein? It looks like we are trying to read more atoms from the PDB then we actually allocated from the PSF topology.

@richardjgowers
Copy link
Member

Yeah the PDB file is much longer (it's solvated), I think PSF DCD is the correct combination

@jdetle
Copy link
Contributor Author

jdetle commented May 2, 2016

Okay this is an error in the Docs, I'll go ahead and change PDB to DCD. This will be solved by #833.

@kain88-de
Copy link
Member

Thanks.

@orbeckst
Copy link
Member

orbeckst commented May 4, 2016

I think PSF DCD is the correct combination

@jdetle also noted that the example wrongly suggests one could use the PSF/DCD combo to analyze water-protein hydrogen bonds. But the PSF/DCD combo was simulated in implicit solvent and does not have TIP3 water inside.

Instead use something like the following example where we calculate the average number of hydrogen bond for protein residues that are solvent-exposed:

import numpy as np
import MDAnalysis as mda
from MDAnalysis.tests.datafiles import GRO, XTC
from MDAnalysis.analysis.hbonds import HydrogenBondAnalysis

u = mda.Universe(GRO, XTC)

# hydrogen bonds
H = HydrogenBondAnalysis(u, 'protein', 'resname SOL', distance=3, angle=120)
H.run()
counts = H.count_by_time()
print(counts.count)
# [586 594 577 588 573 610 599 596 598 602]

# exposed residues (quick to write, slow to execute...)
Nres_exposed = np.array([u.select_atoms("protein and around 3 resname SOL").n_residues for ts in u.trajectory], dtype=np.float64)

# hbonds per residue
avg_hbonds = counts.count/Nres_exposed

# plot
import matplotlib.pyplot as plt
plt.matplotlib.style.use('ggplot')
fig = plt.figure(figsize=(5,5))
ax = fig.add_subplot(111)
ax.fill_between(counts.time, avg_hbonds, color="blue", alpha=0.3)
ax.set_xlabel(r"time $t$ (ps)")
ax.set_ylabel(r"mean number of hydrogen bonds protein-water $\langle N \rangle$")
fig.savefig("adk_avg_protein_water_hbonds.png")

adk_avg_protein_water_hbonds

@orbeckst
Copy link
Member

orbeckst commented May 6, 2016

@jdetle, will this be fixed with PR #833?

@jdetle
Copy link
Contributor Author

jdetle commented May 6, 2016

Yep!
On Fri, May 6, 2016 at 2:07 PM Oliver Beckstein notifications@github.com
wrote:

@jdetle https://github.com/jdetle, will this be fixed with PR #833
#833?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#838 (comment)

Have a wonderful day,
John J. Detlefs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants