Closed Gojja closed 2 years ago
This looks like a question for MDAnalysis and not PMDA, given that you never import pmda in your example.
The development version of the User Guide now has a section HBond analysis: https://userguide.mdanalysis.org/2.0.0-dev0/examples/analysis/hydrogen_bonds/hbonds.html — please check there.
Have you asked on the mailing list or discord? See https://www.mdanalysis.org/#participating for how to get in touch.
Note that you might be using an older version of MDAnalysis compared to the docs.
Expected behaviour
generating a table from hbonds.table() / hbonds.generate_table() command.
Actual behaviour
Attribute error: AttributeError: 'HydrogenBondAnalysis' object has no attribute 'table' AttributeError: 'HydrogenBondAnalysis' object has no attribute 'generate_table'
Code to reproduce the behaviour
import MDAnalysis from MDAnalysis.analysis.hydrogenbonds.hbond_analysis import HydrogenBondAnalysis as HBA
u = MDAnalysis.Universe('file.tpr', 'file.xtc')
Calculate h bonds between protein and water within 3 of protein
hbonds = HBA(universe=u)
protein_hydrogens_sel = hbonds.guess_hydrogens("protein") protein_acceptors_sel = hbonds.guess_acceptors("protein")
water_hydrogens_sel = "resname TIP3 and name H1 H2" water_acceptors_sel = "resname TIP3 and name OH2"
hbonds.hydrogens_sel = f"({protein_hydrogens_sel}) or ({water_hydrogens_sel} and around 3 not resname TIP3)" hbonds.acceptors_sel = f"({protein_acceptors_sel}) or ({water_acceptors_sel} and around 3 not resname TIP3)" hbonds.run( start=None, stop=None, step=None, verbose=True )
print (hbonds.generate_table())
P.S.: I have tried following @orbeckst advice from a previous post but unable to get the desired results. using:
createlist = [i for i in range (25)] for i in createlist: print(hbonds.results.hbonds[i]) #gives you 0th-25th frame information in a file name demo.txt Sourcefile = open('demo.txt','w') print(hbonds.results, file = Sourcefile)
I am able to print the output in a file 'demo.txt', which looks like this: demo.txt: {'hbonds': array([[ 0. , 220. , 221. , 136. , 2.94151315, 163.86075402], [ 0. , 612. , 613. , 833. , 2.98953254, 168.22524712], [ 0. , 730. , 731. , 695. , 2.68823347, 164.12368554], ..., [ 24. , 730. , 731. , 694. , 2.87765749, 165.38558508], [ 24. , 750. , 753. , 706. , 2.67695685, 176.39070686], [ 24. , 766. , 767. , 733. , 2.80496225, 171.68436711]])} ~ I could also edit the demo.txt but I don't know how to get the full output, i.e., without "..." in line-6. This output looks similar to what is available on the MDAnalysis tutorials.