Augustus 3.4.0
Loading...
Searching...
No Matches
codonevodiscr.hh
1/*
2 * codonevo.hh
3 *
4 * License: Artistic License, see file LICENSE.TXT or
5 * https://opensource.org/licenses/artistic-license-1.0
6 */
7
8#ifndef _CODONEVODISCR_HH
9#define _CODONEVODISCR_HH
10
11#include "contTimeMC.hh"
12#include "geneticcode.hh"
13
14enum MatrixFormat {fmt_GSL, fmt_TXT};
15
16//forward declarations
17class PhyloTree;
18
34// clamsa related code
35class CodonEvoDiscr : public Evo {
36public:
37 CodonEvoDiscr() : Evo(64), M(0), Theta(NULL), bias(NULL), w(NULL) {};
39
40 /*
41 * in the discriminative settings, k stands for the number of models matrices were computed on the base of
42 */
43 void setM();
44 int getM(){ return M;}
45 void writeRateMatrices(string filename); // serialize to file
46 void readMatrices(MatrixFormat fmt = fmt_TXT);
47
48 void computeLogPmatrices(); // precomputes and stores the array of matrices
49
50 /*
51 * Returns a pointer to the 64x64 substitution probability matrix
52 * for which t and omega come closest to scored values.
53 */
54 gsl_matrix *getSubMatrixLogP(double omega, double t);
55
56 /*
57 * Computes the substitution probability
58 * P( X(t)=to | X(0)=from, omega), where 1 <= from,to <= 64 are codons
59 * If you want to call this for many values of 'from' and 'to', use rather getSubMatrixP above.
60 */
61 double subLogProb(int from, int to, double omega, double t){
62 gsl_matrix *P = getSubMatrixLogP(omega, t);
63 return gsl_matrix_get(P, from, to);
64 }
65 /*
66 * log likelihood of exon candidate pair e1, e1 (required: equal number of codons, gapless)
67 * Used for testing. The pruning algorithm requires tuples of codons instead.
68 */
69 double logLik(const char *e1, const char *e2, int u, double t); // output variables
70
71 // store log likeliehoods for all omegas for one codon tuple
72 vector<double> loglikForCodonTuple(vector<string> &seqtuple, PhyloTree *ctree){
73 int dummysubs = 0;
74 return loglikForCodonTuple(seqtuple, ctree, NULL, dummysubs);
75 }
76
77 /* loglikForCodonTuple
78 * @param[in] seqtuple input codon alignment with as many rows as ctree has leaves
79 * @param[in] ctree codon scaled tree
80 * @param[in] tree optionally a second tree for running the Fitch alg
81 * @return the a vector of k log likelihoods
82 */
83 vector<double> loglikForCodonTuple(vector<string> &seqtuple, PhyloTree *ctree, PhyloTree *tree, int &subs);
84 /*
85 * add new branch length b
86 * this function is currently not needed, since the pruning algorithm does change the phylogenetic tree
87 */
88 void addBranchLength(double b){}
89
90 void produceComb(vector<vector<int> >& config){}
91 double getProb(const vector<double> &lls);
92
93private:
94 int M; // number of rate matrices for which P's are stored
95 vector<double*> piArr; // differently from the case of omega here each model M has its own pi
96 gsl_matrix *Theta; // M x 2 matrix from ClaMSA logreg layer
97 double *bias; // vector of 2 biases from ClaMSA logreg layer
98 double *w; // weight vector summarizing equivalently Theta and bias
99};
100
101#endif // _CODONEVODISCR_HH
class CodonEvoDiscr
Definition codonevodiscr.hh:35
abstract base class for codon and exon evolution
Definition contTimeMC.hh:31
Definition phylotree.hh:104