Hydrogen Bond Statistics

This module enables Hydrogen Bond geometries assessment based on CSD statistics. The model encapsulates information regarding the number of hydrogen bond interactions present in the crystal structures and based on statistical information from CSD. It provides information about hydrogen bond geometries, including assessment of whether the bond distance and angles are usual or not unusual. To run it we will import the appropriate module:

>>> from ccdc import io
>>> from ccdc.interaction import HydrogenBondStatisticsSearch

Basic operation

First, let us create an ccdc.interaction.HydrogenBondStatisticsSearch instance:

>>> hbs = HydrogenBondStatisticsSearch()

The first thing to do is to set a target crystal; here we have chosen ADRENL which is the refcode of the skeleton molecule in Adrenaline, a hormone and medication which is involved in regulating visceral functions.

>>> csd = io.EntryReader('CSD')
>>> myentry = csd.entry('ADRENL')

Plotting HBS distance and angle data as Histograms

To plot histograms, you first need to import the third party libraries matplotlib and numpy

>>> import matplotlib.pyplot as plt
>>> import numpy as np

The data used to plot the histogram data is already binned for users. The axis properties for the histograms is also precalculated in order to match as closely as possible to what is plotted in Mercury. For example, the x-axis properties for the distance histogram of the fourth bond in ADRENL can be obtained by running:

>>> hb = stats[3]
>>> hb.distance_histogram_x_axis_properties
(2.2999999999999994, 3.3000000000000003, 44.0)

The first two values of the tuple returned by this function ccdc.interaction.HydrogenBondStatisticsSearch.HydrogenBondStatistics.distance_histogram_x_axis_properties() are the minimum and maximum values of the x-axis, and the third number is the number of bins the data will be binned into.

The next step is to generate the various binedges for matplotlib using numpy. We do this by running this command:

>>> distance_axis_properties = hb.distance_histogram_x_axis_properties
>>> step = (distance_axis_properties[1] - distance_axis_properties[0])/distance_axis_properties[2]
>>> binedges = np.arange(distance_axis_properties[0], distance_axis_properties[1], step)

Sometimes the array of values generated by numpy for the binedges fall slightly short because the maximum value is not added. When such a case happens, we have to manually append the maximum value to the binedges array using:

>>> binedges = np.append(binedges, distance_axis_properties[1])

We can then plot the distance histogram for the fourth bond by running:

>>> plt.hist(binedges[:-1], binedges, weights=hb.distance_histogram_frequencies)

This gives us the raw distance histogram without the radial and cone correction applied. Radial and Cone corrections are applied as weights to the frequency counts of the histograms. To apply these corrections with the weights we first have to multiply the weights to the frequency counts elementwise to get the effective densities:

>>> distance_frequencies_radial_corrected = np.multiply(hb.distance_histogram_weights, hb.distance_histogram_frequencies)

We can then plot the corrected distance histogram for the fourth bond by running:

>>> plt.hist(binedges[:-1], binedges, weights=distance_frequencies_radial_corrected)

Alternatively we can use the precomputed effective densities to plot the radially corrected distances by running:

>>> plt.hist(binedges[:-1], binedges, weights=hb.distance_histogram_effective_densities)