moleculekit.projections.metricdihedral module#
- class moleculekit.projections.metricdihedral.Dihedral(atom1: dict, atom2: dict, atom3: dict, atom4: dict, dihedraltype: str | None = None, check_valid: bool = 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) – 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: Molecule, res: int, segid: str | None = None, chain: str | None = None, insertion: str | None = None, ff: str = 'amber')#
Constructs a Dihedral object corresponding to the chi1 angle of a residue
- Parameters:
mol (
Moleculeobject) – A Molecule object from which to obtain structural informationres (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
ff (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: Molecule, res: int, segid: str | None = None, chain: str | None = None, insertion: str | None = None, ff: str = 'amber')#
Constructs a Dihedral object corresponding to the chi2 angle of a residue
- Parameters:
mol (
Moleculeobject) – A Molecule object from which to obtain structural informationres (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
ff (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: Molecule, res: int, segid: str | None = None, chain: str | None = None, insertion: str | None = None, ff: str = 'amber')#
Constructs a Dihedral object corresponding to the chi3 angle of a residue
- Parameters:
mol (
Moleculeobject) – A Molecule object from which to obtain structural informationres (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
ff (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: Molecule, res: int, segid: str | None = None, chain: str | None = None, insertion: str | None = None, ff: str = 'amber')#
Constructs a Dihedral object corresponding to the chi4 angle of a residue
- Parameters:
mol (
Moleculeobject) – A Molecule object from which to obtain structural informationres (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
ff (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: Molecule, res: int, segid: str | None = None, chain: str | None = None, insertion: str | None = None, ff: str = 'amber')#
Constructs a Dihedral object corresponding to the chi5 angle of a residue
- Parameters:
mol (
Moleculeobject) – A Molecule object from which to obtain structural informationres (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
ff (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: Molecule, dihedrals: list, sel: str | ndarray = 'all')#
Converts dihedral objects to atom indexes of a given Molecule
- Parameters:
mol (
Moleculeobject) – A Molecule object from which to obtain atom informationdihedrals (list) – A single dihedral or a list of Dihedral objects
sel (str or np.ndarray) – Atom selection to restrict the application of the selections (a selection string, boolean mask, or integer index array). 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(mol: Molecule, res1: int, res2: int, segid: str | None = None, chain: str | None = None, insertion1: str | None = None, insertion2: str | None = None, ff: str = 'amber')#
Constructs a Dihedral object corresponding to the omega angle of res1 and res2
- Parameters:
mol (
Moleculeobject) – A Molecule object from which to obtain structural informationres1 (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
ff (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: Molecule, res1: int, res2: int, segid: str | None = None, chain: str | None = None, insertion1: str | None = None, insertion2: str | None = None, ff: str = 'amber')#
Constructs a Dihedral object corresponding to the phi angle of res1 and res2
- Parameters:
mol (
Moleculeobject) – A Molecule object from which to obtain structural informationres1 (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
ff (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: Molecule, sel: str | ndarray = 'protein or resname ACE NME', dih: tuple = ('psi', 'phi'), ff: str = 'amber')#
Returns a list of tuples containing the four resid/atom pairs for each dihedral of the protein
- Parameters:
mol (
Moleculeobject) – A Molecule object from which to obtain structural informationsel (str or np.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 here
dih (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:
list of
Dihedralobjects
- static psi(mol: Molecule, res1: int, res2: int, segid: str | None = None, chain: str | None = None, insertion1: str | None = None, insertion2: str | None = None, ff: str = 'amber')#
Constructs a Dihedral object corresponding to the psi angle of res1 and res2
- Parameters:
mol (
Moleculeobject) – A Molecule object from which to obtain structural informationres1 (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
ff (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: list | None = None, sincos: bool = True, protsel: str | ndarray = 'protein or resname ACE NME')#
Bases:
ProjectionCalculates a set of dihedral angles from trajectories
- Parameters:
dih (list of
Dihedralobject) – 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 or np.ndarray, optional) – 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)
- getMapping(mol: Molecule)#
Returns the description of each projected dimension.
- Parameters:
mol (
Moleculeobject) – 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:
DataFrameobject