ppALIGN API documentation

BoltzmannWeight Class Reference

#include <weights.hpp>

Inheritance diagram for BoltzmannWeight:
Weight

List of all members.

Public Member Functions

 BoltzmannWeight (const ScoreMatrix &s, double _scale, double temperature, double gap_open, double gap_extension, AlignmentType t, bool allow_DI=true, bool allow_ID=false)
 BoltzmannWeight (const Alphabet &alphabet1, const Alphabet &alphabet2, const std::string &matrix_name, double temperature, double gap_open, double gap_extension, AlignmentType t, bool allow_DI=true, bool allow_ID=false)
virtual ~BoltzmannWeight ()
xdouble Average (const Frequencies &freq1, const Frequencies &freq2) const
double Temperature () const
virtual bool IsBoltzmann () const

Public Attributes

double temper
double alpha
double beta
xdouble exp_alpha
xdouble exp_beta

Detailed Description

Boltzmannweights of the score matrix. Each pair of letters a and b is assigned a weight $w[a][b] = \exp ( s[a][b] / T / \lambda)$ where s is a score matrix and T the temperature. The relationship between the log-likelihood ratio and the score is given by $s[a][b] = \lambda * \log \frac{p(a,b)}{q(a)q(b)}$. $\lambda$ is stored in the field Weight::scale.

  • BoltzmannWeight::BoltzmannWeight(const ScoreMatrix & s,double,double, double,AlignmentType,bool,bool) Constructor from a integer valued score matrix with scale $ \lambda = 1$.
  • BoltzmannWeight::BoltzmannWeight(const Alphabet &, const Alphabet &, const std::string &, double,double, double,AlignmentType,bool,bool). Construcotr from a matrix name. The scale $ \lambda $ is set accordingly, e.g. $ 2 / \log(2)$ for the blosum matrix. In this case the canonical temperature where finite temperature alignment approximates the pair HMM is 1.

The free score is defined as

\[ F_T = T \lambda \log Z_T \]

and the expected score as

\[ \langle S \rangle_T = \frac{1}{Z_T}\sum_A S(A) \exp\left( \frac{S(A)}{T\lambda} \right) \]

with

\[ Z_T = \sum_A \exp\left(\frac{S(A)}{T \lambda}\right) \]

. The image below shows how the free score and the expected score variies with temperature. In the limit $ T \rightarrow 0$ both values approach the value of the optimal score.

freescore.png
Examples:

alternative_alignments.cpp, freescore.cpp, and pairprobmap.cpp.

Definition at line 232 of file weights.hpp.


Constructor & Destructor Documentation

BoltzmannWeight::BoltzmannWeight ( const ScoreMatrix s,
double  _scale,
double  temperature,
double  gap_open,
double  gap_extension,
AlignmentType  t,
bool  allow_DI = true,
bool  allow_ID = false 
)

Construct the weights from the score matrix and temperature.

Assume that the score matrix is given by the integer values stored in s[a][b]. The weights are given by $ w[a][b] = \exp(s[a][b] / temperature / lambda) $. If the scale is not known use the method ScoreMatrix::GetScale(). It is stored in Weight::scale. Gaps are given the weight $\exp(-\frac{\alpha}{ \lambda T })$ and $\exp(-\frac{\beta}{ \lambda T})$, where

  • $\alpha$ = gap_open + gap_extension.
  • $\beta$ = gap_extension.
    Parameters:
    s score matrix (integer valued)
    scale scale of the matrix
    temperature temperature
    gap_open gap open penalty
    gap_extension gap extension penalty
    t type of the alignment
    allow_DI transitions from deletion to insertion possible
    allow_ID transitions from insertion to deletion possible
BoltzmannWeight::BoltzmannWeight ( const Alphabet alphabet1,
const Alphabet alphabet2,
const std::string &  matrix_name,
double  temperature,
double  gap_open,
double  gap_extension,
AlignmentType  t,
bool  allow_DI = true,
bool  allow_ID = false 
)

Construct the weights from the score matrix and temperature. Assume that the name of the score matrix is known and supported by ppalign. The score matrix is scaled by $\exp[ p(a,b)/q(a)/q(b)/T ]$ The scale of the corresponding matrix is stored in Weight::scale. Gaps are given the weight $\exp(-\frac{\alpha}{\lambda T})$ and $\exp(-\frac{\beta}{\lambda T})$, where

  • $\alpha$ = gap_open + gap_extension.
  • $\beta$ = gap_extension.
    Parameters:
    alphabet1 alphabet of the first sequence
    alphabet2 alphabet of the second sequence
    matrix_name name of the scoring matrix
    temperature temperature T
    gap_open gap open penalty
    gap_extension gap extension penalty
    t alignment type
    allow_DI transitions from deletion to insertion possible
    allow_ID transitions from insertion to deletion possible
virtual BoltzmannWeight::~BoltzmannWeight (  )  [inline, virtual]

Destructor.

Definition at line 329 of file weights.hpp.


Member Function Documentation

xdouble BoltzmannWeight::Average ( const Frequencies freq1,
const Frequencies freq2 
) const

Average the weights with respect to frequencies freq1 and freq2.

Parameters:
freq1 Frequencies for the first letter
freq2 Frequencies for the second letter
Returns:
$[ \sum_{a,b} p(a) p(b) w[a][b]$ where p=freq1 and q=freq2
Remarks:
ensure that freq1 and freq2 are normalized
virtual bool BoltzmannWeight::IsBoltzmann (  )  const [inline, virtual]
Returns:
true

Reimplemented from Weight.

Definition at line 349 of file weights.hpp.

double BoltzmannWeight::Temperature (  )  const [inline]

Temperature

Returns:
temperature

Definition at line 343 of file weights.hpp.


Member Data Documentation

gap open penality

Definition at line 243 of file weights.hpp.

gap extension penality

Definition at line 245 of file weights.hpp.

Weights for gap open $\exp(-frac{\alpha}{T \lambda})$. see different constructor for the definition of the scale $\lambda$.

Definition at line 255 of file weights.hpp.

Weights for gap extension $ \exp(-frac{\alpha}{T \lambda})$. See different constructor for the definition of the scale

Definition at line 265 of file weights.hpp.

temperature value.

Definition at line 241 of file weights.hpp.


The documentation for this class was generated from the following file: