Can openbabel detect intramolecular Hydrogen bonds? If not, would it be worth
including in OBMol? I put together the python function below which uses
OBMol functions to find the number of intramolecular hydrogen bonds based on
a user define angle and distance cutoff.
def getHBondList(obmol):
"""Returns list of H bonds (atoms involved, angle and distance) based on
user defined angle and distance cutoff"""
# Make list of H atoms, their donor atoms and possible Acceptor atoms
HD_atom_idx_list=[]; A_atom_idx_list=[]; HD_D_idx_dict={} # HD means H
atom bonded to Donor atom (D), A=acceptor
for atom in OBMolAtomIter(obmol):
idx=atom.GetIdx()
if atom.GetAtomicNum()==1: # hydrogen atoms
for nn_atom in OBAtomAtomIter(atom): # nn_atom=nearest
neighbour atom
if nn_atom.IsHbondDonor():
HD_atom_idx_list.append(idx) # list of H atoms
bonded to D atoms
HD_D_idx_dict[idx]=nn_atom.GetIdx() # dictionary of H
atom idx and its D atom idx
if atom.IsHbondAcceptor():
A_atom_idx_list.append(idx) # list of A atoms
# Check distance and angle between HD and A atoms and make list of H
bonds (atoms involved, angle and distance)
Hbond_list=[]
for HD_atom_idx in HD_atom_idx_list:
HD_atom=obmol.GetAtom(HD_atom_idx)
D_atom_idx=HD_D_idx_dict[HD_atom_idx]
D_atom=obmol.GetAtom(D_atom_idx)
HD_atom_coords=numpy.array([HD_atom.GetX(), HD_atom.GetY(),
HD_atom.GetZ()])
for A_atom_idx in A_atom_idx_list:
if A_atom_idx == D_atom_idx: # don't consider the H
atom's D atom as A atom
pass
else:
A_atom=obmol.GetAtom(A_atom_idx)
A_atom_coords=numpy.array([A_atom.GetX(), A_atom.GetY(),
A_atom.GetZ()])
Hbond_angle=obmol.GetAngle(D_atom, HD_atom, A_atom)
Hbond_dist=numpy.linalg.norm(HD_atom_coords-A_atom_coords)
if Hbond_angle > Hbond_angle_cutoff and Hbond_dist <
Hbond_dist_cutoff:
Hbond_list.append([D_atom_idx, HD_atom_idx, A_atom_idx,
Hbond_dist, Hbond_angle])
return Hbond_list
--
View this message in context:
http://forums.openbabel.org/Intramolecular-Hydrogen-bond-detection-tp4656069.html
Sent from the General discussion mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
OpenBabel-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss