Created
March 29, 2017 03:07
-
-
Save orbeckst/eaad2d7cf063901d9b48d5e357ac3e61 to your computer and use it in GitHub Desktop.
Part of issue report https://github.com/MDAnalysis/mdanalysis/issues/1268 by @vivecalindahl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python2.7 | |
import MDAnalysis as mda | |
import MDAnalysis.analysis.hbonds | |
def select_monomers(u, nmer=4): | |
protein = u.select_atoms("protein") | |
# note: bynum is 1-based so range starts at 1 | |
monomers = [u.select_atoms("protein and bynum " + str(i1) + ":" + str(i2)) for i1 in range(1, protein.n_atoms, protein.n_atoms/nmer) for i2 in [i1+protein.n_atoms/nmer - 1]] | |
# List with the monomer atom groups | |
return monomers | |
def segment_monomers(u): | |
monomers = select_monomers(u) | |
segids = ["monomer" + str(i+1) for i in range(len(monomers))] | |
for monomer, segid in zip(monomers, segids): | |
monomer.segids = segid | |
return segids | |
if __name__ == "__main__": | |
# input | |
grofile="t39000.gro" | |
# Create the md universe | |
u = mda.Universe(grofile) | |
# Analyze monomers separately | |
segids = segment_monomers(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) | |
oxygens_t_seg=[] | |
# for segid in segids: | |
segid=segids[0] | |
hbondana = MDAnalysis.analysis.hbonds.HydrogenBondAnalysis(u, | |
selection1= ' and '.join(['segid ' + segid, 'resid 197', 'name ND2']), | |
selection2='resname SOL and name OW', | |
selection1_type='donor', | |
distance=hbonddist, angle=hbondangle) | |
print 'running hbond ana for segid ' + segid | |
hbondana.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment