mdtraj.wernet_nilsson(traj, exclude_water=True, periodic=True, sidechain_only=False)

Identify hydrogen bonds based on cutoffs for the Donor-H…Acceptor distance and angle according to the criterion outlined in [1]. As opposed to Baker-Hubbard, this is a “cone” criterion where the distance cutoff depends on the angle.

The criterion employed is \(r_\text{DA} < 3.3 A - 0.00044*\delta_{HDA}*\delta_{HDA}\), where \(r_\text{DA}\) is the distance between donor and acceptor heavy atoms, and \(\delta_{HDA}\) is the angle made by the hydrogen atom, donor, and acceptor atoms, measured in degrees (zero in the case of a perfectly straight bond: D-H … A).

When donor the donor is ‘O’ and the acceptor is ‘O’, this corresponds to the definition established in [R8080]. The donors considered by this method are NH and OH, and the acceptors considered are O and N. In the paper the only donor considered is OH.


traj : md.Trajectory

An mdtraj trajectory. It must contain topology information.

exclude_water : bool, default=True

Exclude solvent molecules from consideration.

periodic : bool, default=True

Set to True to calculate displacements and angles across periodic box boundaries.

sidechain_only : bool, default=False

Set to True to only consider sidechain-sidechain interactions.


hbonds : list, len=n_frames

A list containing the atom indices involved in each of the identified hydrogen bonds at each frame. Each element in the list is an array where each row contains three integer indices, (d_i, h_i, a_i), such that d_i is the index of the donor atom, h_i the index of the hydrogen atom, and a_i the index of the acceptor atom involved in a hydrogen bond which occurs in that frame.


Each hydrogen bond is distinguished for the purpose of this function by the indices of the donor, hydrogen, and acceptor atoms. This means that, for example, when an ARG sidechain makes a hydrogen bond with its NH2 group, you might see what appear like double counting of the h-bonds, since the hydrogen bond formed via the H_1 and H_2 are counted separately, despite their “chemical indistinguishably”


[R8080](1, 2) Wernet, Ph., L.G.M. Pettersson, and A. Nilsson, et al. “The Structure of the First Coordination Shell in Liquid Water.” (2004) Science 304, 995-999.


>>> md.wernet_nilsson(t)
array([[  0,  10,   8],
       [  0,  11,   7],
       [ 69,  73,  54],
       [ 76,  82,  65],
       [119, 131,  89],
       [140, 148, 265],
       [166, 177, 122],
       [181, 188, 231]])
>>> label = lambda hbond : '%s -- %s' % (t.topology.atom(hbond[0]), t.topology.atom(hbond[2]))
>>> for hbond in hbonds:
>>>     print label(hbond)
GLU1-N -- GLU1-OE2
GLU1-N -- GLU1-OE1
GLY6-N -- SER4-O
CYS7-N -- GLY5-O
TYR11-N -- VAL8-O
MET12-N -- LYS20-O