1 | // =============================================================== // |
---|
2 | // // |
---|
3 | // File : phylo.hxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Institute of Microbiology (Technical University Munich) // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // =============================================================== // |
---|
10 | |
---|
11 | #ifndef PHYLO_HXX |
---|
12 | #define PHYLO_HXX |
---|
13 | |
---|
14 | #ifndef PH_FILTER_HXX |
---|
15 | #include "PH_filter.hxx" |
---|
16 | #endif |
---|
17 | #ifndef AP_MATRIX_HXX |
---|
18 | #include <AP_matrix.hxx> |
---|
19 | #endif |
---|
20 | #ifndef AW_BASE_HXX |
---|
21 | #include <aw_base.hxx> |
---|
22 | #endif |
---|
23 | #ifndef ARBDB_BASE_H |
---|
24 | #include <arbdb_base.h> |
---|
25 | #endif |
---|
26 | #ifndef ARB_ASSERT_H |
---|
27 | #include <arb_assert.h> |
---|
28 | #endif |
---|
29 | |
---|
30 | #define ph_assert(cond) arb_assert(cond) |
---|
31 | |
---|
32 | #define AWAR_PHYLO_ALIGNMENT "tmp/phyl/alignment" |
---|
33 | #define AWAR_PHYLO_FILTER_FILTER "phyl/filter/filter" |
---|
34 | |
---|
35 | #define AWAR_PHYLO_MATRIX_POINT "phyl/matrix/point" |
---|
36 | #define AWAR_PHYLO_MATRIX_MINUS "phyl/matrix/minus" |
---|
37 | #define AWAR_PHYLO_MATRIX_REST "phyl/matrix/rest" |
---|
38 | #define AWAR_PHYLO_MATRIX_LOWER "phyl/matrix/lower" |
---|
39 | |
---|
40 | #define AWAR_PHYLO_FILTER_STARTCOL "phyl/filter/startcol" |
---|
41 | #define AWAR_PHYLO_FILTER_STOPCOL "phyl/filter/stopcol" |
---|
42 | #define AWAR_PHYLO_FILTER_MINHOM "phyl/filter/minhom" |
---|
43 | #define AWAR_PHYLO_FILTER_MAXHOM "phyl/filter/maxhom" |
---|
44 | #define AWAR_PHYLO_FILTER_POINT "phyl/filter/point" |
---|
45 | #define AWAR_PHYLO_FILTER_MINUS "phyl/filter/minus" |
---|
46 | #define AWAR_PHYLO_FILTER_REST "phyl/filter/rest" |
---|
47 | #define AWAR_PHYLO_FILTER_LOWER "phyl/filter/lower" |
---|
48 | |
---|
49 | #define AWAR_PHYLO_MARKERLINENAME "tmp/phylo/markerlinename" |
---|
50 | |
---|
51 | enum { |
---|
52 | DONT_COUNT = 0, |
---|
53 | SKIP_COLUMN_IF_MAX = 1, |
---|
54 | SKIP_COLUMN_IF_OCCUR = 2, |
---|
55 | COUNT_DONT_USE_MAX = 3, |
---|
56 | TREAT_AS_UPPERCASE = 4, |
---|
57 | TREAT_AS_REGULAR = 5, |
---|
58 | |
---|
59 | FILTER_MODES, // has to be last! |
---|
60 | }; |
---|
61 | |
---|
62 | |
---|
63 | #define PH_DB_CACHE_SIZE 2000000 |
---|
64 | |
---|
65 | #define AP_F_LOADED ((AW_active)1) |
---|
66 | #define AP_F_NLOADED ((AW_active)2) |
---|
67 | #define AP_F_SEQUENCES ((AW_active)4) |
---|
68 | #define AP_F_MATRIX ((AW_active)8) |
---|
69 | #define AP_F_TREE ((AW_active)16) |
---|
70 | #define AP_F_ALL ((AW_active)-1) |
---|
71 | |
---|
72 | #define PH_CORRECTION_BANDELT_STRING "bandelt" |
---|
73 | |
---|
74 | #define NIL 0 |
---|
75 | |
---|
76 | // matrix definitions |
---|
77 | #define PH_TRANSFORMATION_JUKES_CANTOR_STRING "J+C" |
---|
78 | #define PH_TRANSFORMATION_KIMURA_STRING "KIMURA" |
---|
79 | #define PH_TRANSFORMATION_TAJIMA_NEI_STRING "T+N" |
---|
80 | #define PH_TRANSFORMATION_TAJIMA_NEI_PAIRWISE_STRING "T+N-P" |
---|
81 | #define PH_TRANSFORMATION_BANDELT_STRING "B" |
---|
82 | #define PH_TRANSFORMATION_BANDELT_JC_STRING "B+J+C" |
---|
83 | #define PH_TRANSFORMATION_BANDELT2_STRING "B2" |
---|
84 | #define PH_TRANSFORMATION_BANDELT2_JC_STRING "B2+J+C" |
---|
85 | |
---|
86 | enum PH_CORRECTION { |
---|
87 | PH_CORRECTION_NONE, |
---|
88 | PH_CORRECTION_BANDELT |
---|
89 | }; |
---|
90 | |
---|
91 | |
---|
92 | enum { |
---|
93 | PH_GC_0, |
---|
94 | PH_GC_1, |
---|
95 | PH_GC_0_DRAG |
---|
96 | }; |
---|
97 | |
---|
98 | // make awars : |
---|
99 | void PH_create_filter_variables(AW_root *aw_root, AW_default aw_def); |
---|
100 | |
---|
101 | AW_window *PH_create_filter_window(AW_root *aw_root); |
---|
102 | |
---|
103 | |
---|
104 | |
---|
105 | enum display_type { NONE, species_dpy, filter_dpy, matrix_dpy, tree_dpy }; |
---|
106 | |
---|
107 | |
---|
108 | typedef double AP_FLOAT; |
---|
109 | |
---|
110 | enum PH_TRANSFORMATION { |
---|
111 | PH_TRANSFORMATION_NONE, |
---|
112 | PH_TRANSFORMATION_JUKES_CANTOR, |
---|
113 | PH_TRANSFORMATION_KIMURA, |
---|
114 | PH_TRANSFORMATION_TAJIMA_NEI, |
---|
115 | PH_TRANSFORMATION_TAJIMA_NEI_PAIRWISE, |
---|
116 | PH_TRANSFORMATION_BANDELT, |
---|
117 | PH_TRANSFORMATION_BANDELT_JC, |
---|
118 | PH_TRANSFORMATION_BANDELT2, |
---|
119 | PH_TRANSFORMATION_BANDELT2_JC |
---|
120 | }; |
---|
121 | |
---|
122 | // --------------------------- |
---|
123 | // class definitions |
---|
124 | |
---|
125 | class PH_root : virtual Noncopyable { |
---|
126 | char *use; |
---|
127 | GBDATA *gb_main; |
---|
128 | |
---|
129 | static PH_root *SINGLETON; |
---|
130 | |
---|
131 | public: |
---|
132 | |
---|
133 | PH_root() |
---|
134 | : use(NULL), |
---|
135 | gb_main(NULL) |
---|
136 | { |
---|
137 | ph_assert(!SINGLETON); |
---|
138 | SINGLETON = this; |
---|
139 | } |
---|
140 | ~PH_root() { |
---|
141 | ph_assert(this == SINGLETON); |
---|
142 | SINGLETON = NULL; |
---|
143 | free(use); |
---|
144 | } |
---|
145 | |
---|
146 | GB_ERROR open(const char *db_server); |
---|
147 | GBDATA *get_gb_main() const { ph_assert(gb_main); return gb_main; } |
---|
148 | const char *get_aliname() const { return use; } |
---|
149 | }; |
---|
150 | |
---|
151 | |
---|
152 | struct elem; |
---|
153 | |
---|
154 | class PHDATA : virtual Noncopyable { |
---|
155 | // connection to database |
---|
156 | // pointers to all elements and important values of the database |
---|
157 | |
---|
158 | struct PHENTRY : virtual Noncopyable { |
---|
159 | unsigned int key; |
---|
160 | char *name; |
---|
161 | char *full_name; |
---|
162 | GBDATA *gb_species_data_ptr; |
---|
163 | PHENTRY *next; |
---|
164 | PHENTRY *prev; |
---|
165 | int group_members; // >0: this elem is grouphead |
---|
166 | elem *first_member; // !=NULL: elem is grouphead |
---|
167 | bool selected; |
---|
168 | |
---|
169 | PHENTRY() |
---|
170 | : key(0), |
---|
171 | name(NULL), |
---|
172 | full_name(NULL), |
---|
173 | gb_species_data_ptr(NULL), |
---|
174 | next(NULL), |
---|
175 | prev(NULL), |
---|
176 | group_members(0), |
---|
177 | first_member(NULL), |
---|
178 | selected(false) |
---|
179 | {} |
---|
180 | |
---|
181 | ~PHENTRY() { |
---|
182 | ph_assert(0); // @@@ why not called? |
---|
183 | } |
---|
184 | }; |
---|
185 | |
---|
186 | unsigned int last_key_number; |
---|
187 | long seq_len; |
---|
188 | |
---|
189 | AW_root *aw_root; // only link |
---|
190 | PH_root *ph_root; // only link |
---|
191 | |
---|
192 | public: |
---|
193 | GBDATA *get_gb_main() { return ph_root->get_gb_main(); } |
---|
194 | |
---|
195 | char *use; // @@@ elim (PH_root has same field) |
---|
196 | |
---|
197 | PHENTRY *entries; |
---|
198 | PHENTRY **hash_elements; |
---|
199 | unsigned int nentries; // total number of entries |
---|
200 | |
---|
201 | static PHDATA *ROOT; // 'global' pointer |
---|
202 | |
---|
203 | AP_smatrix *distance_table; // weights between different characters |
---|
204 | AP_smatrix *matrix; // calculated matrix |
---|
205 | float *markerline; |
---|
206 | |
---|
207 | PHDATA(AW_root *aw_root_, PH_root *ph_root_) |
---|
208 | : last_key_number(0), |
---|
209 | seq_len(0), |
---|
210 | aw_root(aw_root_), |
---|
211 | ph_root(ph_root_), |
---|
212 | use(NULL), |
---|
213 | entries(NULL), |
---|
214 | hash_elements(NULL), |
---|
215 | nentries(0), |
---|
216 | distance_table(NULL), |
---|
217 | matrix(NULL), |
---|
218 | markerline(NULL) |
---|
219 | {} |
---|
220 | ~PHDATA() { |
---|
221 | unload(); |
---|
222 | delete matrix; |
---|
223 | } |
---|
224 | |
---|
225 | char *load(char*& use); // open database and get pointers to it |
---|
226 | char *unload(); |
---|
227 | GB_ERROR save(char *filename); |
---|
228 | void print(); |
---|
229 | GB_ERROR calculate_matrix(const char *cancel, double alpha, PH_TRANSFORMATION transformation); |
---|
230 | long get_seq_len() { return seq_len; }; |
---|
231 | |
---|
232 | }; |
---|
233 | |
---|
234 | #else |
---|
235 | #error phylo.hxx included twice |
---|
236 | #endif // PHYLO_HXX |
---|