1 | // =============================================================== // |
---|
2 | // // |
---|
3 | // File : di_protdist.hxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Institute of Microbiology (Technical University Munich) // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // =============================================================== // |
---|
10 | |
---|
11 | #ifndef DI_PROTDIST_HXX |
---|
12 | #define DI_PROTDIST_HXX |
---|
13 | |
---|
14 | #ifndef AP_SEQ_SIMPLE_PRO_HXX |
---|
15 | #include <AP_seq_simple_pro.hxx> |
---|
16 | #endif |
---|
17 | |
---|
18 | const int DI_MAX_AA = STOP; // must be 20 |
---|
19 | const int DI_MAX_PAA = UNK; // includes virtual aa |
---|
20 | const int DI_RESOLUTION = 1000; // max res |
---|
21 | const int DI_MAX_DIST = 10; // max dist |
---|
22 | |
---|
23 | // stop is first non real AA == 20 |
---|
24 | |
---|
25 | enum di_codetype { UNIVERSAL, CILIATE, MITO, VERTMITO, FLYMITO, YEASTMITO }; |
---|
26 | enum di_cattype { NONE, SIMILARITY, KIMURA, PAM, CHEMICAL, HALL, GEORGE }; |
---|
27 | |
---|
28 | typedef double di_aa_matrix[DI_MAX_AA][DI_MAX_AA]; |
---|
29 | typedef double di_paa_matrix[DI_MAX_PAA][DI_MAX_PAA]; |
---|
30 | typedef char di_bool_matrix[DI_MAX_PAA][DI_MAX_PAA]; |
---|
31 | |
---|
32 | class DI_ENTRY; |
---|
33 | class AP_smatrix; |
---|
34 | |
---|
35 | class di_protdist : virtual Noncopyable { |
---|
36 | static double pameigs[20]; |
---|
37 | static double pamprobs[20][20]; |
---|
38 | |
---|
39 | di_codetype whichcode; |
---|
40 | di_cattype whichcat; |
---|
41 | |
---|
42 | long spp; // number of species |
---|
43 | long chars; // number of characters |
---|
44 | |
---|
45 | // spp = number of species chars = number of sites in actual sequences |
---|
46 | |
---|
47 | double freqa, freqc, freqg, freqt, ttratio, xi, xv, ease, fracchange; |
---|
48 | DI_ENTRY **entries; // link to entries |
---|
49 | aas trans[4][4][4]; |
---|
50 | double pi[20]; |
---|
51 | long cat[DI_MAX_AA]; |
---|
52 | double eig[DI_MAX_AA]; |
---|
53 | double exptteig[DI_MAX_AA]; |
---|
54 | di_aa_matrix prob, eigvecs; |
---|
55 | |
---|
56 | di_paa_matrix *slopes[DI_RESOLUTION*DI_MAX_DIST]; |
---|
57 | // huge cash for many slopes |
---|
58 | di_paa_matrix *curves[DI_RESOLUTION*DI_MAX_DIST]; |
---|
59 | di_bool_matrix *infs[DI_RESOLUTION*DI_MAX_DIST]; |
---|
60 | |
---|
61 | di_paa_matrix *akt_slopes; |
---|
62 | di_paa_matrix *akt_curves; |
---|
63 | di_bool_matrix *akt_infs; |
---|
64 | AP_smatrix *matrix; // link to output matrix |
---|
65 | |
---|
66 | // Local variables for makedists, propagated globally for c version: |
---|
67 | double p, dp, d2p; |
---|
68 | |
---|
69 | void maketrans(); |
---|
70 | void code(); |
---|
71 | void transition(); |
---|
72 | void givens(di_aa_matrix a, long i, long j, long n, double ctheta, double stheta, bool left); |
---|
73 | void coeffs(double x, double y, double *c, double *s, double accuracy); |
---|
74 | void tridiag(di_aa_matrix a, long n, double accuracy); |
---|
75 | void shiftqr(di_aa_matrix a, long n, double accuracy); |
---|
76 | void qreigen(di_aa_matrix prob, long n); |
---|
77 | void pameigen(); |
---|
78 | |
---|
79 | void predict(double tt, long nb1, long nb2); |
---|
80 | int tt_2_pos(double tt); // double to cash index |
---|
81 | double pos_2_tt(int pos); // cash index to pos |
---|
82 | void build_exptteig(double tt); |
---|
83 | void build_predikt_table(int pos); // build akt_slopes akt_curves |
---|
84 | void build_akt_predikt(double tt); // build akt_slopes akt_curves |
---|
85 | |
---|
86 | double predict_slope(int b1, int b2) { return akt_slopes[0][b1][b2]; } |
---|
87 | double predict_curve(int b1, int b2) { return akt_curves[0][b1][b2]; } |
---|
88 | char predict_infinity(int b1, int b2) { return akt_infs[0][b1][b2]; } |
---|
89 | |
---|
90 | void clean_slopes(); |
---|
91 | |
---|
92 | public: |
---|
93 | di_protdist(di_codetype codei, di_cattype cati, long nentries, DI_ENTRY **entries, long seq_len, AP_smatrix *matrixi); |
---|
94 | ~di_protdist(); |
---|
95 | |
---|
96 | GB_ERROR makedists(bool *aborted_flag); // calculate the distance matrix |
---|
97 | }; |
---|
98 | |
---|
99 | #else |
---|
100 | #error di_protdist.hxx included twice |
---|
101 | #endif // DI_PROTDIST_HXX |
---|