Functions | Variables
models.c File Reference

Model related code. More...

Functions

void putWAG (double *ext_initialRates)
 Hardcoded values for the WAG model. More...
 
static void initProtMat (double f[20], int proteinMatrix, double *ext_initialRates, int lg4_index)
 Initialize protein substitution rates matrix. More...
 
static void updateFracChange (pllInstance *tr, partitionList *pr)
 Set the frac. More...
 
static void mytred2 (double **a, const int n, double *d, double *e)
 Not sure what this function does. More...
 
static int mytqli (double *d, double *e, const int n, double **z)
 Not sure what this function does. More...
 
static void makeEigen (double **_a, const int states, double *d, double *e)
 Compute the eigenvectors and eigenvalues. More...
 
static void initGeneric (const int states, const unsigned int *valueVector, int valueVectorLength, double *fracchange, double *ext_EIGN, double *EV, double *EI, double *frequencies, double *ext_initialRates, double *tipVector)
 Generic initialization of parameters and decomposition of the Q matrix. More...
 
void initReversibleGTR (pllInstance *tr, partitionList *pr, int model)
 Initialize GTR. More...
 
double LnGamma (double alpha)
 
double IncompleteGamma (double x, double alpha, double ln_gamma_alpha)
 
double PointNormal (double prob)
 
double PointChi2 (double prob, double v)
 
void makeGammaCats (double alpha, double *gammaRates, int K, boolean useMedian)
 Compute the gamma rates. More...
 
static void setRates (double *r, int rates)
 Set the substitution rates. More...
 
void initRateMatrix (pllInstance *tr, partitionList *pr)
 Initialize the substitution rates matrix. More...
 
static void setSymmetry (int *s, int *sDest, const int sCount, int *f, int *fDest, const int fCount)
 Function for setting secondary structure symmetries. More...
 
static void setupSecondaryStructureSymmetries (pllInstance *tr, partitionList *partitions)
 Wrapper function for setting secondary structure symmetries. More...
 
static void initializeBaseFreqs (partitionList *pr, double **empiricalFrequencies)
 Initialize base frequencies in partition data. More...
 
void initModel (pllInstance *tr, double **empiricalFrequencies, partitionList *partitions)
 Initialize the model parameters. More...
 

Variables

const unsigned int bitVectorSecondary [256]
 
const unsigned int bitVector32 [33]
 
const unsigned int bitVectorAA [23]
 
const unsigned int bitVectorIdentity [256]
 
const partitionLengths pLengths [PLL_MAX_MODEL]
 
FILE * byteFile
 

Detailed Description

Model related code.

Detailed description to appear soon.

Function Documentation

static void initGeneric ( const int  states,
const unsigned int *  valueVector,
int  valueVectorLength,
double *  fracchange,
double *  ext_EIGN,
double *  EV,
double *  EI,
double *  frequencies,
double *  ext_initialRates,
double *  tipVector 
)
static

Generic initialization of parameters and decomposition of the Q matrix.

Decompose the Q matrix into eigenvectors and eigenvalues.

Parameters
statesNumber of states of the current model
valueVectorPointer where the tipVector will be stored
valueVectorLengthNumber of elements (of size states) of the tipVector
fracchangeVariable where the computed fracchange will be stored
ext_EIGNArray where the eigenvalues will be stored
EVArray where the eigenvectors will be stored
EIArray where the inverse eigenvectors will be stored
frequenciesThe model frequencies
ext_initialRatesThe model substitution rates
tipVectorArray where the computed tipVector will be stored
Todo:
Perhaps we could change this also to the way optRatesGeneric and other functions are implemented. That is, instead of passing all these parameters, pass the partition index instead and load the values within the code. Will make the code more readable.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void initializeBaseFreqs ( partitionList pr,
double **  empiricalFrequencies 
)
static

Initialize base frequencies in partition data.

Copy the computed empirical frequencies for each partition from the empiricalFrequencies structure to each partition structure.

Parameters
prList of partitions
empiricalFrequenciesArray containing the empirical frequencies

+ Here is the caller graph for this function:

void initModel ( pllInstance tr,
double **  empiricalFrequencies,
partitionList partitions 
)

Initialize the model parameters.

Initialize the model parameters. Specifically

  • Base frequencies
  • Rate matrix
Parameters
trThe PLL instance
empiricalFrequenciesPointer to the empirical frequencies array
partitionsPointer to the partitions structure
Todo:
What is tr->optimizeRateCategoryInvocations = 1 ?

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void initProtMat ( double  f[20],
int  proteinMatrix,
double *  ext_initialRates,
int  lg4_index 
)
static

Initialize protein substitution rates matrix.

Initialize the array pointed to by ext_initialRates with the substitution rates of the corresponding protein model and set f to the appropriate stationary frequencies

Parameters
fArray where to store the stationary frequency rates
proteinMatrixWhich protein matrix to use
ext_initialRatesWhere to store the retrieved substitution rates
lg4_indexIn case we are filling a substitution rates matrix of an LG4 model the index specifies which of the four matrixes to use

+ Here is the caller graph for this function:

void initRateMatrix ( pllInstance tr,
partitionList pr 
)

Initialize the substitution rates matrix.

Initialize the substitution rates matrices for all partitions

Parameters
trThe PLL instance
prList of partitions
Todo:
Do we need the secondary structure and binary? Will we only use GTR? If yes, we could rename this function to initRateMatrixGTR

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void initReversibleGTR ( pllInstance tr,
partitionList pr,
int  model 
)

Initialize GTR.

Wrapper function for the decomposition of the substitution rates matrix into eigenvectors and eigenvalues

Parameters
trPLL instance
prList of partitions
modelPartition index

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void makeEigen ( double **  _a,
const int  states,
double *  d,
double *  e 
)
static

Compute the eigenvectors and eigenvalues.

Parameters
_aThe Q matrix
statesNumber of states
dEigenvalues I think?
eNot sure why this is passed as a parameter. It is uninitialized, it is first set in mytqli(...) and it is never used in initGeneric()
Todo:
Remove e from parameter?

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void makeGammaCats ( double  alpha,
double *  gammaRates,
int  K,
boolean  useMedian 
)

Compute the gamma rates.

Compute the gamma rates

Parameters
alphaAlpha parameter
gammaRatesArray where to store the computed gamma rates
KNumber of categories
useMedianBoolean flag whether to use a median or not
Todo:
Document this more.

+ Here is the caller graph for this function:

static int mytqli ( double *  d,
double *  e,
const int  n,
double **  z 
)
static

Not sure what this function does.

Todo:
Comment this function

+ Here is the caller graph for this function:

static void mytred2 ( double **  a,
const int  n,
double *  d,
double *  e 
)
static

Not sure what this function does.

Todo:
Comment this function

+ Here is the caller graph for this function:

void putWAG ( double *  ext_initialRates)

Hardcoded values for the WAG model.

Fill the ext_initialRates array with hardcoded substitution rates of the WAG model.

Parameters
ext_initialRatesWhere to place the substitution rates

+ Here is the caller graph for this function:

static void setRates ( double *  r,
int  rates 
)
static

Set the substitution rates.

Set rates - 1 substitution rates. Set the last rate to 1.

Parameters
rArray of substitution rates
ratesNumber of rates to set

+ Here is the caller graph for this function:

static void setSymmetry ( int *  s,
int *  sDest,
const int  sCount,
int *  f,
int *  fDest,
const int  fCount 
)
static

Function for setting secondary structure symmetries.

Todo:
Do we need this function?

+ Here is the caller graph for this function:

static void setupSecondaryStructureSymmetries ( pllInstance tr,
partitionList partitions 
)
static

Wrapper function for setting secondary structure symmetries.

Todo:
Do we need this function?

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void updateFracChange ( pllInstance tr,
partitionList pr 
)
static

Set the frac.

Update partitionContribution in each partition by setting it to the fraction of sites in that partition to the total number of sites. Also set tr->fracchange according to the computes fracchange of each partition.

Parameters
trPLL instance
prList of partitions
Todo:
I understand how fracchange is computed for each partition, but I dont know what is it for. Also what is tr->fracchange for?

+ Here is the caller graph for this function: