Skip to content

Instantly share code, notes, and snippets.

@orbeckst
Created May 21, 2017 07:03
Show Gist options
  • Save orbeckst/736fb4d2864d25a5a7cc6e50cc36aa9c to your computer and use it in GitHub Desktop.
Save orbeckst/736fb4d2864d25a5a7cc6e50cc36aa9c to your computer and use it in GitHub Desktop.
Updated script reproducehbondissue.py to work with MDAnalysis 0.16.1-dev ; part of https://github.com/MDAnalysis/mdanalysis/issues/1268 .
#! /usr/bin/env python2.7
# 0.16.1-dev
import MDAnalysis as mda
import MDAnalysis.analysis.hbonds
def select_monomers_str(u, nmer=4):
protein = u.select_atoms("protein")
return ["protein and bynum {0}:{1}".format(i1, i2)
for i1 in range(1, protein.n_atoms, protein.n_atoms/nmer)
for i2 in [i1+protein.n_atoms/nmer - 1]]
if __name__ == "__main__":
# input
grofile = "t39000.gro"
# Create the md universe
u = mda.Universe(grofile)
# Analyze monomers separately
# Need to use selection string for each monomer:
monomer_selections = select_monomers_str(u)
hbonddist = 3.0 # distance in Angstrom between donor H and acceptor atom.
hbondangle = 180-35 # deg (different angle def in the mda hbond tool than for gmx)
# just look at one monomer for right now;
# To loop: for monomer_selection in monomer_selections:
#imonomer = 0
for monomer_selection in monomer_selections:
sel1 = "{0} and resid 197 and name ND2".format(monomer_selection)
hbondana = MDAnalysis.analysis.\
hbonds.HydrogenBondAnalysis(u, \
selection1=sel1,
selection2='resname SOL and name OW',
selection1_type='donor',
distance=hbonddist, angle=hbondangle,
filter_first=True, debug=True)
print 'running hbond ana for monomer {}'.format(monomer_selection)
hbondana.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment