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