1 | // =========================================================== // |
---|
2 | // // |
---|
3 | // File : adtools.hxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Institute of Microbiology (Technical University Munich) // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // =========================================================== // |
---|
10 | |
---|
11 | #ifndef ADTOOLS_HXX |
---|
12 | #define ADTOOLS_HXX |
---|
13 | |
---|
14 | const long max_value = 0x7fffffff; |
---|
15 | |
---|
16 | #include <arbdb++.hxx> |
---|
17 | |
---|
18 | typedef enum { |
---|
19 | ADT_SEARCH_FORWARD = 1, |
---|
20 | ADT_SEARCH_BACKWARD = -1, |
---|
21 | ADT_SEARCH_ALL = 0 |
---|
22 | } ADT_SEARCH_DIRECTION; |
---|
23 | |
---|
24 | |
---|
25 | typedef enum { |
---|
26 | ADT_NO_REPLACE = -1, |
---|
27 | ADT_REPLACE_ONLY = 0, |
---|
28 | ADT_REPLACE_AND_SEARCH_NEXT = 4, |
---|
29 | ADT_SEARCH_AND_REPLACE_NEXT = 1, |
---|
30 | ADT_REPLACE_REST_SEQUENCE = 2, |
---|
31 | ADT_REPLACE_REST_EDITOR = 3 |
---|
32 | } ADT_REPLACE_OPTION; |
---|
33 | |
---|
34 | |
---|
35 | typedef enum { |
---|
36 | NO_BUTTON, |
---|
37 | //----------search |
---|
38 | BUTTON_SEARCH_FORWARD, |
---|
39 | BUTTON_SEARCH_BACKWARD, |
---|
40 | BUTTON_SEARCH_ALL, |
---|
41 | //----------replace |
---|
42 | BUTTON_NO_REPLACE, |
---|
43 | BUTTON_REPLACE_ONLY, |
---|
44 | BUTTON_REPLACE_AND_SEARCH_NEXT, |
---|
45 | BUTTON_SEARCH_AND_REPLACE_NEXT, |
---|
46 | BUTTON_REPLACE_REST_SEQUENCE, |
---|
47 | BUTTON_REPLACE_REST_EDITOR, |
---|
48 | //----------complement |
---|
49 | BUTTON_COMPL_BLOCK, |
---|
50 | BUTTON_COMPL_REST_SEQUENCE, |
---|
51 | BUTTON_COMPL_SEQUENCE, |
---|
52 | BUTTON_COMPL_REST_TEXT, |
---|
53 | BUTTON_COMPL_ALL |
---|
54 | } ADT_BUTTON; |
---|
55 | |
---|
56 | typedef enum { |
---|
57 | ADT_DONT_STOPP_REPLACE = 1, |
---|
58 | ADT_STOPP_REPLACE = 0 |
---|
59 | } ADT_REPLACE_LOOP; |
---|
60 | |
---|
61 | typedef enum { |
---|
62 | ADT_DB_CLOSED = 0, |
---|
63 | ADT_DB_OPEN = 1 |
---|
64 | } ADT_DB_STATUS; |
---|
65 | |
---|
66 | typedef enum { |
---|
67 | ADT_ALITYPE_UNDEFINED, |
---|
68 | ADT_ALITYPE_RNA, |
---|
69 | ADT_ALITYPE_DNA, |
---|
70 | ADT_ALITYPE_AMI |
---|
71 | } ADT_ACID; |
---|
72 | |
---|
73 | typedef enum { |
---|
74 | NO = 0, |
---|
75 | YES = 1 |
---|
76 | } ADT_UTIL; |
---|
77 | |
---|
78 | #define GAP_SYMBOL 80 // zeichen, ausser NULL |
---|
79 | #define NOGAP_SYMBOL 70 |
---|
80 | |
---|
81 | /*************************************************************************** |
---|
82 | class ADT_COMPLEMENT |
---|
83 | |
---|
84 | ***************************************************************************/ |
---|
85 | |
---|
86 | class ADT_COMPLEMENT { |
---|
87 | friend class ADT_SEQUENCE; |
---|
88 | |
---|
89 | //********** |
---|
90 | private: |
---|
91 | char *char_array; |
---|
92 | char *make_char_array(); // vollst. Zeichensatz |
---|
93 | |
---|
94 | //********** |
---|
95 | public: |
---|
96 | |
---|
97 | const char *species_name; |
---|
98 | const char *alignment_type; |
---|
99 | const char *alignment_name; |
---|
100 | char *sequence; |
---|
101 | char *sequence_buffer; |
---|
102 | |
---|
103 | long *index_buffer; |
---|
104 | |
---|
105 | ADT_ACID adt_acid; |
---|
106 | ADT_UTIL complement_seq; |
---|
107 | ADT_UTIL invert_seq; |
---|
108 | ADT_UTIL seq_is_complemented; |
---|
109 | ADT_UTIL seq_is_inverted; |
---|
110 | ADT_UTIL take_cursor; |
---|
111 | ADT_UTIL take_borders; |
---|
112 | ADT_UTIL remove_gaps_points; |
---|
113 | ADT_BUTTON which_button; |
---|
114 | |
---|
115 | long alignment_length; |
---|
116 | long sequence_length; |
---|
117 | long left_border; |
---|
118 | long right_border; |
---|
119 | |
---|
120 | ADT_COMPLEMENT(void); |
---|
121 | ~ADT_COMPLEMENT(void); |
---|
122 | |
---|
123 | AD_ERR *complement_compile(void); //veraendert Zeichensatz |
---|
124 | AD_ERR *complement_buffers(void); //Puffer fuer Seq + Index |
---|
125 | |
---|
126 | }; |
---|
127 | |
---|
128 | |
---|
129 | /*************************************************************************** |
---|
130 | class ADT_EDIT |
---|
131 | |
---|
132 | ***************************************************************************/ |
---|
133 | |
---|
134 | class ADT_EDIT { |
---|
135 | friend class ADT_SEQUENCE; |
---|
136 | |
---|
137 | public: |
---|
138 | long selection; //Sequenz markiert |
---|
139 | long found_matchp; //Matchpattern gefunden? |
---|
140 | long actual_cursorpos_editor; |
---|
141 | long replace_overflow; |
---|
142 | long mistakes_found; //Anzahl gefundener Fehler |
---|
143 | long seq_equal_match; |
---|
144 | |
---|
145 | ADT_DB_STATUS db_status; |
---|
146 | ADT_UTIL border_overflow; |
---|
147 | |
---|
148 | ADT_EDIT(void); |
---|
149 | ~ADT_EDIT(void); |
---|
150 | |
---|
151 | }; |
---|
152 | |
---|
153 | |
---|
154 | /*************************************************************************** |
---|
155 | class ADT_SEARCH |
---|
156 | |
---|
157 | ***************************************************************************/ |
---|
158 | class ADT_SEARCH { |
---|
159 | friend class ADT_SEQUENCE; |
---|
160 | private: |
---|
161 | |
---|
162 | char *matchpattern_buffer; |
---|
163 | char *show_search_array(); |
---|
164 | char *search_array; |
---|
165 | char *save_sequence; // Sicherungskopie der Sequenz |
---|
166 | // fuer Fehlerfall bei Replace |
---|
167 | |
---|
168 | public: |
---|
169 | char *seq_anfang; // Sequenz oder Sequenz-Puffer |
---|
170 | long *seq_index_start; // Index-Puffer |
---|
171 | char *matchpattern; //? wildcard; |
---|
172 | // i'm the father of this string |
---|
173 | char *replace_string; // Replace String |
---|
174 | long mistakes_allowed; // Anzahl der beim Vergleich |
---|
175 | // Sequenz<->Matchpattern erlaubten |
---|
176 | // Fehler |
---|
177 | long gaps; //what about gaps |
---|
178 | long upper_eq_lower; //gross/KLEIN-Schreibung |
---|
179 | long t_equal_u; //t und u gleichbehandeln |
---|
180 | long search_start_cursor_pos; |
---|
181 | long replace_start_cursor_pos; |
---|
182 | |
---|
183 | ADT_SEARCH_DIRECTION search_direction; |
---|
184 | ADT_REPLACE_OPTION replace_option; |
---|
185 | ADT_REPLACE_LOOP replace_loop_sequence; |
---|
186 | |
---|
187 | ADT_SEARCH(void); |
---|
188 | ~ADT_SEARCH(void); |
---|
189 | |
---|
190 | AD_ERR *compile(void); //veraendert Zeichensatz |
---|
191 | |
---|
192 | long found_cursor_pos; //Stelle, ab der die Sequenz mit dem |
---|
193 | //Matchpattern unter Beruecksichtigung |
---|
194 | //der "erlaubten" Fehleranzahl ueber = |
---|
195 | //einstimmt. |
---|
196 | long string_replace; // 0 == kein String replaced, default; |
---|
197 | // 1 == String replaced; |
---|
198 | |
---|
199 | }; |
---|
200 | |
---|
201 | /*************************************************************************** |
---|
202 | class ADT_ALI |
---|
203 | |
---|
204 | ****************************************************************************/ |
---|
205 | |
---|
206 | class ADT_ALI : public AD_ALI { |
---|
207 | char *gapsequence; // realsequenz mit - an ausgeblendeten stellen |
---|
208 | int *gapshowoffset; // fuer umsetzung show -> realcoord |
---|
209 | int *gaprealoffset; |
---|
210 | int gapshowoffset_len; |
---|
211 | int inited; |
---|
212 | |
---|
213 | // es gilt: |
---|
214 | // showoffset[showoffset[showpos]] + showpos = realpos |
---|
215 | // realpos - gap[realoffset[realpos]] = showpos |
---|
216 | // fuer die gap verwaltung |
---|
217 | |
---|
218 | |
---|
219 | public: |
---|
220 | ~ADT_ALI(); |
---|
221 | ADT_ALI(); |
---|
222 | |
---|
223 | void init(AD_MAIN *ad_main); |
---|
224 | |
---|
225 | void gap_init(); |
---|
226 | AD_ERR *gap_make(int position,int len); |
---|
227 | AD_ERR *gap_delete(int showposition); |
---|
228 | AD_ERR *gap_update(char *oldseq,char *newseq); |
---|
229 | |
---|
230 | int gap_inside(int showposition1,int showposition2); |
---|
231 | int gap_inside(int realposition); |
---|
232 | int gap_behind(int showposition); |
---|
233 | int gap_realpos(int showposition); |
---|
234 | int gap_showpos(int realposition); |
---|
235 | |
---|
236 | |
---|
237 | char *gap_make_real_sequence(char *realseq,const char *showseq); |
---|
238 | char *gap_make_show_sequence(const char *realseq,char *showseq); |
---|
239 | void operator = (ADT_ALI& ); |
---|
240 | }; |
---|
241 | |
---|
242 | |
---|
243 | class ADT_SEARCH_REPLACE { |
---|
244 | friend class ADT_SEQUENCE; |
---|
245 | private: |
---|
246 | |
---|
247 | char *matchpattern_buffer; |
---|
248 | char *show_search_array(); |
---|
249 | char *search_array; |
---|
250 | char *save_sequence; // Sicherungskopie der Sequenz |
---|
251 | // fuer Fehlerfall bei Replace |
---|
252 | |
---|
253 | public: |
---|
254 | char *seq_anfang; // Sequenz oder Sequenz-Puffer |
---|
255 | long *seq_index_start; // Index-Puffer |
---|
256 | char *matchpattern; //? wildcard; |
---|
257 | // i'm the father of this string |
---|
258 | |
---|
259 | char *replace_string; // Replace String |
---|
260 | long mistakes_allowed; // Anzahl der beim Vergleich |
---|
261 | // Sequenz<->Matchpattern erlaubten |
---|
262 | // Fehler |
---|
263 | |
---|
264 | long gaps; //what about gaps |
---|
265 | long upper_eq_lower; //gross/KLEIN-Schreibung |
---|
266 | long t_equal_u; //t und u gleichbehandeln |
---|
267 | long search_start_cursor_pos; //Position, ab der die Suche in der |
---|
268 | //Sequenz gestartet wird. |
---|
269 | //search: actual_cursorpos_editor +/- 1; |
---|
270 | |
---|
271 | long replace_start_cursor_pos; //Position, ab der der Replace-String |
---|
272 | //in die Sequenz eingefuegt wird. |
---|
273 | //replace: actual_cursorpos_editor; |
---|
274 | |
---|
275 | |
---|
276 | |
---|
277 | ADT_SEARCH_DIRECTION search_direction; |
---|
278 | ADT_REPLACE_OPTION replace_option; |
---|
279 | ADT_REPLACE_LOOP replace_loop_sequence; |
---|
280 | |
---|
281 | ADT_SEARCH_REPLACE(void); |
---|
282 | ~ADT_SEARCH_REPLACE(void); |
---|
283 | |
---|
284 | AD_ERR *compile(void); //veraendert Zeichensatz |
---|
285 | |
---|
286 | |
---|
287 | long found_cursor_pos; //Stelle, ab der die Sequenz mit dem |
---|
288 | //Matchpattern unter Beruecksichtigung |
---|
289 | //der "erlaubten" Fehleranzahl ueber = |
---|
290 | //einstimmt. |
---|
291 | |
---|
292 | long string_replace; // 0 == kein String replaced, default; |
---|
293 | // 1 == String replaced; |
---|
294 | |
---|
295 | }; |
---|
296 | |
---|
297 | #define GAP_SYMBOL 80 // zeichen, ausser NULL |
---|
298 | #define NOGAP_SYMBOL 70 |
---|
299 | |
---|
300 | class ADT_SEQUENCE : public AD_SEQ { |
---|
301 | |
---|
302 | class ADT_ALI *adt_ali; |
---|
303 | int Cursorposition; |
---|
304 | long show_timestamp; |
---|
305 | |
---|
306 | AD_ERR *make_sequence_buffer(ADT_SEARCH *ptr_adt_search, ADT_EDIT *prt_adt_edit); |
---|
307 | AD_ERR *rewrite_from_sequence_buffer(ADT_SEARCH *ptr_adt_search, ADT_EDIT *prt_adt_edit); |
---|
308 | |
---|
309 | public: |
---|
310 | ADT_SEQUENCE(); |
---|
311 | ~ADT_SEQUENCE(); |
---|
312 | |
---|
313 | void init(ADT_ALI *adtali,AD_CONT * adcont); |
---|
314 | // SHOWSEQUENCEN |
---|
315 | void show_update(); // must be called after this->update |
---|
316 | int show_len(); |
---|
317 | char *show_get(); |
---|
318 | AD_ERR *show_put(); |
---|
319 | AD_ERR *show_insert(char *text,int position); |
---|
320 | AD_ERR *show_remove(int len,int position); |
---|
321 | AD_ERR *show_replace(char *text, int position); |
---|
322 | AD_ERR *show_command( AW_key_mod keymod, AW_key_code keycode, char key, int direction, long &cursorpos, int & changed_flag); |
---|
323 | |
---|
324 | AD_ERR *show_edit_seq_search(ADT_SEARCH *ptr_adt_search, ADT_EDIT *ptr_adt_edit); |
---|
325 | AD_ERR *show_edit_search(ADT_SEARCH *ptr_adt_search, ADT_EDIT *ptr_adt_edit); |
---|
326 | AD_ERR *show_edit_replace(ADT_SEARCH *ptr_adt_search, ADT_EDIT *ptr_adt_edit); |
---|
327 | AD_ERR *show_edit_seq_compl(ADT_COMPLEMENT *ptr_adt_complement, ADT_EDIT *ptr_adt_edit); |
---|
328 | AD_ERR *show_edit_complement(ADT_COMPLEMENT *ptr_adt_complement, ADT_EDIT *ptr_adt_edit); |
---|
329 | AD_ERR *show_edit_invert(ADT_COMPLEMENT *ptr_adt_complement, ADT_EDIT *ptr_adt_edit); |
---|
330 | |
---|
331 | }; |
---|
332 | |
---|
333 | #else |
---|
334 | #error adtools.hxx included twice |
---|
335 | #endif // ADTOOLS_HXX |
---|