You are reading the documentation for version 3.1 of ProMod3. You may also want to read the documentation for: 3.0 1.3 2.0 2.1

Sampling Dihedral Angles

The torsion sampler is the basic object used to sample the backbone torsion angles phi and psi. It can be used to calculate the probability distributions of backbone torsion angles from structures and save them, as well as loading distributions and drawing from them. It uses distributions specific for triplets of residues, so that when drawing a phi/psi pair for a certain residue, the distribution from which the pair is drawn also depends on the identity of the residues before and after the residue in question. The distributions of the sampler are internally stored in a vector, so that most methods which need to access a specific distribution can either take 3 residue names or an index as input.

As a showcase example, we randomly sample from a given torsion sample and store the resulting samples as a scatter plot:

from promod3 import loop
from ost import conop
# this requires matplotlib and numpy
import matplotlib
# change next line, if you wish to use a GUI-based plot-output
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import numpy as np

# load a default sampler
t_sampler = loop.LoadTorsionSampler()

# dihedral angles will be stored in here
phi = list()
psi = list()

# draw from a random distribution
for i in range(1000):
    dihedral_pair = t_sampler.Draw(conop.ALA, 
                                   conop.PRO, 
                                   conop.ALA)
    phi.append(dihedral_pair[0])
    psi.append(dihedral_pair[1])

# and plot it
plt.xlim(-np.pi, np.pi)
plt.ylim(-np.pi, np.pi)
plt.plot(phi, psi, '.')
plt.xlabel("phi", fontsize='large')
plt.ylabel("psi", fontsize='large')
plt.title("ALA-PRO-ALA")

# store plot as png file
plt.savefig("torsion_plot.png")

Defining Amino Acid triplets

Since the torsion sampler considers triplets of amino acids, we need to define them. This is done with the so called torsion group definitions. Three strings represent the according positions of the consecutive amino acids. They are combined by “-”. It is either possible to use the keyword “all”, or write out all allowed amino acids by their three letter code and separate them by ”,”. An example would be: “all- VAL,ILE-PRO”. There are cases where a tripeptide can match several group definitions. The list of group definitions is iterated for every combination of three consecutive amino acids and the first hit is decisive.

The Torsion Sampler Class

class promod3.loop.TorsionSampler(group_definitions, bins_per_dimension, seed)

Basic object used to sample the backbone torsion angles phi and psi.

Parameters:
  • group_definitions (list of str) – List of group definitions defining amino acid triplets
  • bins_per_dimension – Number of bins to represent the 360 degrees of each torsion angle
  • seed (int) – Seed for random number generator
Raises:

RuntimeException when there is a possible combination of the 20 standard amino acids not matching any of the group definitions.

ExtractStatistics(view)

Extracts backbone torsion angles from the structure and adds them to the appropriate histograms in the sampler.

Parameters:view (ost.mol.EntityView) – structure from which parameters will be extracted
UpdateDistributions()

Recalculates the probability distributions from the histograms.

static Load(filename, seed)
static LoadPortable(filename, seed)

Loads raw binary file generated with Save() (optimized for fast reading) / portable file generated with SavePortable() (slower but less machine-dependent).

Parameters:
  • filename (str) – Path to the file from which to load the sampler.
  • seed (int) – Seed for random number generator (not saved in file).
Returns:

A torsion sampler

Return type:

TorsionSampler

Raises:

RuntimeError if file cannot be opened or if file cannot be parsed (see here for details).

Save(filename)
SavePortable(filename)

Saves a raw / portable binary representation. Use portable files for distribution and convert locally to raw files. See here for details.

Parameters:filename (str) – Path to the file where the sampler will be saved
Raises:RuntimeError if file cannot be opened.
GetHistogramIndex(before, central, after)
Parameters:
Returns:

The index of the histogram corresponding to the triplet of residues specified.

GetHistogramIndices(sequence)
Parameters:sequence (str) – Sequence of length n from which histogram indices should created.
Returns:List of length n-2 containing histogram indices of all consecutive amino acid triplets in sequence
Raises:RuntimeError if sequence contains non standard amino acid
Draw(before, central, after)

Draws a pair of dihedral angles for the central residue from the distribution specific for such a triplet of residues.

Parameters:
Returns:

A pair of phi/psi angles

Draw(index)

Draws a pair of dihedral angles from the distribution specified by the index.

Parameters:index (int) – The index of the distribution from which a phi/psi pair will be drawn.
Returns:A pair of phi/psi angles
DrawPhiGivenPsi(before, central, after, psi)

Draws a phi angle for the central residue from the conditional distribution P( phi | psi ) specific for such a triplet of residues.

Parameters:
Returns:

An angle

DrawPhiGivenPsi(index, psi)

Draws a phi angle from the conditional distribution P( phi | psi ) specified by the index.

Parameters:
  • index (int) – The index of the distribution from which a phi angle will be drawn.
  • psi (float) – psi angle
Returns:

An angle

DrawPsiGivenPhi(before, central, after, phi)

Draws a phi angle for the central residue from the conditional distribution P( psi | phi ) specific for such a triplet of residues.

Parameters:
Returns:

An angle

DrawPsiGivenPhi(index, phi)

Draws a phi angle from the conditional distribution P( psi | phi ) specified by the index.

Parameters:
  • index (int) – The index of the distribution from which a psi angle will be drawn.
  • phi (float) – phi angle
Returns:

An angle

GetProbability(before, central, after, phi, psi)

Returns the probability of a specific pair of phi/psi angles for the central residue from the corresponding distribution.

Parameters:
Returns:

A probability

GetProbability(index, phi, psi)

Returns the probability of a specific pair of phi/psi angles calulated from the distribution specified by index.

Parameters:
  • index (int) – The index of the distribution.
  • phi (float) – phi angle
  • psi (float) – psi angle
Returns:

A probability

GetPhiProbabilityGivenPsi(before, central, after, phi, psi)

Returns P( phi | psi ) for the central residue from the corresponding distribution.

Parameters:
Returns:

A probability

GetPsiProbabilityGivenPhi(before, central, after, psi, phi)

Returns P( psi | phi ) for the central residue from the corresponding distribution.

Parameters:
Returns:

A probability

GetPhiProbabilityGivenPsi(index, phi, psi)

Returns P( phi | psi ) for the central residue from the corresponding distribution.

Parameters:
  • index (int) – The index of the distribution.
  • psi (float) – phi angle
  • phi (float) – psi angle
Returns:

A probability

GetPsiProbabilityGivenPhi(index, psi, phi)

Returns P( psi | phi ) for the central residue from the corresponding distribution.

Parameters:
  • index (int) – The index of the distribution.
  • psi (float) – phi angle
  • phi (float) – psi angle
Returns:

A probability

GetBinsPerDimension()

Returns the number of bins per dimension of the distributions.

Return type:int
GetBinSize()

Returns the size of the bins (in radians) of the distributions.

Return type:float

Contents

Search

Enter search terms or a module, class or function name.

Previous topic

Representing Loops

Next topic

Structural Data

You are here