18#include <gsl/gsl_matrix.h>
19#include <gsl/gsl_eigen.h>
20#include <gsl/gsl_linalg.h>
33 Evo(
int s) : states(s), m(0), pi(NULL) {};
35 int getNumStates(){
return states;}
42 void setBranchLengths(vector<double> b,
int m=-1);
43 void printBranchLengths();
45 virtual void getRateMatrices() {};
46 virtual void computeLogPmatrices()=0;
47 virtual void addBranchLength(
double b)=0;
49 double getPi(
int i)
const {
return pi[i];}
50 double getLogPi(
int i)
const {
return log(getPi(i));}
52 gsl_matrix *getSubMatrixQ(
int u){
return allQs[u]; }
63 gsl_matrix *getSubMatrixP(
int u,
double t);
64 gsl_matrix *getSubMatrixLogP(
int u,
double t);
70 gsl_matrix *expQt(
double t, gsl_vector *lambda, gsl_matrix *U, gsl_matrix *Uinv);
73 int findClosestIndex(vector<double> &v,
double val);
80 vector<gsl_matrix *> allQs;
90int eigendecompose(gsl_matrix *Q,
97void validateEigenDecomp(gsl_matrix *Q, gsl_vector *lambda, gsl_matrix *U, gsl_matrix *Uinv,
int states);
99void printCodonMatrix(gsl_matrix *M);
104gsl_matrix *log(gsl_matrix *P,
int states);
119 ExonEvo(
int num_states=2) :
Evo(num_states), U(NULL), Uinv(NULL), l(NULL) {
126 ExonEvo(
int num_states,
double lambda,
double mu,
double ali_error)
127 :
Evo(num_states), U(NULL), Uinv(NULL), l(NULL) {
128 setLambda(lambda,
false);
130 setAliErr(ali_error,
false);
138 gsl_matrix_free(Uinv);
143 void setLambda(
double lambda = 0.0001,
bool propsOverride =
true);
144 void setMu(
double mu = 0.0001,
bool propsOverride =
true);
145 void setAliErr(
double ali_error = 0.1,
bool propsOverride =
true);
146 double getLambda()
const{
return lambda;}
147 double getMu()
const{
return mu;}
148 double getAliErr()
const{
return ali_error;}
150 void getRateMatrices();
151 void computeLogPmatrices();
152 void addBranchLength(
double b);
153 double minBranchLength()
const {
return times.front();}
154 int eigendecompose(gsl_matrix *Q);
155 gsl_matrix *expQt(
double t) {
return Evo::expQt(t,l,U,Uinv);}
156 gsl_matrix *getExonRateMatrix();
157 void validateEigenDecomp(gsl_matrix *Q){::validateEigenDecomp(Q,l,U,Uinv,states);}
185 this->times.push_back(1);
186 this->pi =
new double[64];
187 for(
int i=0; i<64; i++){
191 void computeLogPmatrices();
192 void addBranchLength(
double b){}
abstract base class for codon and exon evolution
Definition contTimeMC.hh:31
Definition contTimeMC.hh:116
A simple matrix class. Base class for all mathematical matrix objects.
Definition matrix.hh:27
Definition contTimeMC.hh:180