1 | |
---|
2 | const int ph_max_aa = stop; // mussed be 20 |
---|
3 | const int ph_max_paa = unk; // includes virtual aa |
---|
4 | const int ph_resolution = 1000; // max res |
---|
5 | const int ph_max_dist = 10; // max dist |
---|
6 | // stop is first non real AA == 20 |
---|
7 | |
---|
8 | typedef enum { |
---|
9 | universal, ciliate, mito, vertmito, flymito, yeastmito |
---|
10 | } ph_codetype; |
---|
11 | typedef enum { |
---|
12 | none,similarity,kimura,pam,chemical, hall, george |
---|
13 | } ph_cattype; |
---|
14 | |
---|
15 | |
---|
16 | typedef double ph_aa_matrix[ph_max_aa][ph_max_aa]; |
---|
17 | typedef double ph_paa_matrix[ph_max_paa][ph_max_paa]; |
---|
18 | typedef char ph_bool_matrix[ph_max_paa][ph_max_paa]; |
---|
19 | |
---|
20 | class ph_protdist { |
---|
21 | static double pameigs[20]; |
---|
22 | static double pamprobs[20][20]; |
---|
23 | ph_codetype whichcode; |
---|
24 | ph_cattype whichcat; |
---|
25 | |
---|
26 | long spp; // number of species |
---|
27 | long chars; // number of characters |
---|
28 | /* |
---|
29 | * spp = number of species chars = number of sites in actual sequences |
---|
30 | */ |
---|
31 | double freqa, freqc, freqg, freqt, ttratio, xi, xv, ease, fracchange; |
---|
32 | PHENTRY **entries; // link to entries |
---|
33 | aas trans[4][4][4]; |
---|
34 | double pi[20]; |
---|
35 | long cat[ph_max_aa]; |
---|
36 | double eig[ph_max_aa]; |
---|
37 | double exptteig[ph_max_aa]; |
---|
38 | ph_aa_matrix prob, eigvecs; |
---|
39 | ph_paa_matrix *(slopes[ph_resolution*ph_max_dist]); |
---|
40 | // huge cash for many slopes |
---|
41 | ph_paa_matrix *(curves[ph_resolution*ph_max_dist]); |
---|
42 | ph_bool_matrix *(infs[ph_resolution*ph_max_dist]); |
---|
43 | ph_paa_matrix *akt_slopes; |
---|
44 | ph_paa_matrix *akt_curves; |
---|
45 | ph_bool_matrix *akt_infs; |
---|
46 | double weight[2]; // weight akt slope 1 -> linear interpolation |
---|
47 | AP_smatrix *matrix; // link to output matrix |
---|
48 | |
---|
49 | /* Local variables for makedists, propagated globally for c version: */ |
---|
50 | double p, dp, d2p; |
---|
51 | |
---|
52 | |
---|
53 | void cats(ph_cattype wcat); |
---|
54 | void maketrans(); |
---|
55 | void code(); |
---|
56 | void transition(); |
---|
57 | void givens(ph_aa_matrix a,long i,long j,long n,double ctheta,double stheta,GB_BOOL left); |
---|
58 | void coeffs(double x,double y,double *c,double *s,double accuracy); |
---|
59 | void tridiag(ph_aa_matrix a,long n,double accuracy); |
---|
60 | void shiftqr(ph_aa_matrix a, long n, double accuracy); |
---|
61 | void qreigen(ph_aa_matrix prob,long n); |
---|
62 | void pameigen(); |
---|
63 | |
---|
64 | void predict(double tt,long nb1,long nb2); |
---|
65 | int tt_2_pos(double tt); // double to cash index |
---|
66 | double pos_2_tt(int pos); // cash index to pos |
---|
67 | void build_exptteig(double tt); |
---|
68 | void build_predikt_table(int pos); // build akt_slopes akt_curves |
---|
69 | void build_akt_predikt(double tt); // build akt_slopes akt_curves |
---|
70 | |
---|
71 | double predict_slope(int b1,int b2) { |
---|
72 | return akt_slopes[0][b1][b2];}; |
---|
73 | double predict_curve(int b1,int b2) { return |
---|
74 | akt_curves[0][b1][b2];}; |
---|
75 | char predict_infinity(int b1,int b2) { return |
---|
76 | akt_infs[0][b1][b2];}; |
---|
77 | void clean_slopes(); |
---|
78 | |
---|
79 | public: |
---|
80 | ph_protdist(ph_codetype codei, ph_cattype cati, long nentries, PHENTRY **entries, long seq_len, AP_smatrix *matrixi); |
---|
81 | ~ph_protdist(); |
---|
82 | const char *makedists(); // calculate the distance matrix |
---|
83 | }; |
---|