moleculekit.projections.metricdihedral module#
- class moleculekit.projections.metricdihedral.Dihedral(atom1, atom2, atom3, atom4, dihedraltype=None, check_valid=True)#
Bases:
objectClass to store atoms defining a dihedral angle.
- Parameters:
atom1 (
dict) – Dictionary describing the first atom of the dihedral with keys such as “name”, “resid”, “segid”, “insertion” and “chain”.atom2 (
dict) – Dictionary describing the second atom of the dihedral.atom3 (
dict) – Dictionary describing the third atom of the dihedral.atom4 (
dict) – Dictionary describing the fourth atom of the dihedral.dihedraltype (
str|None) – A label describing the type of the dihedral angle (e.g. “phi”, “psi”, “chi1”).check_valid (
bool) – If True, validate the atom dictionary keys and fill in missing keys with default values.
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(mol, res, segid=None, chain=None, insertion=None, ff='amber')#
Constructs a Dihedral object corresponding to the chi1 angle of a residue
- Parameters:
mol (
Molecule) – A Molecule object from which to obtain structural informationres (
int) – The resid of the residueinsertion (
str|None) – The insertion letter of the residueff (
str) – The force field whose atom-naming convention to use when selecting the dihedral atoms. Either “amber” or “charmm”.
- Returns:
dihedral – A Dihedral object
- Return type:
Dihedralobject
- static chi2(mol, res, segid=None, chain=None, insertion=None, ff='amber')#
Constructs a Dihedral object corresponding to the chi2 angle of a residue
- Parameters:
mol (
Molecule) – A Molecule object from which to obtain structural informationres (
int) – The resid of the residueinsertion (
str|None) – The insertion letter of the residueff (
str) – The force field whose atom-naming convention to use when selecting the dihedral atoms. Either “amber” or “charmm”; the two differ for the chi2 atoms of some residues.
- Returns:
dihedral – A Dihedral object
- Return type:
Dihedralobject
- static chi3(mol, res, segid=None, chain=None, insertion=None, ff='amber')#
Constructs a Dihedral object corresponding to the chi3 angle of a residue
- Parameters:
mol (
Molecule) – A Molecule object from which to obtain structural informationres (
int) – The resid of the residueinsertion (
str|None) – The insertion letter of the residueff (
str) – The force field whose atom-naming convention to use when selecting the dihedral atoms. Either “amber” or “charmm”.
- Returns:
dihedral – A Dihedral object
- Return type:
Dihedralobject
- static chi4(mol, res, segid=None, chain=None, insertion=None, ff='amber')#
Constructs a Dihedral object corresponding to the chi4 angle of a residue
- Parameters:
mol (
Molecule) – A Molecule object from which to obtain structural informationres (
int) – The resid of the residueinsertion (
str|None) – The insertion letter of the residueff (
str) – The force field whose atom-naming convention to use when selecting the dihedral atoms. Either “amber” or “charmm”.
- Returns:
dihedral – A Dihedral object
- Return type:
Dihedralobject
- static chi5(mol, res, segid=None, chain=None, insertion=None, ff='amber')#
Constructs a Dihedral object corresponding to the chi5 angle of a residue
- Parameters:
mol (
Molecule) – A Molecule object from which to obtain structural informationres (
int) – The resid of the residueinsertion (
str|None) – The insertion letter of the residueff (
str) – The force field whose atom-naming convention to use when selecting the dihedral atoms. Either “amber” or “charmm”.
- Returns:
dihedral – A Dihedral object
- Return type:
Dihedralobject
- static dihedralsToIndexes(mol, dihedrals, sel='all')#
Converts dihedral objects to atom indexes of a given Molecule
- Parameters:
- Returns:
indexes – A list containing a list of atoms that correspond to each dihedral.
- Return type:
listoflists
Examples
>>> dihs = [] >>> dihs.append(Dihedral.phi(mol, 1, 2)) >>> dihs.append(Dihedral.psi(mol, 2, 3)) >>> indexes = Dihedral.dihedralsToIndexes(mol, dihs)
- static omega(mol, res1, res2, segid=None, chain=None, insertion1=None, insertion2=None, ff='amber')#
Constructs a Dihedral object corresponding to the omega angle of res1 and res2
- Parameters:
mol (
Molecule) – A Molecule object from which to obtain structural informationres1 (
int) – The resid of the first residue containing the CA C atomsres2 (
int) – The resid of the second residue containing the N CA atomsff (
str) – The force field whose atom-naming convention to use when selecting the dihedral atoms. Either “amber” or “charmm”.
- Returns:
dihedral – A Dihedral object
- Return type:
Dihedralobject
- static phi(mol, res1, res2, segid=None, chain=None, insertion1=None, insertion2=None, ff='amber')#
Constructs a Dihedral object corresponding to the phi angle of res1 and res2
- Parameters:
mol (
Molecule) – A Molecule object from which to obtain structural informationres1 (
int) – The resid of the first residue containing the C atomres2 (
int) – The resid of the second residue containing the N CA C atomsff (
str) – The force field whose atom-naming convention to use when selecting the dihedral atoms. Either “amber” or “charmm”.
- Returns:
dihedral – A Dihedral object
- Return type:
Dihedralobject
- static proteinDihedrals(mol, sel='protein or resname ACE NME', dih=('psi', 'phi'), ff='amber')#
Returns a list of tuples containing the four resid/atom pairs for each dihedral of the protein
- Parameters:
mol (
Molecule) – A Molecule object from which to obtain structural informationsel (
str|ndarray) – Atom selection to restrict the atoms for which to calculate dihedrals (a selection string, boolean mask, or integer index array; e.g. only one of many chains). See more heredih (
tuple) – A tuple of the dihedral types we want to calculate (phi, psi, omega, chi1, chi2, chi3, chi4, chi5)ff (
str) – The force field whose atom-naming convention to use when selecting the dihedral atoms. Either “amber” or “charmm” (this only affects some chi2 sidechain atom names).
- Returns:
dihedrals – A list of Dihedral objects
- Return type:
- static psi(mol, res1, res2, segid=None, chain=None, insertion1=None, insertion2=None, ff='amber')#
Constructs a Dihedral object corresponding to the psi angle of res1 and res2
- Parameters:
mol (
Molecule) – A Molecule object from which to obtain structural informationres1 (
int) – The resid of the first residue containing the N CA C atomsres2 (
int) – The resid of the second residue containing the N atomff (
str) – The force field whose atom-naming convention to use when selecting the dihedral atoms. Either “amber” or “charmm”.
- Returns:
dihedral – A Dihedral object
- Return type:
Dihedralobject
- class moleculekit.projections.metricdihedral.MetricDihedral(dih=None, sincos=True, protsel='protein or resname ACE NME')#
Bases:
ProjectionCalculates a set of dihedral angles from trajectories
- Parameters:
dih (
list|None) – You can provide your own list of Dihedral objects. See example.sincos (
bool) – Set to True to return the dihedral angles as their sine and cosine components. Makes them periodic.protsel (
str|ndarray) – Atom selection for the protein segment for which to calculate dihedral angles (a selection string, boolean mask, or integer index array). 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)