Hydrogen bonds

Computes the number of hydrogen bonds of a set of atoms, or between two sets of atoms, for each frame in a simulation.

PDBTools.hydrogen_bondsFunction
hydrogen_bonds(sim::Simulation, sel1, sel1 => sel2,...; kargs...)

Function to compute the number of hydrogen bonds per frame in a simulation.

Arguments

  • sim::Simulation: The Simulation object.

and, optionally,

  • a list of selections, or pairs of selections, given as selection strings. Examples: "protein", "protein" => "water", etc.

If no selection is provided, the hydrogen bonds among all atoms are computed. If two selections of a pair are different, their atoms must not overlap (an error will be thrown).

Returns

  • An ordered dictionary in which the key specifies the selections and the values are vectors with the number of hydrogen bonds in each frame.

Optional keyword arguments

  • parallel::Bool=true: Defines if the calculation is run in parallel. Requires starting Julia with multi-threading.
  • donnor_acceptor_distance::Real=3.5f0: Maximum distance between donnor and acceptor to consider a hydrogen bond.
  • angle_cutoff::Real=30: Maximum angle (in degrees) between donnor-hydrogen-acceptor to consider a hydrogen bond.
  • electronegative_elements=("N", "O", "F", "S"): Elements considered electronegative for hydrogen bonding.
  • d_covalent_bond::Real=1.2f0: Maximum distance between donnor and hydrogen to consider a covalent bond.

Example

julia> using MolSimToolkit, MolSimToolkit.Testing

julia> sim = Simulation(Testing.namd_pdb, Testing.namd_traj);

julia> hbs = hydrogen_bonds(sim, "protein")
OrderedCollections.OrderedDict{String, Vector{Int64}} with 1 entry:
  "protein => protein" => [32, 28, 27, 27, 26]

julia> hbs = hydrogen_bonds(sim, "protein" => "water")
OrderedCollections.OrderedDict{String, Vector{Int64}} with 1 entry:
  "protein => water" => [75, 81, 76, 68, 80]

julia> hbs = hydrogen_bonds(sim, "protein", "protein" => "water", "water" => "resname POPC")
OrderedCollections.OrderedDict{String, Vector{Int64}} with 3 entries:
  "protein => protein"    => [32, 28, 27, 27, 26]
  "protein => water"      => [75, 81, 76, 68, 80]
  "water => resname POPC" => [413, 403, 406, 392, 376]
Note

This function does not use topology information. It identified polar hydrogens based on distance criteria only, where d_covalent_bond is the criterium for identifying covalent bonds between donnor and hydrogen atoms.

source

Example

using MolSimToolkit, PDBTools
using MolSimToolkit.Testing # to load test files
using Plots
# Build Simulation object
sim = Simulation(Testing.namd_pdb, Testing.namd_traj)
# Compute h-bonds of the protein with itself
hbs_prot = hydrogen_bonds(sim, "protein")
# Compute h-bonds between protein and water
hbs_prot_water = hydrogen_bonds(sim, "protein" => "water")
# Plot
plot(MolSimStyle,
    [hbs_prot["protein => protein"] hbs_prot_water["protein => water"]];
    xlabel="frame",
    ylabel="number of hydrogen bonds",
    label=["protein-protein" "protein-water"],
    legend=:outertopright,
)
Example block output

Alternativelly, multiple selections, or pairs of selections can be provided, for faster computations,

hbs = hydrogen_bonds(sim,
        "protein",
        "protein" => "water",
        "protein" => "resname POPC",
)
OrderedCollections.OrderedDict{String, Vector{Int64}} with 3 entries:
  "protein => protein"      => [32, 28, 27, 27, 26]
  "protein => water"        => [75, 81, 76, 68, 80]
  "protein => resname POPC" => [0, 1, 4, 5, 6]

The result can be converted directly to a DataFrame

using DataFrames, CSV
df = DataFrame(hbs)
5×3 DataFrame
Rowprotein => proteinprotein => waterprotein => resname POPC
Int64Int64Int64
132750
228811
327764
427685
526806

and saved to CSV file with CSV.write("hbonds.csv", df).

Note

The order of the pairs, e. g. "protein" => "water" or "water" => "protein", does not affect the result, as electronegative atoms of both groups will be considered as possible hydrogen bond donnors and/or acceptors.

When a single selection is provided, e. g. "protein", the hydrogen bonds within that selection are computed, with no repetitions.