pytraj.hbond

class pytraj.hbond_.DatasetHBond(dslist=None)

Bases: pytraj.base_holder.BaseDataHolder

Hold data for hbond analysis.

Attributes

data return pytraj.DatasetList
donor_acceptor return a list of donor and acceptor
values return raw numpy array

Methods

get_amber_mask() return a list of distance mask and angle mask
to_dict() return OrderedDict
total_solute_hbonds() return total solute hbonds
data

return pytraj.DatasetList

donor_acceptor

return a list of donor and acceptor

get_amber_mask()

return a list of distance mask and angle mask

to_dict()

return OrderedDict

total_solute_hbonds()

return total solute hbonds

See also: DatasetHBond.data.keys()

values

return raw numpy array

pytraj.hbond_.hbond(traj, mask='', solvent_donor=None, solvent_acceptor=None, distance=3.0, angle=135.0, image=False, series=True, options='', dtype='hbond', frame_indices=None, top=None)

(combined with cpptraj doc) Searching for Hbond donors/acceptors in region specified by mask. Hydrogen bond is defined as A-HD, where A is acceptor heavy atom, H is hydrogen, D is donor heavy atom. Hydrogen bond is formed when A to D distance < distance cutoff and A-H-D angle > angle cutoff; if angle < 0 it is ignored.

Parameters:

traj : Trajectory-like

mask : {str, 1D array-like}

Atom mask for searching hbond. If this mask is specify, cpptraj will automatically search for donors and acceptors.

solvent_donor : {None, str}, default None

solvent_acceptor: {None, str}, deafult None

if solvent_acceptor and solvent_donor are None, cpptraj only search hbond for if solvent_donor and solvent_acceptor are NOT None, cpptraj will search for hbond between solute and solvent too.

distance : float, default 3.0 (angstrom)

hbond distance cut off

angle : float, 135.0 degree

hbond angle cut off

dtype : return output’s type, default ‘hbond’

image : bool, default False

series : bool, default True

  • output time series (array of 1 and 0) for hbond or not (highly recommend to use this default value)
  • if False, you must specify dtype=’dataset’

options : str

additional cpptraj options. For example you can explicitly specify donormask and acceptormask.

  • If donormask is specified but not acceptormask, acceptors will be automatically searched for in mask.
  • If acceptormask is specified but not donormask, donors will be

automatically search for in mask.

  • If both donormask and acceptormask are specified no automatic searching will occur.
Returns:

out : DatasetHBond if series is True else return ‘DatasetList’

See also

to_amber_mask

Notes

  • pytraj use ‘series’ as default. In cpptraj, you need to explicitly specify ‘series’.
  • if ‘series’ is False, the ‘dtype’ argument will be ignored.

Examples

>>> import pytraj as pt
>>> traj = pt.load_sample_data('tz2')
>>> # search hbond without including solvent
>>> data = pt.search_hbonds(traj, ':5,8')
>>> data
<pytraj.hbonds.DatasetHBond
donor_acceptor pairs : 2>
>>> data.donor_acceptor
['LYS8_O-GLU5_N-H', 'GLU5_O-LYS8_N-H']
>>> # get raw data, ndarray with shape=(n_hbonds+1, n_frames)
>>> # first array shows the total solute hbonds and other arrays shows
>>> # if hbond exists (1) or non-exists (0) for each frame
>>> data.values
array([[2, 2, 0, ..., 1, 1, 1],
       [1, 1, 0, ..., 1, 1, 1],
       [1, 1, 0, ..., 0, 0, 0]], dtype=int32)
>>> # search hbond including solvent
>>> hbonds = pt.search_hbonds(traj, ':5,8', solvent_donor=':WAT@O', solvent_acceptor=':WAT')
>>> hbonds
<pytraj.hbonds.DatasetHBond
donor_acceptor pairs : 8>
>>> hbonds.donor_acceptor
['LYS8_O-GLU5_N-H', 'GLU5_O-LYS8_N-H', 'LYS8_HZ1-V', 'LYS8_HZ2-V', 'GLU5_OE2-V', 'GLU5_O-V', 'GLU5_OE1-V', 'LYS8_HZ3-V']
>>> # 'GLU5_O-V' mean non-specific hbond between GLU5_O and solvent (:WAT in this case)