| 1 | #include <stdio.h> |
|---|
| 2 | #include <stdlib.h> |
|---|
| 3 | #include <string.h> |
|---|
| 4 | #include <time.h> |
|---|
| 5 | #include <math.h> |
|---|
| 6 | |
|---|
| 7 | #include <arbdb.h> |
|---|
| 8 | #include <arbdbt.h> |
|---|
| 9 | #include <aw_root.hxx> |
|---|
| 10 | #include <aw_window.hxx> |
|---|
| 11 | #include <awt.hxx> |
|---|
| 12 | #include <awt_canvas.hxx> |
|---|
| 13 | #include <awt_tree.hxx> |
|---|
| 14 | #include <awt_dtree.hxx> |
|---|
| 15 | #include <awt_tree_cb.hxx> |
|---|
| 16 | |
|---|
| 17 | #include "MultiProbe.hxx" |
|---|
| 18 | #include "mp_proto.hxx" |
|---|
| 19 | |
|---|
| 20 | BOOL MP_is_probe(char *seq); |
|---|
| 21 | int get_random(int min, int max); //gibt eine Zufallszahl x mit der Eigenschaft : min <= x <= max |
|---|
| 22 | void init_system3_tab(); |
|---|
| 23 | |
|---|
| 24 | char *glob_old_seq = NULL; |
|---|
| 25 | |
|---|
| 26 | int **system3_tab = NULL; |
|---|
| 27 | static int system3_tab_size = 0; |
|---|
| 28 | |
|---|
| 29 | unsigned char **hamming_tab = NULL; |
|---|
| 30 | BOOL new_pt_server = TRUE; |
|---|
| 31 | struct Params P; |
|---|
| 32 | |
|---|
| 33 | long k_aus_n(int k, int n) { |
|---|
| 34 | int a = n, b = 1, i; |
|---|
| 35 | |
|---|
| 36 | if (k > (n / 2)) k = n - k; |
|---|
| 37 | if (k <= 0) return (k == 0); |
|---|
| 38 | for (i = 2; i <= k; n--, a *= n, b *= i, i++) ; |
|---|
| 39 | return a / b; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | int get_random(int min,int max) { |
|---|
| 43 | mp_assert(min <= max); |
|---|
| 44 | return GB_random(max-min+1)+min; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | void MP_new_sequence(AW_window *aww) { |
|---|
| 48 | AWUSE(aww); |
|---|
| 49 | mp_main->get_aw_root()->awar_string(MP_AWAR_SEQUENZEINGABE)->write_string(""); |
|---|
| 50 | |
|---|
| 51 | delete glob_old_seq; |
|---|
| 52 | glob_old_seq = NULL; |
|---|
| 53 | |
|---|
| 54 | char *res = aw_input2awar("Enter target sequence", MP_AWAR_SEQUENZEINGABE); |
|---|
| 55 | free(res); |
|---|
| 56 | |
|---|
| 57 | MP_take_manual_sequence(aww); |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | void MP_close_main(AW_window *aww) |
|---|
| 62 | { |
|---|
| 63 | AWT_canvas *ntw = mp_main->get_ntw(); |
|---|
| 64 | |
|---|
| 65 | if (mp_main->get_mp_window()->get_result_window()) |
|---|
| 66 | mp_main->get_mp_window()->get_result_window()->hide(); |
|---|
| 67 | |
|---|
| 68 | GB_transaction dummy(ntw->gb_main); |
|---|
| 69 | |
|---|
| 70 | AP_tree *ap_tree = AWT_TREE(ntw)->tree_root; |
|---|
| 71 | if (ap_tree) ap_tree->calc_color(); |
|---|
| 72 | |
|---|
| 73 | if (ntw->gb_main) |
|---|
| 74 | ntw->tree_disp->update(ntw->gb_main); |
|---|
| 75 | |
|---|
| 76 | ntw->refresh(); |
|---|
| 77 | |
|---|
| 78 | AW_POPDOWN(aww); |
|---|
| 79 | delete mp_main->get_p_eval(); |
|---|
| 80 | mp_main->set_p_eval(NULL); |
|---|
| 81 | delete mp_main->get_stc(); |
|---|
| 82 | mp_main->set_stc(NULL); |
|---|
| 83 | |
|---|
| 84 | delete glob_old_seq; |
|---|
| 85 | glob_old_seq = NULL; |
|---|
| 86 | new_pt_server = TRUE; |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | void MP_gen_quality(AW_root *awr,AW_CL cd1,AW_CL cd2) |
|---|
| 90 | { |
|---|
| 91 | BOOL firsttime = TRUE; |
|---|
| 92 | |
|---|
| 93 | AWUSE(cd1); |
|---|
| 94 | AWUSE(cd2); |
|---|
| 95 | |
|---|
| 96 | if (firsttime) |
|---|
| 97 | { |
|---|
| 98 | firsttime = FALSE; |
|---|
| 99 | return; |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | char *probe, *new_qual, *ecol_pos; |
|---|
| 103 | char *selected = awr->awar(MP_AWAR_SELECTEDPROBES)->read_string(); |
|---|
| 104 | AW_window *aww= mp_main->get_mp_window()->get_window(); |
|---|
| 105 | |
|---|
| 106 | if (!selected || !selected[0]) |
|---|
| 107 | return; |
|---|
| 108 | |
|---|
| 109 | probe = MP_get_probes(selected); |
|---|
| 110 | if (!probe || !probe[0]) |
|---|
| 111 | return; |
|---|
| 112 | |
|---|
| 113 | ecol_pos = MP_get_comment(3,selected); |
|---|
| 114 | |
|---|
| 115 | aww->delete_selection_from_list( selected_list, selected); |
|---|
| 116 | |
|---|
| 117 | new_qual = new char[5 + 7 + strlen(probe)]; //5 = Zahl und Separator und Zahl und Separator und Nullzeichen |
|---|
| 118 | sprintf(new_qual,"%1ld#%1ld#%6d#%s",mp_gl_awars.probe_quality,mp_gl_awars.singlemismatches,atoi(ecol_pos),probe); |
|---|
| 119 | delete probe; |
|---|
| 120 | |
|---|
| 121 | aww->insert_selection( selected_list, new_qual, new_qual ); |
|---|
| 122 | aww->insert_default_selection( selected_list, "", "" ); |
|---|
| 123 | aww->sort_selection_list( selected_list, 0, 1); |
|---|
| 124 | aww->update_selection_list( selected_list ); |
|---|
| 125 | awr->awar(MP_AWAR_SELECTEDPROBES)->write_string(new_qual); |
|---|
| 126 | delete new_qual; |
|---|
| 127 | delete ecol_pos; |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | void MP_modify_selected(AW_root *awr,AW_CL cd1,AW_CL cd2) //setzt den 2.Parameter in selected_list |
|---|
| 131 | { |
|---|
| 132 | char *com1, *com2, *com3, *probes, *ptr2, temp[120]; |
|---|
| 133 | AW_window *aww = mp_main->get_mp_window()->get_window(); |
|---|
| 134 | List<char> *l = new List<char>; |
|---|
| 135 | |
|---|
| 136 | AWUSE(cd1); |
|---|
| 137 | AWUSE(cd2); |
|---|
| 138 | |
|---|
| 139 | aww->init_list_entry_iterator(selected_list); //initialisieren |
|---|
| 140 | |
|---|
| 141 | while ((ptr2 = (char *)aww->get_list_entry_char_value())) { |
|---|
| 142 | aww->iterate_list_entry(1); |
|---|
| 143 | |
|---|
| 144 | com1 = MP_get_comment(1,ptr2); |
|---|
| 145 | com2 = MP_get_comment(2,ptr2); |
|---|
| 146 | com3 = MP_get_comment(3,ptr2); |
|---|
| 147 | probes =MP_get_probes(ptr2); |
|---|
| 148 | |
|---|
| 149 | if (!probes || !probes[0]) |
|---|
| 150 | break; |
|---|
| 151 | |
|---|
| 152 | sprintf(temp,"%1d#%1ld#%6d#%s",atoi(com1), mp_gl_awars.no_of_mismatches, atoi(com3), probes); |
|---|
| 153 | |
|---|
| 154 | l->insert_as_last(strdup(temp)); |
|---|
| 155 | |
|---|
| 156 | delete probes; |
|---|
| 157 | delete com1; |
|---|
| 158 | delete com2; |
|---|
| 159 | delete com3; |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | aww->clear_selection_list( selected_list ); |
|---|
| 163 | |
|---|
| 164 | ptr2 = l->get_first(); |
|---|
| 165 | while (ptr2) |
|---|
| 166 | { |
|---|
| 167 | l->remove_first(); |
|---|
| 168 | aww->insert_selection( selected_list, ptr2, ptr2 ); |
|---|
| 169 | delete ptr2; |
|---|
| 170 | ptr2 = l->get_first(); |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | aww->insert_default_selection( selected_list, "", "" ); |
|---|
| 174 | aww->sort_selection_list( selected_list, 0, 1); |
|---|
| 175 | aww->update_selection_list( selected_list ); |
|---|
| 176 | awr->awar(MP_AWAR_SELECTEDPROBES)->write_string(""); |
|---|
| 177 | |
|---|
| 178 | remembered_mismatches = mp_gl_awars.no_of_mismatches; |
|---|
| 179 | delete l; |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | void MP_gen_singleprobe(AW_root *awr,AW_CL cd1,AW_CL cd2) |
|---|
| 183 | { |
|---|
| 184 | AWUSE(cd1); |
|---|
| 185 | AWUSE(cd2); |
|---|
| 186 | |
|---|
| 187 | char *probe, *new_sing; |
|---|
| 188 | char *selected = awr->awar(MP_AWAR_SELECTEDPROBES)->read_string(); |
|---|
| 189 | AW_window *aww= mp_main->get_mp_window()->get_window(); |
|---|
| 190 | |
|---|
| 191 | if (!selected || !selected[0]) |
|---|
| 192 | return; |
|---|
| 193 | |
|---|
| 194 | probe = MP_get_probes(selected); |
|---|
| 195 | aww->delete_selection_from_list( selected_list, selected); |
|---|
| 196 | |
|---|
| 197 | new_sing = new char[5 + 7 + strlen(probe)]; //5 = Zahl und Separator und Zahl und Separator und Nullzeichen |
|---|
| 198 | sprintf(new_sing,"%1ld#%1ld#%6ld#%s",mp_gl_awars.probe_quality,mp_gl_awars.singlemismatches, mp_gl_awars.ecolipos,probe); |
|---|
| 199 | delete probe; |
|---|
| 200 | |
|---|
| 201 | aww->insert_selection( selected_list, new_sing, new_sing ); |
|---|
| 202 | aww->insert_default_selection( selected_list, "", "" ); |
|---|
| 203 | aww->sort_selection_list( selected_list, 0, 1); |
|---|
| 204 | aww->update_selection_list( selected_list ); |
|---|
| 205 | awr->awar(MP_AWAR_SELECTEDPROBES)->write_string(new_sing); |
|---|
| 206 | delete new_sing; |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | void MP_popup_result_window(AW_window *aww) { |
|---|
| 210 | AWUSE(aww); |
|---|
| 211 | mp_main->get_mp_window()->create_result_window(mp_main->get_aw_root())->activate(); |
|---|
| 212 | init_system3_tab(); |
|---|
| 213 | } |
|---|
| 214 | |
|---|
| 215 | BOOL check_status(int gen_cnt, double avg_fit, double min_fit, double max_fit) |
|---|
| 216 | { |
|---|
| 217 | char view_text[150]; |
|---|
| 218 | |
|---|
| 219 | if (gen_cnt == 0) |
|---|
| 220 | sprintf(view_text,"Evaluating first generation"); |
|---|
| 221 | else |
|---|
| 222 | sprintf(view_text,"Gen:%d Avg:%5i Min:%5i Max:%5i",gen_cnt,int(avg_fit),int(min_fit),int(max_fit)); |
|---|
| 223 | |
|---|
| 224 | if (aw_status(view_text) == 1) |
|---|
| 225 | { |
|---|
| 226 | aw_closestatus(); |
|---|
| 227 | return FALSE; //Berechnungen abbrechen !!!!!! |
|---|
| 228 | } |
|---|
| 229 | |
|---|
| 230 | return TRUE; |
|---|
| 231 | } |
|---|
| 232 | |
|---|
| 233 | void init_system3_tab() |
|---|
| 234 | { |
|---|
| 235 | int i, j, k, |
|---|
| 236 | size_hamming_tab, |
|---|
| 237 | hamm_dist; |
|---|
| 238 | int **dummy_int; |
|---|
| 239 | int counter, wert; |
|---|
| 240 | |
|---|
| 241 | if (system3_tab) { |
|---|
| 242 | for (j=0; j< system3_tab_size; j++) |
|---|
| 243 | delete [] system3_tab[j]; |
|---|
| 244 | |
|---|
| 245 | delete [] system3_tab; |
|---|
| 246 | } |
|---|
| 247 | system3_tab = new int*[mp_gl_awars.no_of_probes]; |
|---|
| 248 | system3_tab_size = mp_gl_awars.no_of_probes; |
|---|
| 249 | for (j=0; j<mp_gl_awars.no_of_probes; j++) |
|---|
| 250 | { |
|---|
| 251 | system3_tab[j] = new int[3]; |
|---|
| 252 | memset(system3_tab[j],0, sizeof(int) * 3 ); |
|---|
| 253 | } |
|---|
| 254 | |
|---|
| 255 | for (j=0; j< mp_gl_awars.no_of_probes; j++) |
|---|
| 256 | { |
|---|
| 257 | for (k=0; k<3; k++) |
|---|
| 258 | { |
|---|
| 259 | if (!j) system3_tab[j][k] = k; |
|---|
| 260 | else system3_tab[j][k] = system3_tab[j-1][k] * 3; |
|---|
| 261 | } |
|---|
| 262 | } |
|---|
| 263 | |
|---|
| 264 | |
|---|
| 265 | //** hamming_tab |
|---|
| 266 | if (hamming_tab) |
|---|
| 267 | delete [] hamming_tab; |
|---|
| 268 | |
|---|
| 269 | size_hamming_tab = (int)pow(3.0, (double) mp_gl_awars.no_of_probes); |
|---|
| 270 | hamming_tab = new unsigned char*[size_hamming_tab]; |
|---|
| 271 | dummy_int = new int*[size_hamming_tab]; |
|---|
| 272 | |
|---|
| 273 | for (i=0; i<size_hamming_tab; i++) |
|---|
| 274 | { |
|---|
| 275 | hamming_tab[i] = new unsigned char[size_hamming_tab]; |
|---|
| 276 | memset(hamming_tab[i], 0, sizeof(unsigned char) * size_hamming_tab ); |
|---|
| 277 | |
|---|
| 278 | dummy_int[i] = new int[mp_gl_awars.no_of_probes]; |
|---|
| 279 | memset(dummy_int[i], 0, sizeof(int) * mp_gl_awars.no_of_probes); |
|---|
| 280 | } |
|---|
| 281 | |
|---|
| 282 | counter = 1; |
|---|
| 283 | for (i=0; i< mp_gl_awars.no_of_probes; i++) |
|---|
| 284 | { |
|---|
| 285 | for (j=0; j<size_hamming_tab; j++) |
|---|
| 286 | { |
|---|
| 287 | for (wert = 0; wert < 3; wert++) |
|---|
| 288 | { |
|---|
| 289 | for (k=0; k<counter; k++) |
|---|
| 290 | { |
|---|
| 291 | dummy_int[j++][i] = wert; |
|---|
| 292 | } |
|---|
| 293 | } |
|---|
| 294 | j--; |
|---|
| 295 | } |
|---|
| 296 | counter *= 3; |
|---|
| 297 | } |
|---|
| 298 | |
|---|
| 299 | for (i=0; i<size_hamming_tab; i++) |
|---|
| 300 | { |
|---|
| 301 | for (j=0; j<size_hamming_tab; j++) |
|---|
| 302 | { |
|---|
| 303 | hamm_dist = 0; |
|---|
| 304 | for (k=0; k<mp_gl_awars.no_of_probes; k++) |
|---|
| 305 | { |
|---|
| 306 | if ((dummy_int[i][k] == 2 && dummy_int[j][k] == 0) || |
|---|
| 307 | (dummy_int[i][k] == 0 && dummy_int[j][k] == 2)) |
|---|
| 308 | hamm_dist++; |
|---|
| 309 | } |
|---|
| 310 | hamming_tab[i][j] = hamm_dist; |
|---|
| 311 | } |
|---|
| 312 | } |
|---|
| 313 | /* |
|---|
| 314 | for (i=0; i<size_hamming_tab; i++) |
|---|
| 315 | { |
|---|
| 316 | for (j=0; j<size_hamming_tab; j++) |
|---|
| 317 | { |
|---|
| 318 | printf("%d ", hamming_tab[i][j]); |
|---|
| 319 | } |
|---|
| 320 | printf("\n"); |
|---|
| 321 | |
|---|
| 322 | } |
|---|
| 323 | */ |
|---|
| 324 | |
|---|
| 325 | for (i=0; i<size_hamming_tab; i++) |
|---|
| 326 | { |
|---|
| 327 | delete [] dummy_int[i]; |
|---|
| 328 | } |
|---|
| 329 | delete [] dummy_int; |
|---|
| 330 | |
|---|
| 331 | |
|---|
| 332 | |
|---|
| 333 | } |
|---|
| 334 | |
|---|
| 335 | void MP_compute(AW_window *aww) |
|---|
| 336 | { |
|---|
| 337 | AW_root *aw_root = mp_main->get_aw_root(); |
|---|
| 338 | AW_window *aww2; |
|---|
| 339 | int i = 0; |
|---|
| 340 | int *bew_array; |
|---|
| 341 | char *ptr, *ptr2, *qual; |
|---|
| 342 | char **probe_field; |
|---|
| 343 | int *single_mismatch; |
|---|
| 344 | ProbeValuation *p_eval = NULL; |
|---|
| 345 | |
|---|
| 346 | |
|---|
| 347 | if (aww->get_no_of_entries( selected_list )-1 < mp_gl_awars.no_of_probes) |
|---|
| 348 | { |
|---|
| 349 | aw_message("Not enough probes selected for computation !!!"); |
|---|
| 350 | return; |
|---|
| 351 | } |
|---|
| 352 | |
|---|
| 353 | if (mp_main->get_stc()) |
|---|
| 354 | { |
|---|
| 355 | delete mp_main->get_stc(); |
|---|
| 356 | mp_main->set_stc(NULL); |
|---|
| 357 | new_pt_server = TRUE; |
|---|
| 358 | } |
|---|
| 359 | |
|---|
| 360 | init_system3_tab(); |
|---|
| 361 | |
|---|
| 362 | aww2 = mp_main->get_mp_window()->create_result_window(aw_root); |
|---|
| 363 | |
|---|
| 364 | aww2->clear_selection_list( result_probes_list ); |
|---|
| 365 | aww2->insert_default_selection( result_probes_list, "", ""); |
|---|
| 366 | aww2->update_selection_list( result_probes_list); |
|---|
| 367 | |
|---|
| 368 | aww->init_list_entry_iterator(selected_list); //initialisieren |
|---|
| 369 | probe_field = new char*[aww->get_no_of_entries(selected_list)-1]; //-1 wegen default entry |
|---|
| 370 | bew_array = new int[aww->get_no_of_entries(selected_list)-1]; |
|---|
| 371 | single_mismatch = new int[aww->get_no_of_entries(selected_list)-1]; |
|---|
| 372 | |
|---|
| 373 | aw_openstatus("Computing multiprobes"); |
|---|
| 374 | |
|---|
| 375 | while ((ptr2 = (char *)aww->get_list_entry_char_value())) |
|---|
| 376 | { |
|---|
| 377 | aww->iterate_list_entry(1); |
|---|
| 378 | ptr = MP_get_probes(ptr2); //hier sind es einfachsonden |
|---|
| 379 | if (ptr && ptr[0] != ' ' && ptr[0] != '\t' && ptr[0] != '\0') { |
|---|
| 380 | qual = MP_get_comment(1,ptr2); |
|---|
| 381 | bew_array[i] = atoi(qual); |
|---|
| 382 | free(qual); |
|---|
| 383 | |
|---|
| 384 | qual = MP_get_comment(2,ptr2); |
|---|
| 385 | single_mismatch[i] = atoi(qual); //single mismatch kann zwar eingestellt werden, aber wird noch nicht uebergeben |
|---|
| 386 | free(qual); |
|---|
| 387 | |
|---|
| 388 | probe_field[i++] = ptr; |
|---|
| 389 | } |
|---|
| 390 | } |
|---|
| 391 | |
|---|
| 392 | p_eval = mp_main->new_probe_eval(probe_field,i,bew_array, single_mismatch); |
|---|
| 393 | p_eval->init_valuation(); |
|---|
| 394 | |
|---|
| 395 | if (pt_server_different) |
|---|
| 396 | { |
|---|
| 397 | pt_server_different = FALSE; |
|---|
| 398 | aw_message("There are species in the tree which are\nnot included in the PT-Server"); |
|---|
| 399 | } |
|---|
| 400 | |
|---|
| 401 | mp_main->destroy_probe_eval(); |
|---|
| 402 | |
|---|
| 403 | aw_closestatus(); |
|---|
| 404 | aww2->activate(); |
|---|
| 405 | |
|---|
| 406 | } |
|---|
| 407 | |
|---|
| 408 | void MP_take_manual_sequence(AW_window *aww) |
|---|
| 409 | { |
|---|
| 410 | AW_window_simple *aws = mp_main->get_mp_window()->get_window(); |
|---|
| 411 | char *seq = mp_gl_awars.manual_sequence, |
|---|
| 412 | *new_seq; |
|---|
| 413 | |
|---|
| 414 | AWUSE(aww); |
|---|
| 415 | |
|---|
| 416 | if (! MP_is_probe(seq)){ |
|---|
| 417 | aw_message("This is not a valid probe !!!"); |
|---|
| 418 | return; |
|---|
| 419 | } |
|---|
| 420 | |
|---|
| 421 | |
|---|
| 422 | if (glob_old_seq){ |
|---|
| 423 | aww->delete_selection_from_list( selected_list, glob_old_seq ); |
|---|
| 424 | } |
|---|
| 425 | |
|---|
| 426 | new_seq = new char[strlen(seq)+5+7]; |
|---|
| 427 | sprintf(new_seq,"%1ld#%1ld#%6d#%s",mp_gl_awars.probe_quality,mp_gl_awars.singlemismatches,0,seq); |
|---|
| 428 | |
|---|
| 429 | aws->insert_selection( selected_list,new_seq,new_seq ); |
|---|
| 430 | |
|---|
| 431 | aws->insert_default_selection(selected_list, "", ""); |
|---|
| 432 | aws->sort_selection_list( selected_list, 0, 1); |
|---|
| 433 | aws->update_selection_list( selected_list ); |
|---|
| 434 | mp_main->get_aw_root()->awar(MP_AWAR_SEQUENZEINGABE)->write_string(""); |
|---|
| 435 | mp_main->get_aw_root()->awar(MP_AWAR_SELECTEDPROBES)->write_string(new_seq); |
|---|
| 436 | delete new_seq; |
|---|
| 437 | } |
|---|
| 438 | |
|---|
| 439 | |
|---|
| 440 | void MP_cache_sonden(AW_window *) { new_pt_server = TRUE; } |
|---|
| 441 | void MP_cache_sonden2(AW_root *) { new_pt_server = TRUE; } |
|---|
| 442 | |
|---|
| 443 | void MP_show_probes_in_tree_move(AW_window *aww, AW_CL cl_backward, AW_CL cl_result_probes_list) { |
|---|
| 444 | bool backward = bool(cl_backward); |
|---|
| 445 | AW_selection_list *resultProbesList = (AW_selection_list*)cl_result_probes_list; |
|---|
| 446 | |
|---|
| 447 | // aw_message(GBS_global_string("backward='%i'", int(backward))); |
|---|
| 448 | |
|---|
| 449 | // aww->move_selection(resultProbesList, mp_main->get_aw_root()->awar(MP_AWAR_RESULTPROBES), backward ? -1 : 1); |
|---|
| 450 | aww->move_selection(resultProbesList, MP_AWAR_RESULTPROBES, backward ? -1 : 1); |
|---|
| 451 | |
|---|
| 452 | MP_show_probes_in_tree(aww); |
|---|
| 453 | } |
|---|
| 454 | |
|---|
| 455 | void MP_show_probes_in_tree(AW_window *aww) |
|---|
| 456 | { |
|---|
| 457 | AWT_canvas *ntw = mp_main->get_ntw(); |
|---|
| 458 | char *mism, *mism_temp; |
|---|
| 459 | char *a_probe, *another_probe, *the_probe, *mism_temp2; |
|---|
| 460 | int i, how_many_probes = 0; |
|---|
| 461 | |
|---|
| 462 | AWUSE(aww); |
|---|
| 463 | |
|---|
| 464 | { |
|---|
| 465 | char *sel = mp_main->get_aw_root()->awar(MP_AWAR_RESULTPROBES)->read_string(); |
|---|
| 466 | a_probe = MP_get_probes(sel); //haelt jetzt Sondenstring |
|---|
| 467 | if (! a_probe || ! a_probe[0]) { |
|---|
| 468 | free(a_probe); |
|---|
| 469 | free(sel); |
|---|
| 470 | return; |
|---|
| 471 | } |
|---|
| 472 | |
|---|
| 473 | mism_temp2 = MP_get_comment(2,sel); |
|---|
| 474 | mism_temp = mism_temp2; |
|---|
| 475 | free(sel); |
|---|
| 476 | } |
|---|
| 477 | |
|---|
| 478 | char **probe_field = new char*[MAXMISMATCHES]; |
|---|
| 479 | int *mismatches = new int[MAXMISMATCHES]; |
|---|
| 480 | |
|---|
| 481 | for (i=0; i<MAXMISMATCHES; i++) |
|---|
| 482 | { |
|---|
| 483 | probe_field[i] = NULL; |
|---|
| 484 | mismatches[i] = 0; |
|---|
| 485 | } |
|---|
| 486 | |
|---|
| 487 | another_probe = a_probe; |
|---|
| 488 | for (i=0; i< MAXPROBECOMBIS; i++) //generiert probe_field und mismatches array |
|---|
| 489 | { |
|---|
| 490 | mism = strchr(mism_temp,' '); |
|---|
| 491 | if (mism) |
|---|
| 492 | *(mism++) = 0; |
|---|
| 493 | |
|---|
| 494 | mismatches[i] = atoi(mism_temp); |
|---|
| 495 | mism_temp = mism; |
|---|
| 496 | |
|---|
| 497 | |
|---|
| 498 | probe_field[i] = NULL; |
|---|
| 499 | the_probe = another_probe; |
|---|
| 500 | another_probe = strchr(another_probe,' '); |
|---|
| 501 | if (another_probe) |
|---|
| 502 | { |
|---|
| 503 | *(another_probe++) = 0; |
|---|
| 504 | while (*another_probe == ' ' || *another_probe == '\t') |
|---|
| 505 | another_probe++; |
|---|
| 506 | } |
|---|
| 507 | else |
|---|
| 508 | { |
|---|
| 509 | probe_field[i] = strdup(the_probe); |
|---|
| 510 | how_many_probes ++; |
|---|
| 511 | break; |
|---|
| 512 | } |
|---|
| 513 | |
|---|
| 514 | if (the_probe && the_probe[0]) |
|---|
| 515 | { |
|---|
| 516 | probe_field[i] = strdup(the_probe); |
|---|
| 517 | how_many_probes ++; |
|---|
| 518 | } |
|---|
| 519 | } |
|---|
| 520 | |
|---|
| 521 | free(a_probe); |
|---|
| 522 | free(mism_temp2); |
|---|
| 523 | |
|---|
| 524 | if (new_pt_server) |
|---|
| 525 | { |
|---|
| 526 | new_pt_server = FALSE; |
|---|
| 527 | |
|---|
| 528 | if (mp_main->get_stc()) |
|---|
| 529 | delete mp_main->get_stc(); |
|---|
| 530 | |
|---|
| 531 | mp_main->set_stc(new ST_Container(MAXSONDENHASHSIZE)); |
|---|
| 532 | if (pt_server_different) |
|---|
| 533 | { |
|---|
| 534 | mp_main->set_stc(NULL); |
|---|
| 535 | new_pt_server = TRUE; |
|---|
| 536 | aw_message("There are species in the tree which are\nnot included in the PT-Server"); |
|---|
| 537 | pt_server_different = FALSE; |
|---|
| 538 | return; |
|---|
| 539 | } |
|---|
| 540 | } |
|---|
| 541 | |
|---|
| 542 | delete mp_main->get_stc()->sondentopf; |
|---|
| 543 | mp_main->get_stc()->sondentopf = new Sondentopf(mp_main->get_stc()->Bakterienliste,mp_main->get_stc()->Auswahlliste ); |
|---|
| 544 | |
|---|
| 545 | for (i=0; i<MAXMISMATCHES; i++){ |
|---|
| 546 | if (probe_field[i]){ |
|---|
| 547 | mp_main->get_stc()->sondentopf->put_Sonde(probe_field[i],mismatches[i], mismatches[i] + mp_gl_awars.outside_mismatches_difference); |
|---|
| 548 | } |
|---|
| 549 | } |
|---|
| 550 | |
|---|
| 551 | mp_main->get_stc()->sondentopf->gen_color_hash(mp_gl_awars.no_of_probes); |
|---|
| 552 | |
|---|
| 553 | GB_transaction dummy(ntw->gb_main); |
|---|
| 554 | AWT_TREE(ntw)->tree_root->calc_color_probes(mp_main->get_stc()->sondentopf->get_color_hash()); |
|---|
| 555 | |
|---|
| 556 | if (ntw->gb_main) |
|---|
| 557 | ntw->tree_disp->update(ntw->gb_main); |
|---|
| 558 | |
|---|
| 559 | ntw->refresh(); |
|---|
| 560 | |
|---|
| 561 | for (i=0; i<MAXMISMATCHES; i++) |
|---|
| 562 | free(probe_field[i]); |
|---|
| 563 | |
|---|
| 564 | delete [] probe_field; |
|---|
| 565 | delete [] mismatches; |
|---|
| 566 | } |
|---|
| 567 | |
|---|
| 568 | void MP_mark_probes_in_tree(AW_window *aww) |
|---|
| 569 | { |
|---|
| 570 | AWT_canvas *ntw = mp_main->get_ntw(); |
|---|
| 571 | char *mism, *mism_temp; |
|---|
| 572 | char *a_probe, *another_probe, *the_probe, *mism_temp2; |
|---|
| 573 | int i, how_many_probes = 0; |
|---|
| 574 | GBDATA *gb_species; |
|---|
| 575 | |
|---|
| 576 | AWUSE(aww); |
|---|
| 577 | |
|---|
| 578 | { |
|---|
| 579 | char *sel = mp_main->get_aw_root()->awar(MP_AWAR_RESULTPROBES)->read_string(); |
|---|
| 580 | a_probe = MP_get_probes(sel); //haelt jetzt Sondenstring |
|---|
| 581 | if (! a_probe || ! a_probe[0]) { |
|---|
| 582 | free(a_probe); |
|---|
| 583 | free(sel); |
|---|
| 584 | return; |
|---|
| 585 | } |
|---|
| 586 | |
|---|
| 587 | mism_temp2 = MP_get_comment(2,sel); |
|---|
| 588 | mism_temp = mism_temp2; |
|---|
| 589 | } |
|---|
| 590 | |
|---|
| 591 | char **probe_field = new char*[MAXMISMATCHES]; |
|---|
| 592 | int *mismatches = new int[MAXMISMATCHES]; |
|---|
| 593 | |
|---|
| 594 | for (i=0; i<MAXMISMATCHES; i++) |
|---|
| 595 | { |
|---|
| 596 | probe_field[i] = NULL; |
|---|
| 597 | mismatches[i] = 0; |
|---|
| 598 | } |
|---|
| 599 | |
|---|
| 600 | another_probe = a_probe; |
|---|
| 601 | for (i=0; i< MAXPROBECOMBIS; i++) //generiert probe_field und mismatches array |
|---|
| 602 | { |
|---|
| 603 | mism = strchr(mism_temp,' '); |
|---|
| 604 | if (mism) |
|---|
| 605 | *(mism++) = 0; |
|---|
| 606 | |
|---|
| 607 | mismatches[i] = atoi(mism_temp); |
|---|
| 608 | mism_temp = mism; |
|---|
| 609 | |
|---|
| 610 | probe_field[i] = NULL; |
|---|
| 611 | the_probe = another_probe; |
|---|
| 612 | another_probe = strchr(another_probe,' '); |
|---|
| 613 | if (another_probe) { |
|---|
| 614 | *(another_probe++) = 0; |
|---|
| 615 | while (*another_probe == ' ' || *another_probe == '\t') |
|---|
| 616 | another_probe++; |
|---|
| 617 | } |
|---|
| 618 | else { |
|---|
| 619 | probe_field[i] = strdup(the_probe); |
|---|
| 620 | how_many_probes ++; |
|---|
| 621 | break; |
|---|
| 622 | } |
|---|
| 623 | |
|---|
| 624 | if (the_probe && the_probe[0]) { |
|---|
| 625 | probe_field[i] = strdup(the_probe); |
|---|
| 626 | how_many_probes ++; |
|---|
| 627 | } |
|---|
| 628 | } |
|---|
| 629 | |
|---|
| 630 | free(a_probe); |
|---|
| 631 | free(mism_temp2); |
|---|
| 632 | |
|---|
| 633 | if (new_pt_server) { |
|---|
| 634 | new_pt_server = FALSE; |
|---|
| 635 | |
|---|
| 636 | if (mp_main->get_stc()) |
|---|
| 637 | delete mp_main->get_stc(); |
|---|
| 638 | |
|---|
| 639 | mp_main->set_stc(new ST_Container(MAXSONDENHASHSIZE)); |
|---|
| 640 | if (pt_server_different) |
|---|
| 641 | { |
|---|
| 642 | mp_main->set_stc(NULL); |
|---|
| 643 | new_pt_server = TRUE; |
|---|
| 644 | aw_message("There are species in the tree which are\nnot included in the PT-Server"); |
|---|
| 645 | pt_server_different = FALSE; |
|---|
| 646 | return; |
|---|
| 647 | } |
|---|
| 648 | } |
|---|
| 649 | |
|---|
| 650 | delete mp_main->get_stc()->sondentopf; |
|---|
| 651 | mp_main->get_stc()->sondentopf = new Sondentopf(mp_main->get_stc()->Bakterienliste,mp_main->get_stc()->Auswahlliste ); |
|---|
| 652 | |
|---|
| 653 | for (i=0; i<MAXMISMATCHES; i++){ |
|---|
| 654 | if (probe_field[i]){ |
|---|
| 655 | mp_main->get_stc()->sondentopf->put_Sonde(probe_field[i],mismatches[i], mismatches[i] + mp_gl_awars.outside_mismatches_difference); |
|---|
| 656 | } |
|---|
| 657 | } |
|---|
| 658 | mp_main->get_stc()->sondentopf->gen_color_hash(mp_gl_awars.no_of_probes); |
|---|
| 659 | |
|---|
| 660 | { |
|---|
| 661 | GB_push_transaction(ntw->gb_main); |
|---|
| 662 | GB_HASH *col_hash = mp_main->get_stc()->sondentopf->get_color_hash(); |
|---|
| 663 | for (gb_species = GBT_first_species(ntw->gb_main); gb_species; gb_species = GBT_next_species(gb_species)) { |
|---|
| 664 | GB_write_flag(gb_species, GBS_read_hash(col_hash, GBT_read_name(gb_species)) > AWT_GC_BLACK); |
|---|
| 665 | } |
|---|
| 666 | } |
|---|
| 667 | GB_pop_transaction(ntw->gb_main); |
|---|
| 668 | |
|---|
| 669 | GB_transaction dummy(ntw->gb_main); |
|---|
| 670 | |
|---|
| 671 | if (ntw->gb_main) |
|---|
| 672 | ntw->tree_disp->update(ntw->gb_main); |
|---|
| 673 | |
|---|
| 674 | ntw->refresh(); |
|---|
| 675 | |
|---|
| 676 | for (i=0; i<MAXMISMATCHES; i++) |
|---|
| 677 | free(probe_field[i]); |
|---|
| 678 | |
|---|
| 679 | delete [] probe_field; |
|---|
| 680 | delete [] mismatches; |
|---|
| 681 | |
|---|
| 682 | MP_normal_colors_in_tree(aww); |
|---|
| 683 | } |
|---|
| 684 | |
|---|
| 685 | void MP_Comment(AW_window *aww, AW_CL com) //Comment fuer Auswahl eintragen |
|---|
| 686 | { |
|---|
| 687 | char *new_list_string; |
|---|
| 688 | AW_root *awr = mp_main->get_aw_root(); |
|---|
| 689 | char *aw_str = awr->awar(MP_AWAR_RESULTPROBESCOMMENT)->read_string(); |
|---|
| 690 | char *aw_str2 = awr->awar(MP_AWAR_RESULTPROBES)->read_string(); |
|---|
| 691 | char *comment = ((char *) com) ? (char *) com : aw_str ; |
|---|
| 692 | char *new_val; |
|---|
| 693 | char *misms; |
|---|
| 694 | char spaces[21]; |
|---|
| 695 | int len_spaces = 0; |
|---|
| 696 | char *ecol; |
|---|
| 697 | const char *successor_value = aww->get_element_of_index(result_probes_list, |
|---|
| 698 | aww->get_index_of_element(result_probes_list, aw_str2)+1); |
|---|
| 699 | |
|---|
| 700 | // remove all '#' from new comment |
|---|
| 701 | for (char *aw_str3 = aw_str; aw_str3[0]; ++aw_str3) { |
|---|
| 702 | if (aw_str3[0] == SEPARATOR[0]) { |
|---|
| 703 | aw_str3[0] = '|'; |
|---|
| 704 | } |
|---|
| 705 | } |
|---|
| 706 | |
|---|
| 707 | new_val = MP_get_probes(aw_str2); |
|---|
| 708 | if (!new_val || !new_val[0]) |
|---|
| 709 | { |
|---|
| 710 | delete new_val; |
|---|
| 711 | return; |
|---|
| 712 | } |
|---|
| 713 | |
|---|
| 714 | misms = MP_get_comment(2,aw_str2); |
|---|
| 715 | ecol = MP_get_comment(3,aw_str2); |
|---|
| 716 | |
|---|
| 717 | spaces[0] = 0; |
|---|
| 718 | len_spaces = (strlen(comment) > 20) ? 20 : strlen(comment); |
|---|
| 719 | |
|---|
| 720 | for (int i=0; i< 20 - len_spaces; i++) |
|---|
| 721 | strcat(spaces, " "); |
|---|
| 722 | |
|---|
| 723 | new_list_string = new char[21+strlen(aw_str2)+2*strlen(SEPARATOR)+1+strlen(ecol)+1]; //1 fuer 0-Zeichen |
|---|
| 724 | sprintf(new_list_string,"%.20s%s%s%s%s%s%s%s",comment,spaces,SEPARATOR,misms,SEPARATOR,ecol,SEPARATOR,new_val); |
|---|
| 725 | delete new_val; |
|---|
| 726 | delete misms; |
|---|
| 727 | delete ecol; |
|---|
| 728 | |
|---|
| 729 | aww->delete_selection_from_list( result_probes_list, aw_str2 ); |
|---|
| 730 | aww->insert_selection( result_probes_list, new_list_string, new_list_string ); |
|---|
| 731 | aww->update_selection_list( result_probes_list ); |
|---|
| 732 | if (awr->awar(MP_AWAR_AUTOADVANCE)->read_int() && successor_value) { |
|---|
| 733 | awr->awar(MP_AWAR_RESULTPROBES)->write_string(successor_value); |
|---|
| 734 | } |
|---|
| 735 | else { |
|---|
| 736 | awr->awar(MP_AWAR_RESULTPROBES)->write_string(new_list_string); |
|---|
| 737 | } |
|---|
| 738 | delete new_list_string; |
|---|
| 739 | } |
|---|
| 740 | |
|---|
| 741 | void MP_leftright(AW_window *aww) |
|---|
| 742 | { |
|---|
| 743 | char *sel = mp_main->get_aw_root()->awar(MP_AWAR_PROBELIST)->read_string(); |
|---|
| 744 | |
|---|
| 745 | if (!sel || !sel[0]) |
|---|
| 746 | return; |
|---|
| 747 | |
|---|
| 748 | aww->insert_selection( selected_list, sel, sel ); |
|---|
| 749 | aww->delete_selection_from_list( probelist, sel); |
|---|
| 750 | aww->insert_default_selection( probelist, "", "" ); |
|---|
| 751 | mp_main->get_aw_root()->awar(MP_AWAR_PROBELIST)->write_string(""); |
|---|
| 752 | aww->sort_selection_list( selected_list, 0, 1); |
|---|
| 753 | aww->update_selection_list( selected_list ); |
|---|
| 754 | aww->update_selection_list( probelist ); |
|---|
| 755 | } |
|---|
| 756 | |
|---|
| 757 | void MP_rightleft(AW_window *aww) // von rechts nach links |
|---|
| 758 | { |
|---|
| 759 | char *sel = mp_main->get_aw_root()->awar(MP_AWAR_SELECTEDPROBES)->read_string(); |
|---|
| 760 | |
|---|
| 761 | if (!sel || !sel[0]) |
|---|
| 762 | return; |
|---|
| 763 | |
|---|
| 764 | aww->insert_selection( probelist, sel, sel ); |
|---|
| 765 | aww->delete_selection_from_list( selected_list, sel); |
|---|
| 766 | aww->insert_default_selection( selected_list, "", "" ); |
|---|
| 767 | mp_main->get_aw_root()->awar(MP_AWAR_SELECTEDPROBES)->write_string(""); |
|---|
| 768 | aww->update_selection_list( selected_list ); |
|---|
| 769 | aww->sort_selection_list( probelist, 0, 1); |
|---|
| 770 | aww->update_selection_list( probelist ); |
|---|
| 771 | } |
|---|
| 772 | |
|---|
| 773 | BOOL MP_is_probe(char *seq) |
|---|
| 774 | { |
|---|
| 775 | BOOL result=TRUE; |
|---|
| 776 | char *s, |
|---|
| 777 | *seq2; |
|---|
| 778 | |
|---|
| 779 | if (! seq) |
|---|
| 780 | return FALSE; |
|---|
| 781 | |
|---|
| 782 | seq2 = MP_get_probes(seq); |
|---|
| 783 | if (!seq2 || ! seq2[0]) |
|---|
| 784 | return FALSE; |
|---|
| 785 | |
|---|
| 786 | s = seq2; |
|---|
| 787 | while (*s && result) |
|---|
| 788 | { |
|---|
| 789 | result = result && MP_probe_tab[(unsigned char)*s]; |
|---|
| 790 | s++; |
|---|
| 791 | } |
|---|
| 792 | free(seq2); |
|---|
| 793 | return result; |
|---|
| 794 | } |
|---|
| 795 | |
|---|
| 796 | void MP_selected_chosen(AW_window *aww) |
|---|
| 797 | { |
|---|
| 798 | char *selected = mp_main->get_aw_root()->awar(MP_AWAR_SELECTEDPROBES)->read_string(); |
|---|
| 799 | char *probe; |
|---|
| 800 | |
|---|
| 801 | AWUSE(aww); |
|---|
| 802 | |
|---|
| 803 | if (!selected || !selected[0]) |
|---|
| 804 | return; |
|---|
| 805 | |
|---|
| 806 | glob_old_seq = strdup(selected); |
|---|
| 807 | |
|---|
| 808 | probe = MP_get_comment(3,selected); |
|---|
| 809 | mp_main->get_aw_root()->awar(MP_AWAR_ECOLIPOS)->write_int(atoi(probe)); |
|---|
| 810 | free(probe); |
|---|
| 811 | |
|---|
| 812 | probe = MP_get_comment(1,selected); |
|---|
| 813 | mp_main->get_aw_root()->awar(MP_AWAR_QUALITY)->write_int(atoi(probe)); |
|---|
| 814 | free(probe); |
|---|
| 815 | |
|---|
| 816 | probe = MP_get_comment(2,selected); |
|---|
| 817 | mp_main->get_aw_root()->awar(MP_AWAR_SINGLEMISMATCHES)->write_int(atoi(probe)); |
|---|
| 818 | free(probe); |
|---|
| 819 | |
|---|
| 820 | probe = MP_get_probes(selected); |
|---|
| 821 | mp_main->get_aw_root()->awar_string(MP_AWAR_SEQUENZEINGABE)->write_string(MP_get_probes(probe)); |
|---|
| 822 | free(probe); |
|---|
| 823 | } |
|---|
| 824 | |
|---|
| 825 | void MP_group_all_except_marked(AW_window */*aww*/) { |
|---|
| 826 | AWT_canvas *ntw = mp_main->get_ntw(); |
|---|
| 827 | NT_group_not_marked_cb(0, ntw); |
|---|
| 828 | } |
|---|
| 829 | |
|---|
| 830 | void MP_normal_colors_in_tree(AW_window *aww) |
|---|
| 831 | { |
|---|
| 832 | AWT_canvas *ntw = mp_main->get_ntw(); |
|---|
| 833 | |
|---|
| 834 | AWUSE(aww); |
|---|
| 835 | |
|---|
| 836 | GB_transaction dummy(ntw->gb_main); |
|---|
| 837 | |
|---|
| 838 | AWT_TREE(ntw)->tree_root->calc_color(); |
|---|
| 839 | |
|---|
| 840 | if (ntw->gb_main) |
|---|
| 841 | ntw->tree_disp->update(ntw->gb_main); |
|---|
| 842 | |
|---|
| 843 | ntw->refresh(); |
|---|
| 844 | } |
|---|
| 845 | |
|---|
| 846 | void MP_all_right(AW_window *aww) |
|---|
| 847 | { |
|---|
| 848 | aww->conc_list( probelist, selected_list ); |
|---|
| 849 | mp_main->get_aw_root()->awar(MP_AWAR_PROBELIST)->write_string(""); |
|---|
| 850 | aww->sort_selection_list( selected_list, 0, 1); |
|---|
| 851 | aww->update_selection_list( selected_list ); |
|---|
| 852 | aww->update_selection_list( probelist ); |
|---|
| 853 | } |
|---|
| 854 | |
|---|
| 855 | void MP_del_all_sel_probes(AW_window *aww) |
|---|
| 856 | { |
|---|
| 857 | mp_main->get_aw_root()->awar(MP_AWAR_SELECTEDPROBES)->write_string(""); |
|---|
| 858 | aww->clear_selection_list( selected_list ); |
|---|
| 859 | aww->insert_default_selection( selected_list, "", "" ); |
|---|
| 860 | aww->update_selection_list( selected_list ); |
|---|
| 861 | } |
|---|
| 862 | |
|---|
| 863 | void MP_del_all_probes(AW_window *aww) |
|---|
| 864 | { |
|---|
| 865 | mp_main->get_aw_root()->awar(MP_AWAR_PROBELIST)->write_string(""); |
|---|
| 866 | aww->clear_selection_list( probelist ); |
|---|
| 867 | aww->insert_default_selection( probelist, "", "" ); |
|---|
| 868 | aww->update_selection_list( probelist ); |
|---|
| 869 | } |
|---|
| 870 | |
|---|
| 871 | void MP_del_all_result(AW_window *aww) |
|---|
| 872 | { |
|---|
| 873 | mp_main->get_aw_root()->awar(MP_AWAR_RESULTPROBES)->write_string(""); |
|---|
| 874 | aww->clear_selection_list( result_probes_list ); |
|---|
| 875 | aww->insert_default_selection( result_probes_list, "", "" ); |
|---|
| 876 | aww->update_selection_list( result_probes_list ); |
|---|
| 877 | } |
|---|
| 878 | |
|---|
| 879 | void MP_del_sel_result(AW_window *aww) |
|---|
| 880 | { |
|---|
| 881 | char *val = mp_main->get_aw_root()->awar(MP_AWAR_RESULTPROBES)->read_string(); |
|---|
| 882 | aww->delete_selection_from_list( result_probes_list, val); |
|---|
| 883 | aww->insert_default_selection( result_probes_list, "", "" ); |
|---|
| 884 | mp_main->get_aw_root()->awar(MP_AWAR_RESULTPROBES)->write_string(""); |
|---|
| 885 | aww->update_selection_list( result_probes_list ); |
|---|
| 886 | } |
|---|
| 887 | |
|---|
| 888 | void MP_del_sel_probes(AW_window *aww) |
|---|
| 889 | { |
|---|
| 890 | char *val = mp_main->get_aw_root()->awar(MP_AWAR_SELECTEDPROBES)->read_string(); |
|---|
| 891 | aww->delete_selection_from_list( selected_list, val); |
|---|
| 892 | aww->insert_default_selection( selected_list, "", "" ); |
|---|
| 893 | mp_main->get_aw_root()->awar(MP_AWAR_SELECTEDPROBES)->write_string(""); |
|---|
| 894 | aww->update_selection_list( selected_list ); |
|---|
| 895 | } |
|---|
| 896 | |
|---|
| 897 | void MP_del_probes(AW_window *aww) |
|---|
| 898 | { |
|---|
| 899 | char *val = mp_main->get_aw_root()->awar(MP_AWAR_PROBELIST)->read_string(); |
|---|
| 900 | aww->delete_selection_from_list( probelist, val); |
|---|
| 901 | aww->insert_default_selection( probelist, "", "" ); |
|---|
| 902 | mp_main->get_aw_root()->awar(MP_AWAR_PROBELIST)->write_string(""); |
|---|
| 903 | aww->update_selection_list( probelist ); |
|---|
| 904 | } |
|---|
| 905 | |
|---|
| 906 | char *MP_get_comment(int which, char *str) //faengt bei eins an |
|---|
| 907 | { |
|---|
| 908 | char *result, *first; |
|---|
| 909 | char *ret_res; |
|---|
| 910 | int i; |
|---|
| 911 | |
|---|
| 912 | result = first = str; |
|---|
| 913 | result = strchr(result,'#'); |
|---|
| 914 | |
|---|
| 915 | for (i=1; i<which; i++) |
|---|
| 916 | { |
|---|
| 917 | first = result+1; |
|---|
| 918 | result = strchr(first,'#'); |
|---|
| 919 | } |
|---|
| 920 | |
|---|
| 921 | if (!result) |
|---|
| 922 | return NULL; |
|---|
| 923 | |
|---|
| 924 | *result = 0; |
|---|
| 925 | ret_res = strdup(first); |
|---|
| 926 | *result = '#'; |
|---|
| 927 | |
|---|
| 928 | return ret_res; |
|---|
| 929 | } |
|---|
| 930 | |
|---|
| 931 | char *MP_remove_comment(char *old_str) |
|---|
| 932 | { |
|---|
| 933 | char *result = strrchr(old_str,'#'); |
|---|
| 934 | char *help; |
|---|
| 935 | char *ret_res; |
|---|
| 936 | |
|---|
| 937 | if (!result) |
|---|
| 938 | return strdup(old_str); |
|---|
| 939 | |
|---|
| 940 | *result = 0; |
|---|
| 941 | help = old_str; |
|---|
| 942 | while (*help == ' ' || *help == '\t') |
|---|
| 943 | help ++; |
|---|
| 944 | |
|---|
| 945 | ret_res = strdup(help); |
|---|
| 946 | *result = '#'; |
|---|
| 947 | |
|---|
| 948 | return ret_res; |
|---|
| 949 | } |
|---|
| 950 | |
|---|
| 951 | char *MP_get_probes(char *str) |
|---|
| 952 | { |
|---|
| 953 | char *result = strrchr(str,'#'); |
|---|
| 954 | |
|---|
| 955 | if (!result) |
|---|
| 956 | return strdup(str); |
|---|
| 957 | |
|---|
| 958 | result++; |
|---|
| 959 | while (*result == ' ' || *result == '\t') |
|---|
| 960 | result ++; |
|---|
| 961 | |
|---|
| 962 | return strdup(result); |
|---|
| 963 | } |
|---|
| 964 | |
|---|
| 965 | void MP_result_chosen(AW_window *aww) |
|---|
| 966 | { |
|---|
| 967 | AW_root *aw_root = mp_main->get_aw_root(); |
|---|
| 968 | char *str = aw_root->awar(MP_AWAR_RESULTPROBES)->read_as_string(), |
|---|
| 969 | *new_str; |
|---|
| 970 | |
|---|
| 971 | AWUSE(aww); |
|---|
| 972 | |
|---|
| 973 | new_str = MP_get_comment(1, str); |
|---|
| 974 | |
|---|
| 975 | aw_root->awar(MP_AWAR_RESULTPROBESCOMMENT)->write_string(new_str); |
|---|
| 976 | free(str); |
|---|
| 977 | free(new_str); |
|---|
| 978 | } |
|---|
| 979 | |
|---|
| 980 | |
|---|
| 981 | |
|---|
| 982 | // |
|---|
| 983 | // functions concerning the server |
|---|
| 984 | // |
|---|
| 985 | |
|---|
| 986 | int MP_init_local_com_struct() |
|---|
| 987 | { |
|---|
| 988 | const char *user = GB_getenvUSER(); |
|---|
| 989 | |
|---|
| 990 | if( aisc_create(mp_pd_gl.link, PT_MAIN, mp_pd_gl.com, |
|---|
| 991 | MAIN_LOCS, PT_LOCS, &mp_pd_gl.locs, |
|---|
| 992 | LOCS_USER, user, |
|---|
| 993 | NULL)){ |
|---|
| 994 | return 1; |
|---|
| 995 | } |
|---|
| 996 | return 0; |
|---|
| 997 | } |
|---|
| 998 | |
|---|
| 999 | const char *MP_probe_pt_look_for_server() |
|---|
| 1000 | { |
|---|
| 1001 | char choice[256]; |
|---|
| 1002 | sprintf(choice,"ARB_PT_SERVER%ld",mp_gl_awars.ptserver); |
|---|
| 1003 | #if defined(DEVEL_RALF) |
|---|
| 1004 | #warning use GBS_ptserver_id_to_choice here ? |
|---|
| 1005 | #endif // DEVEL_RALF |
|---|
| 1006 | GB_ERROR error; |
|---|
| 1007 | error = arb_look_and_start_server(AISC_MAGIC_NUMBER,choice,0); |
|---|
| 1008 | if (error) { |
|---|
| 1009 | aw_message((char *)error); |
|---|
| 1010 | return 0; |
|---|
| 1011 | } |
|---|
| 1012 | return GBS_read_arb_tcp(choice); |
|---|
| 1013 | } |
|---|
| 1014 | |
|---|
| 1015 | |
|---|
| 1016 | int MP_probe_design_send_data(T_PT_PDC pdc) |
|---|
| 1017 | { |
|---|
| 1018 | if (aisc_put(mp_pd_gl.link,PT_PDC, pdc, |
|---|
| 1019 | PDC_CLIPRESULT, P.DESIGNCPLIPOUTPUT, |
|---|
| 1020 | NULL)) return 1; |
|---|
| 1021 | return 0; |
|---|
| 1022 | } |
|---|
| 1023 | |
|---|