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_bonds — Functionhydrogen_bonds(sim::Simulation, sel1, sel1 => sel2,...; kargs...)Function to compute the number of hydrogen bonds per frame in a simulation.
Arguments
sim::Simulation: TheSimulationobject.
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]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,
)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)| Row | protein => protein | protein => water | protein => resname POPC |
|---|---|---|---|
| Int64 | Int64 | Int64 | |
| 1 | 32 | 75 | 0 |
| 2 | 28 | 81 | 1 |
| 3 | 27 | 76 | 4 |
| 4 | 27 | 68 | 5 |
| 5 | 26 | 80 | 6 |
and saved to CSV file with CSV.write("hbonds.csv", df).
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.