Hydrogen Bond Analysis — pmda.hbond_analysis
¶
This module contains parallel versions of analysis tasks in
MDAnalysis.analysis.hbonds.hbond_analysis
.
Classes¶
-
class
pmda.hbond_analysis.
HydrogenBondAnalysis
(universe, donors_sel=None, hydrogens_sel=None, acceptors_sel=None, d_h_cutoff=1.2, d_a_cutoff=3.0, d_h_a_angle_cutoff=150, update_selections=True)[source]¶ Perform an analysis of hydrogen bonds in a Universe.
Set up atom selections and geometric criteria for finding hydrogen bonds in a Universe.
- Parameters
universe (Universe) – MDAnalysis Universe object
donors_sel (str) – Selection string for the hydrogen bond donor atoms. If the universe topology contains bonding information, leave
donors_sel
as None so that donor-hydrogen pairs can be correctly identified.hydrogens_sel (str) – Selection string for the hydrogen bond hydrogen atoms. Leave as None to guess which hydrogens to use in the analysis using
guess_hydrogens
. Ifhydrogens_sel
is left as None, also leavedonors_sel
as None so that donor-hydrogen pairs can be correctly identified.acceptors_sel (str) – Selection string for the hydrogen bond acceptor atoms. Leave as None to guess which atoms to use in the analysis using
guess_acceptors
d_h_cutoff (float (optional)) – Distance cutoff used for finding donor-hydrogen pairs [1.2]. Only used to find donor-hydrogen pairs if the universe topology does not contain bonding information
d_a_cutoff (float (optional)) – Distance cutoff for hydrogen bonds. This cutoff refers to the D-A distance. [3.0]
d_h_a_angle_cutoff (float (optional)) – D-H-A angle cutoff for hydrogen bonds, in degrees. [150]
update_selections (bool (optional)) – Whether or not to update the acceptor, donor and hydrogen lists at each frame. [True]
Examples
The simplest use case is to allow
HydrogenBondAnalysis
to guess the acceptor and hydrogen atoms, and to identify donor-hydrogen pairs via the bonding information in the topology:import MDAnalysis from pmda.hbond_analysis import HydrogenBondAnalysis as HBA u = MDAnalysis.Universe(psf, trajectory) hbonds = HBA(universe=u) hbonds.run()
It is also possible to specify which hydrogens and acceptors to use in the analysis. For example, to find all hydrogen bonds in water:
import MDAnalysis from pmda.hbond_analysis import HydrogenBondAnalysis as HBA u = MDAnalysis.Universe(psf, trajectory) hbonds = HBA(universe=u, hydrogens_sel='resname TIP3 and name H1 H2', acceptors_sel='resname TIP3 and name OH2') hbonds.run()
Alternatively,
hydrogens_sel
andacceptors_sel
may be generated via theguess_hydrogens
andguess_acceptors
. This selection strings may then be modified prior to callingrun
, or a subset of the universe may be used to guess the atoms. For example, find hydrogens and acceptors belonging to a protein:import MDAnalysis from pmda.hbond_analysis import HydrogenBondAnalysis as HBA u = MDAnalysis.Universe(psf, trajectory) hbonds = HBA(universe=u) hbonds.hydrogens_sel = hbonds.guess_hydrogens("protein") hbonds.acceptors_sel = hbonds.guess_acceptors("protein") hbonds.run()
Slightly more complex selection strings are also possible. For example, to find hydrogen bonds involving a protein and any water molecules within 10 Å of the protein (which may be useful for subsequently finding the lifetime of protein-water hydrogen bonds or finding water-bridging hydrogen bond paths):
import MDAnalysis from pmda.hbond_analysis import HydrogenBondAnalysis as HBA u = MDAnalysis.Universe(psf, trajectory) hbonds = HBA(universe=u) protein_hydrogens_sel = hbonds.guess_hydrogens("protein") protein_acceptors_sel = hbonds.guess_acceptors("protein") water_hydrogens_sel = "resname TIP3 and name H1 H2" water_acceptors_sel = "resname TIP3 and name OH2" hbonds.hydrogens_sel = f"({protein_hydrogens_sel}) or ({water_hydrogens_sel} and around 10 not resname TIP3})" hbonds.acceptors_sel = f"({protein_acceptors_sel}) or ({water_acceptors_sel} and around 10 not resname TIP3})" hbonds.run()
It is highly recommended that a topology with bonding information is used to generate the universe, e.g PSF, TPR, or PRMTOP files. This is the only method by which it can be guaranteed that donor-hydrogen pairs are correctly identified. However, if, for example, a PDB file is used instead, a
donors_sel
may be provided along with ahydrogens_sel
and the donor-hydrogen pairs will be identified via a distance cutoff,d_h_cutoff
:import MDAnalysis from pmda.hbond_analysis import HydrogenBondAnalysis as HBA u = MDAnalysis.Universe(pdb, trajectory) hbonds = HBA( universe=u, donors_sel='resname TIP3 and name OH2', hydrogens_sel='resname TIP3 and name H1 H2', acceptors_sel='resname TIP3 and name OH2', d_h_cutoff=1.2 ) hbonds.run()
-
count_by_ids
()[source]¶ Counts the total number hydrogen bonds formed by unique combinations of donor, hydrogen and acceptor atoms.
- Returns
counts – Each row of the array contains the donor atom id, hydrogen atom id, acceptor atom id and the total number of times the hydrogen bond was observed. The array is sorted by frequency of occurrence.
- Return type
numpy.ndarray
Note
Unique hydrogen bonds are determined through a consideration of the hydrogen atom id and acceptor atom id in a hydrogen bond.
-
count_by_time
()[source]¶ Counts the number of hydrogen bonds per timestep.
- Returns
counts – Contains the total number of hydrogen bonds found at each timestep. Can be used along with
HydrogenBondAnalysis.timesteps
to plot the number of hydrogen bonds over time.- Return type
numpy.ndarray
-
count_by_type
()[source]¶ Counts the total number of each unique type of hydrogen bond.
- Returns
counts – Each row of the array contains the donor resname, donor atom type, acceptor resname, acceptor atom type and the total number of times the hydrogen bond was found.
- Return type
numpy.ndarray
Note
Unique hydrogen bonds are determined through a consideration of the resname and atom type of the donor and acceptor atoms in a hydrogen bond.
-
guess_acceptors
(selection='all', max_charge=- 0.5)[source]¶ Guesses which atoms could be considered acceptors in the analysis.
- Parameters
- Returns
potential_acceptors – String containing the
resname
andname
of all atoms that potentially capable of forming hydrogen bonds.- Return type
Notes
This function makes use of and atomic charges to identify which atoms could be considered acceptor atoms in the hydrogen bond analysis. If an atom has an atomic charge less than
max_charge
then it is considered capable of participating in hydrogen bonds.If
acceptors_sel
is None, this function is called to guess the selection.Alternatively, this function may be used to quickly generate a
str
of potential acceptor atoms involved in hydrogen bonding. Thisstr
may then be modified before being used to set the attributeacceptors_sel
.
-
guess_donors
(selection='all', max_charge=- 0.5)[source]¶ Guesses which atoms could be considered donors in the analysis. Only use if the universe topology does not contain bonding information, otherwise donor-hydrogen pairs may be incorrectly assigned.
- Parameters
- Returns
potential_donors – String containing the
resname
andname
of all atoms that potentially capable of forming hydrogen bonds.- Return type
Notes
This function makes use of and atomic charges to identify which atoms could be considered donor atoms in the hydrogen bond analysis. If an atom has an atomic charge less than
max_charge
, and it is withind_h_cutoff
of a hydrogen atom, then it is considered capable of participating in hydrogen bonds.If
donors_sel
is None, and the universe topology does not have bonding information, this function is called to guess the selection.Alternatively, this function may be used to quickly generate a
str
of potential donor atoms involved in hydrogen bonding. Thisstr
may then be modified before being used to set the attributedonors_sel
.
-
guess_hydrogens
(selection='all', max_mass=1.1, min_charge=0.3)[source]¶ Guesses which hydrogen atoms should be used in the analysis.
- Parameters
- Returns
potential_hydrogens – String containing the
resname
andname
of all hydrogen atoms potentially capable of forming hydrogen bonds.- Return type
Notes
This function makes use of atomic masses and atomic charges to identify which atoms are hydrogen atoms that are capable of participating in hydrogen bonding. If an atom has a mass less than
max_mass
and an atomic charge greater thanmin_charge
then it is considered capable of participating in hydrogen bonds.If
hydrogens_sel
is None, this function is called to guess the selection.Alternatively, this function may be used to quickly generate a
str
of potential hydrogen atoms involved in hydrogen bonding. This str may then be modified before being used to set the attributehydrogens_sel
.