1 | |
---|
2 | #include <stdio.h> |
---|
3 | #include <stdlib.h> |
---|
4 | #include <string.h> |
---|
5 | // #include <malloc.h> |
---|
6 | #include <memory.h> |
---|
7 | #include <arbdb.h> |
---|
8 | #include "arbdb++.hxx" |
---|
9 | #include "adtools.hxx" |
---|
10 | /*************************************************************************** |
---|
11 | class ADT_COMPLEMENT |
---|
12 | |
---|
13 | ***************************************************************************/ |
---|
14 | ADT_COMPLEMENT::ADT_COMPLEMENT() { |
---|
15 | // ad_species = NULL; |
---|
16 | species_name = NULL; |
---|
17 | alignment_type = NULL; |
---|
18 | alignment_name = NULL; |
---|
19 | sequence = NULL; |
---|
20 | char_array = NULL; |
---|
21 | sequence_buffer = NULL; |
---|
22 | index_buffer = NULL; |
---|
23 | |
---|
24 | adt_acid = ADT_ALITYPE_UNDEFINED; |
---|
25 | complement_seq = NO; |
---|
26 | invert_seq = NO; |
---|
27 | seq_is_complemented = NO; |
---|
28 | seq_is_inverted = NO; |
---|
29 | take_cursor = NO; |
---|
30 | take_borders = NO; |
---|
31 | remove_gaps_points = NO; |
---|
32 | which_button = NO_BUTTON; |
---|
33 | |
---|
34 | alignment_length = max_value; //max_value |
---|
35 | sequence_length = 0; |
---|
36 | left_border = 0; |
---|
37 | right_border = 0; |
---|
38 | |
---|
39 | } |
---|
40 | |
---|
41 | // ******************* |
---|
42 | ADT_COMPLEMENT::~ADT_COMPLEMENT() { |
---|
43 | // delete char_array; |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | // ******************* |
---|
49 | char * ADT_COMPLEMENT::make_char_array() |
---|
50 | { |
---|
51 | char *local_char_array = new char[256]; |
---|
52 | |
---|
53 | for( int i=0 ; i <= 255 ; i++ ) { |
---|
54 | local_char_array[i] = (char) i; |
---|
55 | } |
---|
56 | return local_char_array; |
---|
57 | } |
---|
58 | |
---|
59 | // ******************* |
---|
60 | AD_ERR * ADT_COMPLEMENT::complement_compile(void) { //Veraendert Zeichensatz |
---|
61 | |
---|
62 | delete char_array; |
---|
63 | char_array = make_char_array(); |
---|
64 | |
---|
65 | char_array[(int)'C'] = 'G'; |
---|
66 | char_array[(int)'c'] = 'g'; |
---|
67 | char_array[(int)'G'] = 'C'; |
---|
68 | char_array[(int)'g'] = 'c'; |
---|
69 | char_array[(int)'U'] = 'A'; |
---|
70 | char_array[(int)'u'] = 'a'; |
---|
71 | char_array[(int)'T'] = 'A'; |
---|
72 | char_array[(int)'t'] = 'a'; |
---|
73 | char_array[(int)'M'] = 'K'; |
---|
74 | char_array[(int)'m'] = 'k'; |
---|
75 | char_array[(int)'R'] = 'Y'; |
---|
76 | char_array[(int)'r'] = 'y'; |
---|
77 | // char_array[(int)'W'] = 'W'; //der Vollstaendigkeit halber |
---|
78 | // char_array[(int)'w'] = 'w'; //der Vollstaendigkeit halber |
---|
79 | // char_array[(int)'S'] = 'S'; //der Vollstaendigkeit halber |
---|
80 | // char_array[(int)'s'] = 's'; //der Vollstaendigkeit halber |
---|
81 | char_array[(int)'Y'] = 'R'; |
---|
82 | char_array[(int)'y'] = 'r'; |
---|
83 | char_array[(int)'K'] = 'M'; |
---|
84 | char_array[(int)'k'] = 'm'; |
---|
85 | char_array[(int)'V'] = 'B'; |
---|
86 | char_array[(int)'v'] = 'b'; |
---|
87 | char_array[(int)'H'] = 'D'; |
---|
88 | char_array[(int)'h'] = 'd'; |
---|
89 | char_array[(int)'D'] = 'H'; |
---|
90 | char_array[(int)'d'] = 'h'; |
---|
91 | char_array[(int)'B'] = 'V'; |
---|
92 | char_array[(int)'b'] = 'v'; |
---|
93 | // char_array[(int)'N'] = 'N'; //der Vollstaendigkeit halber |
---|
94 | // char_array[(int)'n'] = 'n'; //der Vollstaendigkeit halber |
---|
95 | // char_array[(int)'X'] = 'X'; //der Vollstaendigkeit halber |
---|
96 | // char_array[(int)'x'] = 'x'; //der Vollstaendigkeit halber |
---|
97 | // char_array[(int)'.'] = '.'; //der Vollstaendigkeit halber |
---|
98 | |
---|
99 | switch(adt_acid) { |
---|
100 | |
---|
101 | case ADT_ALITYPE_RNA: |
---|
102 | char_array[(int)'A'] = 'U'; |
---|
103 | char_array[(int)'a'] = 'u'; |
---|
104 | break; |
---|
105 | |
---|
106 | case ADT_ALITYPE_DNA: |
---|
107 | char_array[(int)'A'] = 'T'; |
---|
108 | char_array[(int)'a'] = 't'; |
---|
109 | break; |
---|
110 | default: |
---|
111 | break; |
---|
112 | } |
---|
113 | |
---|
114 | return 0; |
---|
115 | } |
---|
116 | |
---|
117 | // ******************* |
---|
118 | AD_ERR * ADT_COMPLEMENT::complement_buffers(void) { //Puffer fuer Seq + Index |
---|
119 | |
---|
120 | char *seq_buff; |
---|
121 | long *ind_buff; |
---|
122 | |
---|
123 | long buffer_len = 0; |
---|
124 | |
---|
125 | //buffer_len = (long)strlen(sequence); |
---|
126 | buffer_len = sequence_length; |
---|
127 | |
---|
128 | seq_buff = (char *)calloc( ((int)buffer_len + 1), sizeof(char) ); |
---|
129 | memset(seq_buff, (int)'.', ((int)buffer_len)); |
---|
130 | sequence_buffer = seq_buff; |
---|
131 | |
---|
132 | |
---|
133 | ind_buff = (long *) calloc( ((int)buffer_len + 1), sizeof(long) ); |
---|
134 | ind_buff[buffer_len] = -1; |
---|
135 | index_buffer = ind_buff; |
---|
136 | |
---|
137 | return 0; |
---|
138 | } |
---|
139 | |
---|
140 | |
---|
141 | |
---|
142 | /*************************************************************************** |
---|
143 | class ADT_EDIT |
---|
144 | |
---|
145 | ***************************************************************************/ |
---|
146 | ADT_EDIT::ADT_EDIT() { |
---|
147 | |
---|
148 | selection = 0; |
---|
149 | found_matchp = 0; |
---|
150 | actual_cursorpos_editor = -1; |
---|
151 | replace_overflow = 0; |
---|
152 | mistakes_found = 0; |
---|
153 | seq_equal_match = 1; |
---|
154 | |
---|
155 | db_status = ADT_DB_CLOSED; |
---|
156 | border_overflow = NO; |
---|
157 | } |
---|
158 | |
---|
159 | ADT_EDIT::~ADT_EDIT() { |
---|
160 | } |
---|
161 | |
---|
162 | |
---|
163 | /*************************************************************************** |
---|
164 | class ADT_SEARCH |
---|
165 | |
---|
166 | ***************************************************************************/ |
---|
167 | ADT_SEARCH::ADT_SEARCH() { |
---|
168 | |
---|
169 | seq_anfang = NULL; |
---|
170 | save_sequence = NULL; |
---|
171 | seq_index_start = NULL; |
---|
172 | matchpattern_buffer = NULL; |
---|
173 | search_array = NULL; |
---|
174 | replace_string = NULL; |
---|
175 | mistakes_allowed = 0; |
---|
176 | gaps = -1; //gaps werden nicht ignoriert |
---|
177 | upper_eq_lower = 0; //gross/KLEIN-Schreibung, |
---|
178 | t_equal_u = 0; //t und u gleichbehandeln, |
---|
179 | search_start_cursor_pos = 0; |
---|
180 | replace_start_cursor_pos = 0; |
---|
181 | search_direction = ADT_SEARCH_FORWARD; //Vorwaertssuche |
---|
182 | replace_option = ADT_NO_REPLACE; //Kein REPLACE |
---|
183 | replace_loop_sequence = ADT_DONT_STOPP_REPLACE; |
---|
184 | |
---|
185 | found_cursor_pos = 0; |
---|
186 | string_replace = 0; |
---|
187 | } |
---|
188 | |
---|
189 | ADT_SEARCH::~ADT_SEARCH() { |
---|
190 | delete search_array; |
---|
191 | delete matchpattern_buffer; |
---|
192 | } |
---|
193 | |
---|
194 | // ************************************* |
---|
195 | char * ADT_SEARCH::show_search_array() |
---|
196 | { |
---|
197 | search_array = new char[256]; |
---|
198 | |
---|
199 | for( int i=0 ; i <= 255 ; i++ ) { |
---|
200 | search_array[i] = (char) i; |
---|
201 | } |
---|
202 | return search_array; |
---|
203 | } |
---|
204 | |
---|
205 | // *********************************** |
---|
206 | //Veraendert Zeichensatz, Liefert Matchpattern ohne Gaps |
---|
207 | AD_ERR * ADT_SEARCH::compile(void) { |
---|
208 | delete search_array; |
---|
209 | search_array = show_search_array(); |
---|
210 | |
---|
211 | if(t_equal_u) { |
---|
212 | search_array[(int)'U'] = 'T'; |
---|
213 | search_array[(int)'u'] = 't'; |
---|
214 | } |
---|
215 | |
---|
216 | if(upper_eq_lower) { |
---|
217 | int char_pos; |
---|
218 | for( char_pos = 'a'; char_pos <= 'z' ; char_pos++) { |
---|
219 | search_array[char_pos] -= ( 'a' - 'A' ); |
---|
220 | } |
---|
221 | } |
---|
222 | |
---|
223 | ///////////////////////////////////Matchpattern WITHOUT gaps. |
---|
224 | if((gaps == 1) || (gaps == 2)) { |
---|
225 | delete matchpattern_buffer; |
---|
226 | matchpattern_buffer=(char *)calloc(strlen(matchpattern)+1,sizeof(char)); |
---|
227 | |
---|
228 | if(matchpattern_buffer != NULL) { |
---|
229 | char *matchp_copy_loop; |
---|
230 | char *matchp_buffer_start, *matchp_buffer_loop; |
---|
231 | |
---|
232 | matchp_buffer_start = matchp_buffer_loop = |
---|
233 | matchpattern_buffer; |
---|
234 | |
---|
235 | for( matchp_copy_loop = matchpattern ; |
---|
236 | *matchp_copy_loop != '\0' ; |
---|
237 | matchp_copy_loop++ ) { |
---|
238 | if(*matchp_copy_loop != '-') { |
---|
239 | *matchp_buffer_loop = *matchp_copy_loop; |
---|
240 | matchp_buffer_loop++; |
---|
241 | } |
---|
242 | } |
---|
243 | *matchp_buffer_loop = '\0'; |
---|
244 | matchpattern = matchp_buffer_start; |
---|
245 | } |
---|
246 | } |
---|
247 | return 0; |
---|
248 | } |
---|
249 | |
---|
250 | |
---|
251 | // ************************************************************************** |
---|
252 | // Funktion liefert die Sequenz entsprechend OHNE Gaps !!!! |
---|
253 | // (Sequenz wird ohne Gaps in ein Puffer-Array geschrieben, |
---|
254 | // => Pointer auf Sequenz-Puffer) |
---|
255 | // |
---|
256 | // ************************************************************************** |
---|
257 | AD_ERR * ADT_SEQUENCE::make_sequence_buffer(ADT_SEARCH |
---|
258 | *ptr_adt_search, ADT_EDIT *ptr_adt_edit) { |
---|
259 | |
---|
260 | //-------------------------------------------------start sequencebuffer |
---|
261 | char *seq_anfang, *seq_copy_loop; |
---|
262 | char *seq_buffer_start, *seq_buffer_loop; //buffer |
---|
263 | long *seq_index_start, *seq_index_loop; //index buffer |
---|
264 | |
---|
265 | seq_anfang = ptr_adt_search->seq_anfang; |
---|
266 | |
---|
267 | char source; |
---|
268 | |
---|
269 | //------------------------------------------memory for sequence-buffer |
---|
270 | seq_buffer_start = (char *)calloc(strlen(seq_anfang)+1,sizeof(char)); |
---|
271 | |
---|
272 | if (!seq_buffer_start) { |
---|
273 | // printf("\n**** ERROR sequence-buffer no memory allocated"); |
---|
274 | } |
---|
275 | seq_buffer_loop = seq_buffer_start; |
---|
276 | //------------------------------------------------------end seq_buffer |
---|
277 | |
---|
278 | //---------------------------------------------memory for index-buffer |
---|
279 | seq_index_start = (long *) calloc(strlen(seq_anfang)+1,sizeof(long)); |
---|
280 | |
---|
281 | if (!seq_index_start) { |
---|
282 | // printf("\n**** ERROR index-buffer no memory allocated"); |
---|
283 | } |
---|
284 | seq_index_loop = seq_index_start; |
---|
285 | //----------------------------------------------------end index_buffer |
---|
286 | |
---|
287 | for( seq_copy_loop = seq_anfang ; |
---|
288 | (source = *seq_copy_loop) ; |
---|
289 | seq_copy_loop++ ) { |
---|
290 | if(*seq_copy_loop != '-') { |
---|
291 | *(seq_buffer_loop++) = source; //kopiert Zeichen |
---|
292 | *(seq_index_loop++) = seq_copy_loop - seq_anfang; |
---|
293 | //Index des Zeichens |
---|
294 | } |
---|
295 | } |
---|
296 | *seq_buffer_loop = '\0'; |
---|
297 | *seq_index_loop = -1; |
---|
298 | ptr_adt_search->seq_anfang = seq_buffer_start; //SEQUENCE START |
---|
299 | //--------------------------------------------------end sequencebuffer |
---|
300 | |
---|
301 | // -------------------------------------neu search/replace cursorstart |
---|
302 | long var_cursorpos_editor = ptr_adt_edit->actual_cursorpos_editor; |
---|
303 | //========================!! |
---|
304 | // Fuer die Neuberechnung der Startpos. |
---|
305 | long buffer_index = 0; //zaehlvariable fuer |
---|
306 | //Cursorberechnung |
---|
307 | for( buffer_index = 0 ; |
---|
308 | (seq_index_start[buffer_index] < |
---|
309 | var_cursorpos_editor) && |
---|
310 | (seq_index_start[buffer_index] != -1 ) ; |
---|
311 | buffer_index++ ) { |
---|
312 | } |
---|
313 | // "buffer_index" |
---|
314 | //somit steht hier der Index, unter dessen |
---|
315 | //Adresse die Cursorposition steht, die |
---|
316 | //entweder groesser (Cursor stand auf einem GAP) |
---|
317 | //oder gleich (Cursor stand auf einem Zeichen) |
---|
318 | //der Cursorpos im Editor ist, vielmehr war. |
---|
319 | |
---|
320 | if( ptr_adt_search->search_direction == ADT_SEARCH_FORWARD) { |
---|
321 | if( (seq_index_start[buffer_index] == var_cursorpos_editor) && |
---|
322 | (var_cursorpos_editor > 0) ) { |
---|
323 | ptr_adt_search->search_start_cursor_pos = |
---|
324 | buffer_index + 1; |
---|
325 | } |
---|
326 | else { |
---|
327 | ptr_adt_search->search_start_cursor_pos = |
---|
328 | buffer_index; |
---|
329 | } |
---|
330 | } // end if |
---|
331 | else { |
---|
332 | ptr_adt_search->search_start_cursor_pos = buffer_index - 1; |
---|
333 | } // end else |
---|
334 | delete ptr_adt_search->seq_index_start; |
---|
335 | ptr_adt_search->seq_index_start = seq_index_start; //indexarray |
---|
336 | ptr_adt_edit->actual_cursorpos_editor = buffer_index; |
---|
337 | //----------------------------------------------------end cursorstart |
---|
338 | |
---|
339 | return 0; |
---|
340 | } |
---|
341 | // ************************************************************************** |
---|
342 | |
---|
343 | |
---|
344 | |
---|
345 | // ************************************************************************** |
---|
346 | // |
---|
347 | // ************************************************************************** |
---|
348 | AD_ERR * ADT_SEQUENCE::rewrite_from_sequence_buffer(ADT_SEARCH |
---|
349 | *ptr_adt_search, ADT_EDIT *ptr_adt_edit) { |
---|
350 | |
---|
351 | char *seq_anfang; //Sequenz |
---|
352 | char *seq_buffer_start; //Sequenz ohne GAPS |
---|
353 | long *seq_index_start; //index buffer, siehe unten! |
---|
354 | long found_cursor_pos_buffer = ptr_adt_search->found_cursor_pos; |
---|
355 | |
---|
356 | //--------------------------------found_cursor_pos nach Suche ohne Gaps |
---|
357 | if (( ptr_adt_edit->found_matchp == 1 ) && |
---|
358 | ( ptr_adt_search->replace_option == ADT_NO_REPLACE )) { |
---|
359 | ptr_adt_search->found_cursor_pos = |
---|
360 | ptr_adt_search->seq_index_start[found_cursor_pos_buffer]; |
---|
361 | } |
---|
362 | //-------------------------------------------------END found_cursor_pos |
---|
363 | |
---|
364 | //---------------------------------------rewrite Seq-Puffer auf Sequenz |
---|
365 | if( ptr_adt_search->replace_option != ADT_NO_REPLACE ) { |
---|
366 | seq_buffer_start = ptr_adt_search->seq_anfang; |
---|
367 | seq_index_start = ptr_adt_search->seq_index_start; |
---|
368 | seq_anfang = get(); |
---|
369 | |
---|
370 | long buffer_index = 0; //zaehlvariable |
---|
371 | char source; |
---|
372 | |
---|
373 | for( ; (source = seq_buffer_start[buffer_index]) ; buffer_index++ ) { |
---|
374 | *(seq_anfang + seq_index_start[buffer_index]) = source; |
---|
375 | } |
---|
376 | ptr_adt_search->seq_anfang = seq_anfang; |
---|
377 | //-------------------------------------------------end rewrite |
---|
378 | |
---|
379 | char *replace_anfang = ptr_adt_search->replace_string; |
---|
380 | long var_start_cursor_pos = ptr_adt_search->replace_start_cursor_pos; |
---|
381 | |
---|
382 | //--------------------------------------------cursorpos_editor |
---|
383 | long buffer_end_replace = var_start_cursor_pos + strlen(replace_anfang); |
---|
384 | |
---|
385 | ptr_adt_edit->actual_cursorpos_editor = |
---|
386 | ptr_adt_search->seq_index_start[buffer_end_replace-1]; |
---|
387 | // nur bei Suchrichtung |
---|
388 | // "Vorwaerts" !!! |
---|
389 | //----------------------------------------end cursorpos_editor |
---|
390 | |
---|
391 | free(seq_buffer_start); |
---|
392 | ptr_adt_search->seq_anfang = NULL; |
---|
393 | free((char *)seq_index_start); |
---|
394 | ptr_adt_search->seq_index_start = NULL; |
---|
395 | |
---|
396 | } |
---|
397 | //--------------------------------------------------------END rewrite |
---|
398 | |
---|
399 | return 0; |
---|
400 | } |
---|
401 | //-----------------------------------------END rewrite_from_sequence_buffer() |
---|
402 | // ************************************************************************** |
---|
403 | |
---|
404 | |
---|
405 | |
---|
406 | |
---|
407 | // ************************************************************************** |
---|
408 | // |
---|
409 | // ************************************************************************** |
---|
410 | AD_ERR * ADT_SEQUENCE::show_edit_seq_search(ADT_SEARCH *ptr_adt_search, |
---|
411 | ADT_EDIT *ptr_adt_edit) { |
---|
412 | AD_ERR *ad_err; |
---|
413 | |
---|
414 | long replace_loop = ADT_DONT_STOPP_REPLACE; //default |
---|
415 | // ADT_DONT_STOPP_REPLACE == 1 !! |
---|
416 | |
---|
417 | ptr_adt_search->seq_anfang = get(); |
---|
418 | |
---|
419 | |
---|
420 | // Sicherheitsabfrage fuer die |
---|
421 | // Rueckwaertssuche !! |
---|
422 | if(ptr_adt_search->search_start_cursor_pos > len()) { |
---|
423 | //Cursorpos > Sequenzlaenge? |
---|
424 | ptr_adt_search->search_start_cursor_pos = len() - 1; |
---|
425 | } |
---|
426 | |
---|
427 | //-----------------------------------------------------Sequenz puffern |
---|
428 | if( (ptr_adt_search->gaps == 0) || (ptr_adt_search->gaps == 1) ) { |
---|
429 | make_sequence_buffer(ptr_adt_search, ptr_adt_edit); |
---|
430 | /////////////////////////////////////////////////// |
---|
431 | } //end if, >>Sequenz<< OHNE Gaps. |
---|
432 | //---------------------------------------------------- end seq puffern |
---|
433 | |
---|
434 | //---------------------------------Sicherungskopie der Seq fuer REPLACE |
---|
435 | if( ptr_adt_search->replace_option != ADT_NO_REPLACE ) { |
---|
436 | ptr_adt_search->save_sequence = strdup(ptr_adt_search->seq_anfang); |
---|
437 | } |
---|
438 | //--------------------------------------------------END Sicherungskopie |
---|
439 | |
---|
440 | //---------------------------------------korrigiert die Start Cursorpos |
---|
441 | // bis Ende.., da erst search(), dann replace() |
---|
442 | if( ( (ptr_adt_search->replace_option == ADT_REPLACE_ONLY) || |
---|
443 | (ptr_adt_search->replace_option == ADT_REPLACE_AND_SEARCH_NEXT)|| |
---|
444 | (ptr_adt_search->replace_option == ADT_REPLACE_REST_SEQUENCE)|| |
---|
445 | (ptr_adt_search->replace_option == ADT_REPLACE_REST_EDITOR) ) && |
---|
446 | (ptr_adt_search->search_start_cursor_pos > 0) ) { |
---|
447 | |
---|
448 | ptr_adt_search->search_start_cursor_pos--; |
---|
449 | } |
---|
450 | //----------------------------------------------------END start_cursor |
---|
451 | |
---|
452 | //==================================================================== |
---|
453 | //=================================================while(replace_loop) |
---|
454 | long max_loop = this->seq_len; |
---|
455 | do { // END Sequenz/Editor |
---|
456 | |
---|
457 | //------------------------------------------------------SEARCH |
---|
458 | ptr_adt_edit->found_matchp = 0; |
---|
459 | |
---|
460 | show_edit_search(ptr_adt_search, ptr_adt_edit); |
---|
461 | ////////////////////////////////////////////// |
---|
462 | //------------------------------------------------- END SEARCH |
---|
463 | |
---|
464 | if( ((ptr_adt_search->replace_option == ADT_REPLACE_ONLY) || |
---|
465 | (ptr_adt_search->replace_option == ADT_REPLACE_AND_SEARCH_NEXT)) && |
---|
466 | (ptr_adt_edit->found_matchp == 0) ) { |
---|
467 | ptr_adt_edit->seq_equal_match = 0; |
---|
468 | ptr_adt_edit->found_matchp = 1; |
---|
469 | return 0; |
---|
470 | } // end if ( ... == ADT_REPLACE_ONLY) |
---|
471 | |
---|
472 | else { |
---|
473 | ptr_adt_search->replace_start_cursor_pos = |
---|
474 | ptr_adt_search->found_cursor_pos; |
---|
475 | } |
---|
476 | |
---|
477 | //---------------------------------------------------- REPLACE |
---|
478 | if( (ptr_adt_edit->found_matchp == 1) && |
---|
479 | (ptr_adt_search->replace_option != ADT_NO_REPLACE) ) { |
---|
480 | |
---|
481 | ad_err = show_edit_replace(ptr_adt_search,ptr_adt_edit); |
---|
482 | ////////////////////////////////////////////// |
---|
483 | if(ad_err) return ad_err; |
---|
484 | } |
---|
485 | //-------------------------------------------------END REPLACE |
---|
486 | |
---|
487 | //------------------------------------------repl and find next |
---|
488 | if( (ptr_adt_search->replace_option == ADT_REPLACE_AND_SEARCH_NEXT) && |
---|
489 | (ptr_adt_search->string_replace == 1) ) { |
---|
490 | ptr_adt_search->string_replace = 0; |
---|
491 | ptr_adt_search->search_start_cursor_pos = |
---|
492 | ptr_adt_edit->actual_cursorpos_editor + 1; |
---|
493 | ptr_adt_search->replace_option = ADT_NO_REPLACE; |
---|
494 | } |
---|
495 | //---------end repl/find next |
---|
496 | else { |
---|
497 | if( (ptr_adt_search->replace_option == ADT_REPLACE_REST_SEQUENCE) || |
---|
498 | (ptr_adt_search->replace_option == ADT_REPLACE_REST_EDITOR) ) { |
---|
499 | |
---|
500 | replace_loop = ptr_adt_search->replace_loop_sequence; |
---|
501 | ptr_adt_search->search_start_cursor_pos = |
---|
502 | ( ptr_adt_edit->actual_cursorpos_editor + 1 ); |
---|
503 | |
---|
504 | // ABBRECHEN, sonst naechste Sequenz |
---|
505 | if( replace_loop == ADT_STOPP_REPLACE ) { |
---|
506 | ptr_adt_edit->found_matchp = 1; |
---|
507 | } |
---|
508 | if (max_loop-- <0) replace_loop = ADT_STOPP_REPLACE; |
---|
509 | } else { |
---|
510 | replace_loop = ADT_STOPP_REPLACE; |
---|
511 | } |
---|
512 | } |
---|
513 | |
---|
514 | } while(replace_loop); |
---|
515 | //============================================================end loop |
---|
516 | //==================================================================== |
---|
517 | |
---|
518 | delete ptr_adt_search->save_sequence; //Sicherungskopie loeschen |
---|
519 | |
---|
520 | //-----------------------------------------Zurueckschreiben aus Puffer |
---|
521 | if( (ptr_adt_search->gaps == 0) || (ptr_adt_search->gaps == 1) ) { |
---|
522 | rewrite_from_sequence_buffer(ptr_adt_search, ptr_adt_edit); |
---|
523 | ///////////////////////////////////////////// |
---|
524 | } //end if, >>Sequenz<< OHNE Gaps. |
---|
525 | //---------------------------------------------------------end rewrite |
---|
526 | |
---|
527 | //----------------------------------- zurueckschreiben in die Datenbank |
---|
528 | if( (ptr_adt_search->string_replace == 1) || |
---|
529 | (ptr_adt_edit->db_status == ADT_DB_OPEN) ) { |
---|
530 | ad_err = put(); |
---|
531 | if(ad_err) { |
---|
532 | // printf("**** ERROR ADT_SEARCH show_edit_replace(), put() \n"); |
---|
533 | return ad_err; |
---|
534 | } |
---|
535 | |
---|
536 | show_update(); |
---|
537 | } |
---|
538 | //---------------------------------------------------end write into DB |
---|
539 | |
---|
540 | if( (ptr_adt_edit->found_matchp == 1) && |
---|
541 | (ptr_adt_search->string_replace == 0) ) { |
---|
542 | ptr_adt_edit->actual_cursorpos_editor = |
---|
543 | ptr_adt_search->found_cursor_pos; |
---|
544 | } |
---|
545 | |
---|
546 | // nichts gefunden, |
---|
547 | //---------------------------------- cursorpos in next sequence |
---|
548 | if( (ptr_adt_edit->found_matchp == 0) || |
---|
549 | (ptr_adt_search->replace_option == ADT_REPLACE_REST_EDITOR) ) { |
---|
550 | if( ptr_adt_search->search_direction == ADT_SEARCH_FORWARD ) { |
---|
551 | ptr_adt_edit->actual_cursorpos_editor = 0; |
---|
552 | ptr_adt_search->search_start_cursor_pos = 0; |
---|
553 | //startet naechste Seq bei Cursorpos = 0 |
---|
554 | } |
---|
555 | if( ptr_adt_search->search_direction == ADT_SEARCH_BACKWARD ) { |
---|
556 | ptr_adt_edit->actual_cursorpos_editor = max_value; |
---|
557 | ptr_adt_search->search_start_cursor_pos = max_value; |
---|
558 | } |
---|
559 | } |
---|
560 | //-------------------------------end cursorpos in next sequence |
---|
561 | |
---|
562 | return 0; |
---|
563 | } // end func show_edit_seq_search() |
---|
564 | |
---|
565 | // ************************************************************************** |
---|
566 | |
---|
567 | |
---|
568 | |
---|
569 | |
---|
570 | // ************************************************************************** |
---|
571 | // |
---|
572 | // ************************************************************************** |
---|
573 | AD_ERR * ADT_SEQUENCE::show_edit_search(ADT_SEARCH *ptr_adt_search, |
---|
574 | ADT_EDIT *ptr_adt_edit) { |
---|
575 | |
---|
576 | char *seq_anfang, *seq_loop_start, *seq_loop_ptr; // Suche Sequenz |
---|
577 | char *matchp_anfang, *matchp_loop_ptr; // Suche |
---|
578 | // Matchpattern |
---|
579 | |
---|
580 | long matchp_len; |
---|
581 | long vorgabefehler, realfehler=0, equal_chars; |
---|
582 | long seq_empty_var; |
---|
583 | long search_var; |
---|
584 | |
---|
585 | search_var = ptr_adt_search->search_direction; |
---|
586 | |
---|
587 | matchp_anfang = ptr_adt_search->matchpattern; |
---|
588 | matchp_len = strlen(matchp_anfang); |
---|
589 | |
---|
590 | seq_empty_var=0; |
---|
591 | vorgabefehler = ptr_adt_search->mistakes_allowed; |
---|
592 | |
---|
593 | seq_anfang = ptr_adt_search->seq_anfang; |
---|
594 | long var_start_cursor_pos = ptr_adt_search->search_start_cursor_pos; |
---|
595 | |
---|
596 | seq_loop_start = seq_anfang + var_start_cursor_pos; |
---|
597 | |
---|
598 | //---------------------------------------------------------start search |
---|
599 | for( ; (*seq_loop_start != '\0') && |
---|
600 | (seq_loop_start >= seq_anfang) ; |
---|
601 | seq_loop_start+=search_var ) { |
---|
602 | realfehler = 0; |
---|
603 | equal_chars = 0; |
---|
604 | seq_loop_ptr=seq_loop_start; |
---|
605 | |
---|
606 | for( matchp_loop_ptr=matchp_anfang ; *matchp_loop_ptr != '\0' ; |
---|
607 | matchp_loop_ptr++ ) { |
---|
608 | |
---|
609 | unsigned char index_seq = *(unsigned char *)seq_loop_ptr; |
---|
610 | unsigned char index_mat=*(unsigned char*)matchp_loop_ptr; |
---|
611 | char i_s = ptr_adt_search->search_array[(int)index_seq]; |
---|
612 | char i_m = ptr_adt_search->search_array[(int)index_mat]; |
---|
613 | if( i_m == '?' ) { // Wilde Karten |
---|
614 | equal_chars++; |
---|
615 | } |
---|
616 | |
---|
617 | else if( i_s != i_m ) { |
---|
618 | realfehler++; |
---|
619 | } |
---|
620 | else { |
---|
621 | equal_chars++; |
---|
622 | } |
---|
623 | // mehr Fehler als erlaubt? |
---|
624 | if(realfehler > vorgabefehler) { |
---|
625 | ptr_adt_edit->found_matchp = 0; |
---|
626 | break; |
---|
627 | } |
---|
628 | //gefunden? (noetig, da Restsequenz |
---|
629 | //kuerzer |
---|
630 | //als Suchstringlaenge sein kann.) |
---|
631 | //Fehler + Uebereinstimmungen = Laenge |
---|
632 | //des Matchpatterns |
---|
633 | if(realfehler+equal_chars == matchp_len) { |
---|
634 | ptr_adt_edit->found_matchp = 1; |
---|
635 | ptr_adt_edit->mistakes_found = realfehler; |
---|
636 | break; |
---|
637 | } |
---|
638 | |
---|
639 | seq_loop_ptr++; // Ende der Sequenz erreicht? |
---|
640 | if( *seq_loop_ptr == '\0') { // |
---|
641 | seq_empty_var = 1; |
---|
642 | break; |
---|
643 | } |
---|
644 | |
---|
645 | } // end for() |
---|
646 | |
---|
647 | if( *(seq_loop_ptr+1) == '\0') { |
---|
648 | ptr_adt_search->replace_loop_sequence = |
---|
649 | ADT_STOPP_REPLACE; |
---|
650 | } |
---|
651 | //----------------------------------------search end found y/n |
---|
652 | |
---|
653 | //---------------------------------found cursorpos in sequence |
---|
654 | if( ptr_adt_edit->found_matchp == 1) { |
---|
655 | ptr_adt_search->found_cursor_pos = |
---|
656 | seq_loop_start - seq_anfang; |
---|
657 | break; |
---|
658 | } |
---|
659 | //-----------------------------------end cursorpos in sequence |
---|
660 | |
---|
661 | if( (ptr_adt_search->replace_option == ADT_REPLACE_ONLY) || |
---|
662 | (ptr_adt_search->replace_option == |
---|
663 | ADT_REPLACE_AND_SEARCH_NEXT)) { |
---|
664 | break; //for schleife nur einmal ausfuehren. |
---|
665 | } |
---|
666 | } // end for() |
---|
667 | //----------------------------------------------------------end search |
---|
668 | |
---|
669 | return 0; |
---|
670 | } |
---|
671 | // ************************************************************************** |
---|
672 | |
---|
673 | |
---|
674 | |
---|
675 | |
---|
676 | // ************************************************************************** |
---|
677 | // |
---|
678 | // Ueberprueft zuerst, ob die Sequenz ab der Cursorposition mit dem |
---|
679 | // Matchpattern uebereinstimmt. Wenn ja, dann erfolgt die Ersetzung. |
---|
680 | // Mit GAPS: durch remove(), und insert() der AD_SEQ-Klasse; |
---|
681 | // Ohne Gaps: direktes ueberschreiben im Sequenzpuffer, danach |
---|
682 | // ueberschreiben der Sequenzkopie im Cache. |
---|
683 | // Beide Varianten schreiben die geaenderte Sequenz mittels put() in |
---|
684 | // die Datenbank zurueck. (Security-Level nicht vergessen!!) |
---|
685 | // |
---|
686 | // ************************************************************************** |
---|
687 | AD_ERR * ADT_SEQUENCE::show_edit_replace(ADT_SEARCH *ptr_adt_search, |
---|
688 | ADT_EDIT *ptr_adt_edit) |
---|
689 | |
---|
690 | { |
---|
691 | char *seq_anfang, *seq_loop_start, *seq_loop_ptr; // Sequenz |
---|
692 | char *matchp_anfang; |
---|
693 | char *replace_anfang, *replace_loop_ptr; // Replace-String |
---|
694 | AD_ERR *ad_err; |
---|
695 | |
---|
696 | matchp_anfang = ptr_adt_search->matchpattern; |
---|
697 | replace_anfang = ptr_adt_search->replace_string; |
---|
698 | seq_anfang = ptr_adt_search->seq_anfang; |
---|
699 | |
---|
700 | ptr_adt_search->string_replace = 0; |
---|
701 | long var_start_cursor_pos = |
---|
702 | ptr_adt_search->replace_start_cursor_pos; |
---|
703 | |
---|
704 | seq_loop_start = seq_anfang + var_start_cursor_pos; |
---|
705 | seq_loop_ptr = seq_loop_start; |
---|
706 | |
---|
707 | //============================================================REPLACE |
---|
708 | |
---|
709 | long match_len = strlen(ptr_adt_search->matchpattern); |
---|
710 | long replace_len = strlen(ptr_adt_search->replace_string); |
---|
711 | |
---|
712 | if( (match_len == replace_len) || |
---|
713 | (ptr_adt_search->gaps == 0) || (ptr_adt_search->gaps == 1) ) { |
---|
714 | |
---|
715 | //----------------------------------------------------replace |
---|
716 | seq_loop_ptr = seq_loop_start; |
---|
717 | for( replace_loop_ptr = replace_anfang ; |
---|
718 | *replace_loop_ptr != '\0' ; replace_loop_ptr++ ) { |
---|
719 | *seq_loop_ptr = *replace_loop_ptr; |
---|
720 | seq_loop_ptr++; |
---|
721 | } // end for() |
---|
722 | } // end if(match_len == replace_len) |
---|
723 | |
---|
724 | else { |
---|
725 | //-----------------------------------------------------remove |
---|
726 | ad_err = remove( strlen(matchp_anfang), |
---|
727 | (int)var_start_cursor_pos,1 ); |
---|
728 | if (ad_err) { // Fehler bei remove |
---|
729 | replace(ptr_adt_search->save_sequence,0,1); |
---|
730 | // printf("**** ERROR REPLACE remove() with GAPS\n"); |
---|
731 | free(ptr_adt_search->save_sequence); |
---|
732 | return ad_err; |
---|
733 | } |
---|
734 | |
---|
735 | //-----------------------------------------------------insert |
---|
736 | else if( strlen(replace_anfang) != 0 ){ |
---|
737 | ad_err = insert( replace_anfang, |
---|
738 | (int)var_start_cursor_pos ,1 ); |
---|
739 | |
---|
740 | if (ad_err) { // Fehler bei replace |
---|
741 | replace(ptr_adt_search->save_sequence,0,1); |
---|
742 | // printf("**** ERROR REPLACE insert() with GAPS\n"); |
---|
743 | free(ptr_adt_search->save_sequence); |
---|
744 | return ad_err; |
---|
745 | } |
---|
746 | ptr_adt_search->seq_anfang = get(); |
---|
747 | } |
---|
748 | } |
---|
749 | //========================================================END REPLACE |
---|
750 | //-------------------------------------------------- Cursorpos Editor |
---|
751 | ptr_adt_edit->actual_cursorpos_editor = |
---|
752 | ptr_adt_search->replace_start_cursor_pos + |
---|
753 | strlen(replace_anfang) - 1; |
---|
754 | //-----------------------------------------------------END Cursorpos |
---|
755 | |
---|
756 | ptr_adt_search->string_replace = 1; //wir haben replaced! |
---|
757 | return 0; |
---|
758 | |
---|
759 | } // end fkt show_edit_replace() |
---|
760 | // ************************************************************************* |
---|
761 | |
---|
762 | |
---|
763 | |
---|
764 | |
---|
765 | // ************************************************************************* |
---|
766 | // Invert/Complement - Haelt und arbeitet auf der Sequenz |
---|
767 | // ************************************************************************* |
---|
768 | AD_ERR * ADT_SEQUENCE::show_edit_seq_compl( |
---|
769 | ADT_COMPLEMENT *ptr_adt_complement, ADT_EDIT *ptr_adt_edit) { |
---|
770 | |
---|
771 | AD_ERR *ad_err; |
---|
772 | |
---|
773 | ptr_adt_complement->sequence = get(); |
---|
774 | |
---|
775 | ptr_adt_complement->sequence_length = |
---|
776 | (long)strlen(ptr_adt_complement->sequence); |
---|
777 | |
---|
778 | //-------------------------------------------------------- border check |
---|
779 | if( ptr_adt_complement->take_borders == YES ) { |
---|
780 | if( (ptr_adt_complement->sequence_length - 1) < |
---|
781 | ptr_adt_complement->right_border ) { |
---|
782 | ptr_adt_complement->right_border = |
---|
783 | ptr_adt_complement->sequence_length - 1; |
---|
784 | } |
---|
785 | if( (ptr_adt_complement->sequence_length - 1) < |
---|
786 | ptr_adt_complement->left_border ) { |
---|
787 | return 0; |
---|
788 | } |
---|
789 | } |
---|
790 | //---------------------------------------------------- end border check |
---|
791 | |
---|
792 | //-----------------------------------------------------fct complement() |
---|
793 | if( ptr_adt_complement->complement_seq == YES ) { |
---|
794 | show_edit_complement(ptr_adt_complement, ptr_adt_edit); |
---|
795 | // ***************************************************** |
---|
796 | } |
---|
797 | //-------------------------------------------------end fct complement() |
---|
798 | |
---|
799 | //---------------------------------------------------------fct invert() |
---|
800 | if( ptr_adt_complement->invert_seq == YES ) { |
---|
801 | show_edit_invert(ptr_adt_complement, ptr_adt_edit); |
---|
802 | // ***************************************************** |
---|
803 | } |
---|
804 | //-----------------------------------------------------end fct invert() |
---|
805 | |
---|
806 | if( (ptr_adt_complement->seq_is_complemented == YES) || |
---|
807 | (ptr_adt_complement->seq_is_inverted == YES) ) { |
---|
808 | ptr_adt_edit->actual_cursorpos_editor = 0; |
---|
809 | } |
---|
810 | |
---|
811 | //----------------------------------- zurueckschreiben in die Datenbank |
---|
812 | if( ptr_adt_edit->db_status == ADT_DB_OPEN ) { |
---|
813 | ad_err = put(); |
---|
814 | if(ad_err) { |
---|
815 | // printf("**** ERROR ADT_COMPLEMENT, no rewrite into DB\n"); |
---|
816 | return ad_err; |
---|
817 | } |
---|
818 | |
---|
819 | show_update(); |
---|
820 | } |
---|
821 | //---------------------------------------------------end write into DB |
---|
822 | |
---|
823 | //---------------------------------------------------------------------------- |
---|
824 | //testen |
---|
825 | #if 0 |
---|
826 | char* seq_loop = ptr_adt_complement->sequence; |
---|
827 | printf("\n================================================================\n"); |
---|
828 | printf("Species-name: %s\n", ptr_adt_complement->species_name ); |
---|
829 | printf("Alignment-type: %s == %d\n", ptr_adt_complement->alignment_type, |
---|
830 | ptr_adt_complement->adt_acid); |
---|
831 | printf("Alignment-name: %s\n", ptr_adt_complement->alignment_name ); |
---|
832 | printf("SEQUENCE:\n"); |
---|
833 | //printf("SEQUENCE: (ab Cursorpos 200)\n"); |
---|
834 | //seq_loop+=200; |
---|
835 | for(int k=0; (k<100) && (*seq_loop); k++) { |
---|
836 | printf("%c", *seq_loop); |
---|
837 | seq_loop++; |
---|
838 | } |
---|
839 | printf("\n"); |
---|
840 | printf("alignment_length: %d\n", ptr_adt_complement->alignment_length ); |
---|
841 | printf("Borders [left..right]: [%d .. %d]\n", |
---|
842 | ptr_adt_complement->left_border, ptr_adt_complement->right_border ); |
---|
843 | printf("seq_is_complemented: %d\n", ptr_adt_complement->seq_is_complemented ); |
---|
844 | printf("seq_is_inverted: %d\n", ptr_adt_complement->seq_is_inverted ); |
---|
845 | printf("which_button: %d\n", ptr_adt_complement->which_button ); |
---|
846 | #endif |
---|
847 | //end test |
---|
848 | //--------------------------------------------------------------------------- |
---|
849 | return 0; |
---|
850 | |
---|
851 | } // end show_edit_seq_compl() |
---|
852 | // ************************************************************************* |
---|
853 | |
---|
854 | |
---|
855 | |
---|
856 | |
---|
857 | // ************************************************************************* |
---|
858 | // Fkt bildet das Complement |
---|
859 | // ************************************************************************* |
---|
860 | |
---|
861 | AD_ERR * ADT_SEQUENCE::show_edit_complement(ADT_COMPLEMENT *ptr_adt_complement, |
---|
862 | ADT_EDIT *ptr_adt_edit) { |
---|
863 | char *seq_start, *right_border; |
---|
864 | char *compl_start, *compl_loop; |
---|
865 | |
---|
866 | seq_start = ptr_adt_complement->sequence; |
---|
867 | compl_start = ptr_adt_complement->sequence; //vorbelegung |
---|
868 | |
---|
869 | right_border = seq_start + max_value; |
---|
870 | //--------------------------------------------------------ab Cursorpos |
---|
871 | if(ptr_adt_complement->take_cursor == YES) { |
---|
872 | compl_start = seq_start + ptr_adt_edit->actual_cursorpos_editor; |
---|
873 | } |
---|
874 | //-------------------------------------------------------end Cursorpos |
---|
875 | |
---|
876 | //-----------------------------------------------------------Intervall |
---|
877 | if(ptr_adt_complement->take_borders == YES) { |
---|
878 | compl_start = seq_start + ptr_adt_complement->left_border; |
---|
879 | right_border = seq_start + ptr_adt_complement->right_border; |
---|
880 | } |
---|
881 | //-------------------------------------------------------end Intervall |
---|
882 | |
---|
883 | //-------------------------------------------------erledigt complement |
---|
884 | for( compl_loop = compl_start; |
---|
885 | (*compl_loop) && (compl_loop <= right_border) ; compl_loop++ ) { |
---|
886 | *compl_loop = ptr_adt_complement->char_array[(int)*compl_loop]; |
---|
887 | } |
---|
888 | ptr_adt_complement->seq_is_complemented = YES; |
---|
889 | //------------------------------------------------------end complement |
---|
890 | |
---|
891 | return 0; |
---|
892 | |
---|
893 | } // end fct show_edit_complement() |
---|
894 | // ************************************************************************* |
---|
895 | |
---|
896 | |
---|
897 | |
---|
898 | // ************************************************************************* |
---|
899 | // Fkt fuehrt Invertierung durch ( = REVERT ) |
---|
900 | // ************************************************************************* |
---|
901 | |
---|
902 | AD_ERR * ADT_SEQUENCE::show_edit_invert(ADT_COMPLEMENT *ptr_adt_complement, |
---|
903 | ADT_EDIT *ptr_adt_edit) { |
---|
904 | char source; |
---|
905 | |
---|
906 | char *right_border; |
---|
907 | char *sequence_loop_start, *sequence_loop, *sequence; |
---|
908 | char *seq_buffer, *seq_buffer_loop_start, *seq_buffer_loop; |
---|
909 | long *index_buffer, *index_buffer_loop_start, *index_buffer_loop; |
---|
910 | |
---|
911 | long char_counter = 0; |
---|
912 | |
---|
913 | sequence = ptr_adt_complement->sequence; |
---|
914 | right_border = sequence + max_value; |
---|
915 | |
---|
916 | //------------------------------------------------------ make Seq/Puffer |
---|
917 | ptr_adt_complement->complement_buffers(); |
---|
918 | //-------------------------------------------------- end make Seq/Puffer |
---|
919 | |
---|
920 | seq_buffer = ptr_adt_complement->sequence_buffer; |
---|
921 | index_buffer = ptr_adt_complement->index_buffer; |
---|
922 | |
---|
923 | sequence_loop_start = sequence; |
---|
924 | seq_buffer_loop_start = seq_buffer; |
---|
925 | index_buffer_loop_start = index_buffer; |
---|
926 | |
---|
927 | //--------------------------------------------------------ab Cursorpos |
---|
928 | if( ptr_adt_complement->take_cursor == YES ) { |
---|
929 | sequence_loop_start += ptr_adt_edit->actual_cursorpos_editor; |
---|
930 | seq_buffer_loop_start += ptr_adt_edit->actual_cursorpos_editor; |
---|
931 | index_buffer_loop_start += ptr_adt_edit->actual_cursorpos_editor; |
---|
932 | } |
---|
933 | //-------------------------------------------------------end Cursorpos |
---|
934 | |
---|
935 | //------------------------------------------------------- take Borders |
---|
936 | if( ptr_adt_complement->take_borders == YES ) { |
---|
937 | sequence_loop_start += ptr_adt_complement->left_border; |
---|
938 | seq_buffer_loop_start += ptr_adt_complement->left_border; |
---|
939 | index_buffer_loop_start += ptr_adt_complement->left_border; |
---|
940 | right_border = sequence + ptr_adt_complement->right_border; |
---|
941 | } |
---|
942 | //-------------------------------------------------------- end Borders |
---|
943 | |
---|
944 | seq_buffer_loop = seq_buffer_loop_start; |
---|
945 | index_buffer_loop = index_buffer_loop_start; |
---|
946 | |
---|
947 | //========================================== kopieren der Seq in Puffer |
---|
948 | for( sequence_loop = sequence_loop_start; |
---|
949 | ( source = *sequence_loop) && (sequence_loop <= right_border) ; |
---|
950 | sequence_loop++ ) { |
---|
951 | if( !((source == '-') || (source == '.')) ) |
---|
952 | { *( seq_buffer_loop++ ) = source; |
---|
953 | *( index_buffer_loop++ ) = sequence_loop - sequence; |
---|
954 | char_counter++; |
---|
955 | } |
---|
956 | } |
---|
957 | //=============================================== end kopieren in Puffer |
---|
958 | |
---|
959 | //========================================================== invertieren |
---|
960 | char *first, *last; |
---|
961 | first = seq_buffer_loop_start; |
---|
962 | last = seq_buffer + char_counter - 1; |
---|
963 | |
---|
964 | for( ; first < last ; first++, last-- ) |
---|
965 | { source = *first; |
---|
966 | *first = *last; |
---|
967 | *last = source; |
---|
968 | } |
---|
969 | //====================================================== end invertieren |
---|
970 | |
---|
971 | //================================================ueberschreiben der Seq |
---|
972 | |
---|
973 | long buffer_index = 0; |
---|
974 | |
---|
975 | //---------------------------------------------------------- take cursor |
---|
976 | if( ptr_adt_complement->take_cursor == YES ) { |
---|
977 | buffer_index = ptr_adt_edit->actual_cursorpos_editor; |
---|
978 | } |
---|
979 | //----------------------------------------------------------- end cursor |
---|
980 | |
---|
981 | //--------------------------------------------------------- take borders |
---|
982 | if(ptr_adt_complement->take_borders == YES) { |
---|
983 | buffer_index = ptr_adt_complement->left_border; |
---|
984 | right_border = seq_buffer + ptr_adt_complement->right_border; |
---|
985 | } |
---|
986 | |
---|
987 | //---------------------------------------------------------- end borders |
---|
988 | |
---|
989 | sequence_loop = sequence_loop_start; |
---|
990 | |
---|
991 | if(ptr_adt_complement->remove_gaps_points == YES) { |
---|
992 | for( seq_buffer_loop = seq_buffer_loop_start ; |
---|
993 | (source = *seq_buffer_loop) && (seq_buffer_loop <= right_border); |
---|
994 | seq_buffer_loop++ ) { |
---|
995 | *(sequence_loop++) = source; |
---|
996 | } |
---|
997 | } |
---|
998 | else { //////////// ptr_adt_complement->remove_gaps_points == NO |
---|
999 | for( ; (source = seq_buffer[buffer_index]) && |
---|
1000 | (seq_buffer[buffer_index] != '.'); |
---|
1001 | buffer_index++) { |
---|
1002 | *(sequence + index_buffer[buffer_index]) = source; |
---|
1003 | |
---|
1004 | } |
---|
1005 | } |
---|
1006 | //=========================================== end ueberschreiben der Seq |
---|
1007 | ptr_adt_complement->seq_is_inverted = YES; |
---|
1008 | |
---|
1009 | free(ptr_adt_complement->sequence_buffer); |
---|
1010 | free((char *)ptr_adt_complement->index_buffer); |
---|
1011 | ptr_adt_complement->sequence_buffer = NULL; |
---|
1012 | ptr_adt_complement->index_buffer = NULL; |
---|
1013 | |
---|
1014 | return 0; |
---|
1015 | |
---|
1016 | } // end fct show_edit_invert() |
---|
1017 | // ************************************************************************* |
---|