htmd.projections.metricdihedral module

class htmd.projections.metricdihedral.Dihedral(atom1, atom2, atom3, atom4, dihedraltype=None, check_valid=True)

Bases: object

Class to store atoms defining a dihedral angle.

Example

>>> # Using the helper functions to construct a dihedral object
>>> d1 = Dihedral.phi(mol, 5, 6, segid='P0')
>>> d2 = Dihedral.chi1(mol, 12, segid='P0') # Defining segid
>>> d3 = Dihedral.chi1(mol, 38, chain='X') # Defining chain
>>> # Manual construction
>>> atom1 = {'name': 'N', 'resid': 5, 'segid': 'P'}
>>> atom2 = {'name': 'CA', 'resid': 3, 'segid': 'P', 'chain': 'A', 'insertion': 'B'}
>>> atom3 = {'name': 'C', 'resid': 46, 'segid': 'P', 'chain': 'X'}
>>> atom4 = {'name': 'O', 'resid': 2, 'segid': 'P'}
>>> d = Dihedral(atom1, atom2, atom3, atom4)
static chi1(res, segid=None, chain=None, insertion=None)

Constructs a Dihedral object corresponding to the chi1 angle of a residue

Parameters:
  • mol (Molecule object) – A Molecule object from which to obtain structural information
  • res (int) – The resid of the residue
  • segid (str) – The segment id of the residue
  • chain (str) – The chain letter of the residue
  • insertion (str) – The insertion letter of the residue
Returns:

dihedral – A Dihedral object

Return type:

Dihedral object

static chi2(res, segid=None, chain=None, insertion=None)

Constructs a Dihedral object corresponding to the chi2 angle of a residue

Parameters:
  • mol (Molecule object) – A Molecule object from which to obtain structural information
  • res (int) – The resid of the residue
  • segid (str) – The segment id of the residue
  • chain (str) – The chain letter of the residue
  • insertion (str) – The insertion letter of the residue
Returns:

dihedral – A Dihedral object

Return type:

Dihedral object

static chi3(res, segid=None, chain=None, insertion=None)

Constructs a Dihedral object corresponding to the chi3 angle of a residue

Parameters:
  • mol (Molecule object) – A Molecule object from which to obtain structural information
  • res (int) – The resid of the residue
  • segid (str) – The segment id of the residue
  • chain (str) – The chain letter of the residue
  • insertion (str) – The insertion letter of the residue
Returns:

dihedral – A Dihedral object

Return type:

Dihedral object

static chi4(res, segid=None, chain=None, insertion=None)

Constructs a Dihedral object corresponding to the chi4 angle of a residue

Parameters:
  • mol (Molecule object) – A Molecule object from which to obtain structural information
  • res (int) – The resid of the residue
  • segid (str) – The segment id of the residue
  • chain (str) – The chain letter of the residue
  • insertion (str) – The insertion letter of the residue
Returns:

dihedral – A Dihedral object

Return type:

Dihedral object

static chi5(res, segid=None, chain=None, insertion=None)

Constructs a Dihedral object corresponding to the chi5 angle of a residue

Parameters:
  • mol (Molecule object) – A Molecule object from which to obtain structural information
  • res (int) – The resid of the residue
  • segid (str) – The segment id of the residue
  • chain (str) – The chain letter of the residue
  • insertion (str) – The insertion letter of the residue
Returns:

dihedral – A Dihedral object

Return type:

Dihedral object

static dihedralsToIndexes(dihedrals, sel='all')

Converts dihedral objects to atom indexes of a given Molecule

Parameters:
  • mol (Molecule object) – A Molecule object from which to obtain atom information
  • dihedrals (list) – A single dihedral or a list of Dihedral objects
  • sel (str) – Atom selection string to restrict the application of the selections. See more here
Returns:

indexes – A list containing a list of atoms that correspond to each dihedral.

Return type:

list of lists

Examples

>>> dihs = []
>>> dihs.append(Dihedral.phi(mol, 1, 2))
>>> dihs.append(Dihedral.psi(mol, 2, 3))
>>> indexes = Dihedral.dihedralsToIndexes(mol, dihs)
static omega(res1, res2, segid=None, chain=None, insertion1=None, insertion2=None)

Constructs a Dihedral object corresponding to the omega angle of res1 and res2

Parameters:
  • mol (Molecule object) – A Molecule object from which to obtain structural information
  • res1 (int) – The resid of the first residue containing the CA C atoms
  • res2 (int) – The resid of the second residue containing the N CA atoms
  • segid (str) – The segment id of the residues
  • chain (str) – The chain letter of the residues
  • insertion1 (str) – The insertion letter of residue 1
  • insertion2 (str) – The insertion letter of residue 2
Returns:

dihedral – A Dihedral object

Return type:

Dihedral object

static phi(res1, res2, segid=None, chain=None, insertion1=None, insertion2=None)

Constructs a Dihedral object corresponding to the phi angle of res1 and res2

Parameters:
  • mol (Molecule object) – A Molecule object from which to obtain structural information
  • res1 (int) – The resid of the first residue containing the C atom
  • res2 (int) – The resid of the second residue containing the N CA C atoms
  • segid (str) – The segment id of the residues
  • chain (str) – The chain letter of the residues
  • insertion1 (str) – The insertion letter of residue 1
  • insertion2 (str) – The insertion letter of residue 2
Returns:

dihedral – A Dihedral object

Return type:

Dihedral object

static proteinDihedrals(sel='protein', dih=('psi', 'phi'))

Returns a list of tuples containing the four resid/atom pairs for each dihedral of the protein

Parameters:
  • mol (Molecule object) – A Molecule object from which to obtain structural information
  • sel (str) – Atom selection string to restrict the atoms for which to calculate dihedrals (e.g. only one of many chains). See more here
  • dih (tuple) – A tuple of the dihedral types we want to calculate (phi, psi, omega, chi1, chi2, chi3, chi4, chi5)
Returns:

dihedrals – A list of Dihedral objects

Return type:

list of Dihedral objects

static psi(res1, res2, segid=None, chain=None, insertion1=None, insertion2=None)

Constructs a Dihedral object corresponding to the psi angle of res1 and res2

Parameters:
  • mol (Molecule object) – A Molecule object from which to obtain structural information
  • res1 (int) – The resid of the first residue containing the N CA C atoms
  • res2 (int) – The resid of the second residue containing the N atom
  • segid (str) – The segment id of the residues
  • chain (str) – The chain letter of the residues
  • insertion1 (str) – The insertion letter of residue 1
  • insertion2 (str) – The insertion letter of residue 2
Returns:

dihedral – A Dihedral object

Return type:

Dihedral object

class htmd.projections.metricdihedral.MetricDihedral(dih=None, sincos=True, protsel='protein')

Bases: htmd.projections.projection.Projection

Calculates a set of dihedral angles from trajectories

Parameters:
  • dih (list of Dihedral object) – You can provide your own list of Dihedral objects. See example.
  • sincos (bool, optional) – Set to True to return the dihedral angles as their sine and cosine components. Makes them periodic.
  • protsel (str, optional) – Atom selection string for the protein segment for which to calculate dihedral angles. Resids should be unique within that segment. See more here

Examples

>>> mol = Molecule('3PTB')
>>> mol.filter('not insertion A')
>>> met = MetricDihedral()
>>> met.project(mol)
>>> # More complicated example
>>> dih = []
>>> dih.append(Dihedral.chi1(mol, 45))
>>> dih.append(Dihedral.psi(mol, 29, 30))
>>> met = MetricDihedral(dih, protsel='protein and segid 0')
>>> met.project(mol)
>>> met.getMapping(mol)
static chi1(resname)
static chi2(resname)
static chi3(resname)
static chi4(resname)
static chi5(resname)
copy()

Produces a deep copy of the object

getMapping(mol)

Returns the description of each projected dimension.

Parameters:mol (Molecule object) – A Molecule object which will be used to calculate the descriptions of the projected dimensions.
Returns:map – A DataFrame containing the descriptions of each dimension
Return type:DataFrame object
static omega(res2)
static phi(res2)
project(mol)

Project molecule.

Parameters:mol (Molecule) – A Molecule object to project.
Returns:data – An array containing the projected data.
Return type:np.ndarray
static psi(res2)