| 1 | // =============================================================== // |
|---|
| 2 | // // |
|---|
| 3 | // File : ED4_terminal.cxx // |
|---|
| 4 | // Purpose : // |
|---|
| 5 | // // |
|---|
| 6 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 7 | // http://www.arb-home.de/ // |
|---|
| 8 | // // |
|---|
| 9 | // =============================================================== // |
|---|
| 10 | |
|---|
| 11 | #include <ed4_extern.hxx> |
|---|
| 12 | #include "ed4_class.hxx" |
|---|
| 13 | #include "ed4_awars.hxx" |
|---|
| 14 | #include "ed4_edit_string.hxx" |
|---|
| 15 | #include "ed4_block.hxx" |
|---|
| 16 | #include "ed4_nds.hxx" |
|---|
| 17 | #include "ed4_ProteinViewer.hxx" |
|---|
| 18 | |
|---|
| 19 | #include <aw_preset.hxx> |
|---|
| 20 | #include <aw_awar.hxx> |
|---|
| 21 | #include <aw_msg.hxx> |
|---|
| 22 | #include <aw_root.hxx> |
|---|
| 23 | #include <aw_question.hxx> |
|---|
| 24 | #include <awt_seq_colors.hxx> |
|---|
| 25 | #include <st_window.hxx> |
|---|
| 26 | #include <arbdb.h> |
|---|
| 27 | |
|---|
| 28 | // ----------------------------------- |
|---|
| 29 | // static terminal properties |
|---|
| 30 | |
|---|
| 31 | static ED4_objspec tree_terminal_spec( |
|---|
| 32 | ED4_P_IS_TERMINAL, // static props |
|---|
| 33 | ED4_L_TREE, // level |
|---|
| 34 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 35 | ED4_L_NO_LEVEL, // handled object |
|---|
| 36 | ED4_L_NO_LEVEL // restriction level |
|---|
| 37 | ); |
|---|
| 38 | |
|---|
| 39 | static ED4_objspec bracket_terminal_spec( |
|---|
| 40 | ED4_P_IS_TERMINAL, // static props |
|---|
| 41 | ED4_L_BRACKET, // level |
|---|
| 42 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 43 | ED4_L_NO_LEVEL, // handled object |
|---|
| 44 | ED4_L_NO_LEVEL // restriction level |
|---|
| 45 | ); |
|---|
| 46 | |
|---|
| 47 | static ED4_objspec species_name_terminal_spec( |
|---|
| 48 | ED4_P_IS_TERMINAL, // static props |
|---|
| 49 | ED4_L_SPECIES_NAME, // level |
|---|
| 50 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 51 | ED4_L_SPECIES, // handled object |
|---|
| 52 | ED4_L_NO_LEVEL // restriction level |
|---|
| 53 | ); |
|---|
| 54 | |
|---|
| 55 | static ED4_objspec sequence_info_terminal_spec( |
|---|
| 56 | ED4_P_IS_TERMINAL, // static props |
|---|
| 57 | ED4_L_SEQUENCE_INFO, // level |
|---|
| 58 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 59 | ED4_L_SEQUENCE, // handled object |
|---|
| 60 | ED4_L_NO_LEVEL // restriction level |
|---|
| 61 | ); |
|---|
| 62 | |
|---|
| 63 | static ED4_objspec sequence_terminal_spec( |
|---|
| 64 | ED4_P_IS_TERMINAL, // static props |
|---|
| 65 | ED4_L_SEQUENCE_STRING, // level |
|---|
| 66 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 67 | ED4_L_NO_LEVEL, // handled object |
|---|
| 68 | ED4_L_NO_LEVEL // restriction level |
|---|
| 69 | ); |
|---|
| 70 | |
|---|
| 71 | static ED4_objspec orf_terminal_spec( |
|---|
| 72 | ED4_P_IS_TERMINAL, // static props |
|---|
| 73 | ED4_L_ORF, // level |
|---|
| 74 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 75 | ED4_L_NO_LEVEL, // handled object |
|---|
| 76 | ED4_L_NO_LEVEL // restriction level |
|---|
| 77 | ); |
|---|
| 78 | |
|---|
| 79 | static ED4_objspec pure_text_terminal_spec( |
|---|
| 80 | ED4_P_IS_TERMINAL, // static props |
|---|
| 81 | ED4_L_PURE_TEXT, // level |
|---|
| 82 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 83 | ED4_L_NO_LEVEL, // handled object |
|---|
| 84 | ED4_L_NO_LEVEL // restriction level |
|---|
| 85 | ); |
|---|
| 86 | |
|---|
| 87 | static ED4_objspec spacer_terminal_spec( |
|---|
| 88 | ED4_P_IS_TERMINAL, // static props |
|---|
| 89 | ED4_L_SPACER, // level |
|---|
| 90 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 91 | ED4_L_NO_LEVEL, // handled object |
|---|
| 92 | ED4_L_NO_LEVEL // restriction level |
|---|
| 93 | ); |
|---|
| 94 | |
|---|
| 95 | static ED4_objspec line_terminal_spec( |
|---|
| 96 | ED4_P_IS_TERMINAL, // static props |
|---|
| 97 | ED4_L_LINE, // level |
|---|
| 98 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 99 | ED4_L_NO_LEVEL, // handled object |
|---|
| 100 | ED4_L_NO_LEVEL // restriction level |
|---|
| 101 | ); |
|---|
| 102 | |
|---|
| 103 | static ED4_objspec column_stat_terminal_spec( |
|---|
| 104 | ED4_P_IS_TERMINAL, // static props |
|---|
| 105 | ED4_L_COL_STAT, // level |
|---|
| 106 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 107 | ED4_L_NO_LEVEL, // handled object |
|---|
| 108 | ED4_L_NO_LEVEL // restriction level |
|---|
| 109 | ); |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | char *ED4_terminal::resolve_pointer_to_string_copy(int *str_len) const { |
|---|
| 113 | int len; |
|---|
| 114 | const char *s = resolve_pointer_to_char_pntr(&len); |
|---|
| 115 | char *t = GB_strduplen(s, len); // space for zero byte is allocated by GB_strduplen |
|---|
| 116 | |
|---|
| 117 | if (str_len) *str_len = len; |
|---|
| 118 | return t; |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | const char *ED4_terminal::resolve_pointer_to_char_pntr(int *str_len) const |
|---|
| 122 | { |
|---|
| 123 | GB_TYPES gb_type; |
|---|
| 124 | const char *db_pointer = NULL; |
|---|
| 125 | GBDATA *gbd = get_species_pointer(); |
|---|
| 126 | |
|---|
| 127 | if (!gbd) { |
|---|
| 128 | if (str_len) { |
|---|
| 129 | if (id) *str_len = strlen(id); |
|---|
| 130 | else *str_len = 0; |
|---|
| 131 | } |
|---|
| 132 | return id; // if we don't have a link to the database we have to use our id |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | GB_push_transaction(GLOBAL_gb_main); |
|---|
| 136 | |
|---|
| 137 | const char *copy_of = 0; // if set, return a copy of this string |
|---|
| 138 | |
|---|
| 139 | gb_type = GB_read_type(gbd); |
|---|
| 140 | #if defined(WARN_TODO) |
|---|
| 141 | #warning temporary workaround - gb_type GB_INT and GB_FLOAT in the switch directive must not be displayed but ignored |
|---|
| 142 | #endif |
|---|
| 143 | switch (gb_type) |
|---|
| 144 | { |
|---|
| 145 | case GB_STRING: |
|---|
| 146 | db_pointer = GB_read_char_pntr(gbd); |
|---|
| 147 | if (str_len) { |
|---|
| 148 | *str_len = GB_read_string_count(gbd); |
|---|
| 149 | e4_assert(*str_len == (int)strlen(db_pointer)); |
|---|
| 150 | } |
|---|
| 151 | break; |
|---|
| 152 | case GB_BITS: |
|---|
| 153 | db_pointer = GB_read_bits_pntr(gbd, '.', '+'); |
|---|
| 154 | if (str_len) { |
|---|
| 155 | *str_len = GB_read_bits_count(gbd); |
|---|
| 156 | e4_assert(*str_len == (int)strlen(db_pointer)); |
|---|
| 157 | } |
|---|
| 158 | break; |
|---|
| 159 | case GB_BYTES: |
|---|
| 160 | db_pointer = GB_read_bytes_pntr(gbd); |
|---|
| 161 | if (str_len) { |
|---|
| 162 | *str_len = GB_read_bytes_count(gbd); |
|---|
| 163 | e4_assert(*str_len == (int)strlen(db_pointer)); |
|---|
| 164 | } |
|---|
| 165 | break; |
|---|
| 166 | case GB_DB: |
|---|
| 167 | copy_of = "GB_DB"; |
|---|
| 168 | break; |
|---|
| 169 | case GB_INT: // FIXME: temporary Workaround |
|---|
| 170 | copy_of = "GB_INT"; |
|---|
| 171 | break; |
|---|
| 172 | case GB_INTS: |
|---|
| 173 | copy_of = "GB_INTS"; |
|---|
| 174 | break; |
|---|
| 175 | case GB_FLOAT: // FIXME: temporary Workaround |
|---|
| 176 | copy_of = "GB_FLOAT"; |
|---|
| 177 | break; |
|---|
| 178 | case GB_FLOATS: |
|---|
| 179 | copy_of = "GB_FLOATS"; |
|---|
| 180 | break; |
|---|
| 181 | default: |
|---|
| 182 | printf("Unknown data type - Please contact administrator\n"); |
|---|
| 183 | e4_assert(0); |
|---|
| 184 | break; |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | if (copy_of) { |
|---|
| 188 | e4_assert(db_pointer == 0); |
|---|
| 189 | |
|---|
| 190 | int len = strlen(copy_of); |
|---|
| 191 | db_pointer = GB_strduplen(copy_of, len); |
|---|
| 192 | |
|---|
| 193 | if (str_len) *str_len = len; |
|---|
| 194 | } |
|---|
| 195 | |
|---|
| 196 | GB_pop_transaction(GLOBAL_gb_main); |
|---|
| 197 | |
|---|
| 198 | return db_pointer; |
|---|
| 199 | } |
|---|
| 200 | |
|---|
| 201 | GB_ERROR ED4_terminal::write_sequence(const char *seq, int seq_len) |
|---|
| 202 | { |
|---|
| 203 | GB_ERROR err = 0; |
|---|
| 204 | GBDATA *gbd = get_species_pointer(); |
|---|
| 205 | e4_assert(gbd); // we must have a link to the database! |
|---|
| 206 | |
|---|
| 207 | GB_push_transaction(GLOBAL_gb_main); |
|---|
| 208 | |
|---|
| 209 | int old_seq_len; |
|---|
| 210 | char *old_seq = resolve_pointer_to_string_copy(&old_seq_len); |
|---|
| 211 | |
|---|
| 212 | bool allow_write_data = true; |
|---|
| 213 | if (ED4_ROOT->aw_root->awar(ED4_AWAR_ANNOUNCE_CHECKSUM_CHANGES)->read_int()) { |
|---|
| 214 | long old_checksum = GBS_checksum(old_seq, 1, "-."); |
|---|
| 215 | long new_checksum = GBS_checksum(seq, 1, "-."); |
|---|
| 216 | |
|---|
| 217 | if (old_checksum != new_checksum) { |
|---|
| 218 | if (aw_question(NULL, "Checksum changed!", "Allow, Reject") == 1) { |
|---|
| 219 | allow_write_data = false; |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | } |
|---|
| 223 | } |
|---|
| 224 | |
|---|
| 225 | if (allow_write_data) { |
|---|
| 226 | GB_TYPES gb_type = GB_read_type(gbd); |
|---|
| 227 | switch (gb_type) { |
|---|
| 228 | case GB_STRING: { |
|---|
| 229 | err = GB_write_string(gbd, seq); |
|---|
| 230 | break; |
|---|
| 231 | } |
|---|
| 232 | case GB_BITS: { |
|---|
| 233 | err = GB_write_bits(gbd, seq, seq_len, ".-"); |
|---|
| 234 | break; |
|---|
| 235 | } |
|---|
| 236 | default: { |
|---|
| 237 | e4_assert(0); |
|---|
| 238 | break; |
|---|
| 239 | } |
|---|
| 240 | } |
|---|
| 241 | } |
|---|
| 242 | |
|---|
| 243 | GB_pop_transaction(GLOBAL_gb_main); |
|---|
| 244 | |
|---|
| 245 | if (!err && dynamic_prop&ED4_P_CONSENSUS_RELEVANT) { |
|---|
| 246 | if (old_seq) { |
|---|
| 247 | curr_timestamp = GB_read_clock(GLOBAL_gb_main); |
|---|
| 248 | |
|---|
| 249 | get_parent(ED4_L_MULTI_SPECIES)->to_multi_species_manager() |
|---|
| 250 | ->update_bases_and_rebuild_consensi(old_seq, old_seq_len, get_parent(ED4_L_SPECIES)->to_species_manager(), ED4_U_UP); // bases_check |
|---|
| 251 | } |
|---|
| 252 | else { |
|---|
| 253 | aw_message("Couldn't read old sequence data"); |
|---|
| 254 | } |
|---|
| 255 | |
|---|
| 256 | request_refresh(); |
|---|
| 257 | } |
|---|
| 258 | |
|---|
| 259 | if (old_seq) free(old_seq); |
|---|
| 260 | |
|---|
| 261 | return err; |
|---|
| 262 | } |
|---|
| 263 | |
|---|
| 264 | |
|---|
| 265 | ED4_returncode ED4_terminal::remove_callbacks() // removes callbacks and gb_alignment |
|---|
| 266 | { |
|---|
| 267 | if (get_species_pointer()) { |
|---|
| 268 | set_species_pointer(0); |
|---|
| 269 | tflag.deleted = 1; // @@@ why ? |
|---|
| 270 | clr_property(ED4_P_CURSOR_ALLOWED); |
|---|
| 271 | request_refresh(); |
|---|
| 272 | } |
|---|
| 273 | return ED4_R_OK; |
|---|
| 274 | } |
|---|
| 275 | |
|---|
| 276 | static ARB_ERROR ed4_remove_species_manager_callbacks(ED4_base *base) { // @@@ unused since [8286] |
|---|
| 277 | if (base->is_species_manager()) { |
|---|
| 278 | base->to_species_manager()->remove_all_callbacks(); |
|---|
| 279 | } |
|---|
| 280 | return NULL; |
|---|
| 281 | } |
|---|
| 282 | |
|---|
| 283 | inline void remove_from_consensus(ED4_manager *group_or_species_man) { |
|---|
| 284 | GB_transaction ta(GLOBAL_gb_main); |
|---|
| 285 | ED4_manager *parent_manager = group_or_species_man->parent; |
|---|
| 286 | parent_manager->update_consensus(parent_manager, NULL, group_or_species_man); |
|---|
| 287 | parent_manager->rebuild_consensi(parent_manager, ED4_U_UP); |
|---|
| 288 | } |
|---|
| 289 | |
|---|
| 290 | ED4_returncode ED4_terminal::kill_object() { |
|---|
| 291 | ED4_species_manager *species_manager = get_parent(ED4_L_SPECIES)->to_species_manager(); |
|---|
| 292 | |
|---|
| 293 | if (species_manager->is_consensus_manager()) { // kill whole group |
|---|
| 294 | if (ED4_new_species_multi_species_manager()==species_manager->parent) { |
|---|
| 295 | aw_message("This group has to exist - deleting it isn't allowed"); |
|---|
| 296 | return ED4_R_IMPOSSIBLE; |
|---|
| 297 | } |
|---|
| 298 | |
|---|
| 299 | ED4_manager *group_manager = species_manager->get_parent(ED4_L_GROUP)->to_group_manager(); |
|---|
| 300 | remove_from_consensus(group_manager); |
|---|
| 301 | group_manager->Delete(); |
|---|
| 302 | } |
|---|
| 303 | else { // kill single species/SAI |
|---|
| 304 | remove_from_consensus(species_manager); |
|---|
| 305 | species_manager->Delete(); |
|---|
| 306 | } |
|---|
| 307 | |
|---|
| 308 | return ED4_R_OK; |
|---|
| 309 | } |
|---|
| 310 | |
|---|
| 311 | ED4_base *ED4_terminal::get_competent_clicked_child(AW_pos /* x */, AW_pos /* y */, ED4_properties /* relevant_prop */) |
|---|
| 312 | { |
|---|
| 313 | e4_assert(0); |
|---|
| 314 | return NULL; |
|---|
| 315 | } |
|---|
| 316 | |
|---|
| 317 | ED4_returncode ED4_terminal::handle_move(ED4_move_info * /* moveinfo */) |
|---|
| 318 | { |
|---|
| 319 | e4_assert(0); |
|---|
| 320 | return ED4_R_IMPOSSIBLE; |
|---|
| 321 | } |
|---|
| 322 | |
|---|
| 323 | ED4_returncode ED4_terminal::move_requested_by_child(ED4_move_info * /* moveinfo */) |
|---|
| 324 | { |
|---|
| 325 | e4_assert(0); |
|---|
| 326 | return ED4_R_IMPOSSIBLE; |
|---|
| 327 | } |
|---|
| 328 | |
|---|
| 329 | |
|---|
| 330 | ED4_base *ED4_terminal::get_competent_child(AW_pos /* x */, AW_pos /* y */, ED4_properties /* relevant_prop */) |
|---|
| 331 | { |
|---|
| 332 | e4_assert(0); |
|---|
| 333 | return NULL; |
|---|
| 334 | } |
|---|
| 335 | |
|---|
| 336 | ED4_returncode ED4_terminal::draw_drag_box(AW_pos x, AW_pos y, GB_CSTR text, int cursor_y) // draws drag box of object at location abs_x, abs_y |
|---|
| 337 | { |
|---|
| 338 | ED4_index i; |
|---|
| 339 | AW_pos drag_x, drag_y; |
|---|
| 340 | AW_pos drag_line_x0[3], drag_line_y0[3]; |
|---|
| 341 | AW_pos drag_line_x1[3], drag_line_y1[3]; |
|---|
| 342 | ED4_base *drag_target = NULL; |
|---|
| 343 | AW_pos target_x, target_y; |
|---|
| 344 | ED4_extension location; |
|---|
| 345 | |
|---|
| 346 | if (cursor_y!=-1) { |
|---|
| 347 | ED4_device_manager *device_manager = ED4_ROOT->get_device_manager(); |
|---|
| 348 | drag_x = 0; |
|---|
| 349 | drag_y = (AW_pos)cursor_y; // cursor_y is already in world coordinates! |
|---|
| 350 | location.position[X_POS] = drag_x; |
|---|
| 351 | location.position[Y_POS] = drag_y; |
|---|
| 352 | device_manager->children->search_target_species(&location, ED4_P_HORIZONTAL, &drag_target, ED4_L_NO_LEVEL); |
|---|
| 353 | |
|---|
| 354 | if (drag_target) { |
|---|
| 355 | drag_target->calc_world_coords (&target_x, &target_y); |
|---|
| 356 | current_ed4w()->world_to_win_coords(&target_x, &target_y); |
|---|
| 357 | #define ARROW_LENGTH 3 |
|---|
| 358 | drag_line_x0[0] = target_x + 5; // horizontal |
|---|
| 359 | drag_line_y0[0] = target_y + drag_target->extension.size[HEIGHT]; |
|---|
| 360 | drag_line_x1[0] = drag_line_x0[0] + 50; |
|---|
| 361 | drag_line_y1[0] = target_y + drag_target->extension.size[HEIGHT]; |
|---|
| 362 | |
|---|
| 363 | drag_line_x0[1] = drag_line_x0[0] -ARROW_LENGTH; // arrow |
|---|
| 364 | drag_line_y0[1] = drag_line_y0[0] -ARROW_LENGTH; |
|---|
| 365 | drag_line_x1[1] = drag_line_x0[0]; |
|---|
| 366 | drag_line_y1[1] = drag_line_y0[0]; |
|---|
| 367 | |
|---|
| 368 | drag_line_x0[2] = drag_line_x0[0] -ARROW_LENGTH; // arrow |
|---|
| 369 | drag_line_y0[2] = drag_line_y0[0] + ARROW_LENGTH; |
|---|
| 370 | drag_line_x1[2] = drag_line_x0[0]; |
|---|
| 371 | drag_line_y1[2] = drag_line_y0[0]; |
|---|
| 372 | #undef ARROW_LENGTH |
|---|
| 373 | for (i = 0; i <= 2; i++) { |
|---|
| 374 | current_device()->line(ED4_G_DRAG, drag_line_x0[i], drag_line_y0[i], drag_line_x1[i], drag_line_y1[i], AW_SCREEN); |
|---|
| 375 | } |
|---|
| 376 | } |
|---|
| 377 | } |
|---|
| 378 | |
|---|
| 379 | if (text != NULL) { |
|---|
| 380 | current_device()->text(ED4_G_DRAG, text, (x + 20), (y + INFO_TERM_TEXT_YOFFSET), 0, AW_SCREEN); |
|---|
| 381 | } |
|---|
| 382 | |
|---|
| 383 | return (ED4_R_OK); |
|---|
| 384 | } |
|---|
| 385 | |
|---|
| 386 | ED4_returncode ED4_terminal::move_requested_by_parent(ED4_move_info *) { // handles a move request coming from parent |
|---|
| 387 | e4_assert(0); |
|---|
| 388 | return (ED4_R_IMPOSSIBLE); |
|---|
| 389 | } |
|---|
| 390 | |
|---|
| 391 | void ED4_multi_species_manager::toggle_selected_species() { |
|---|
| 392 | if (all_are_selected()) deselect_all_species_and_SAI(); |
|---|
| 393 | else select_all(false); // species and SAI |
|---|
| 394 | |
|---|
| 395 | ED4_correctBlocktypeAfterSelection(); |
|---|
| 396 | } |
|---|
| 397 | |
|---|
| 398 | #if defined(DEBUG) && 1 |
|---|
| 399 | static inline void dumpEvent(const char *where, AW_event *event) { |
|---|
| 400 | printf("%s: x=%i y=%i\n", where, event->x, event->y); |
|---|
| 401 | } |
|---|
| 402 | #else |
|---|
| 403 | #define dumpEvent(w, e) |
|---|
| 404 | #endif |
|---|
| 405 | |
|---|
| 406 | ED4_returncode ED4_terminal::event_sent_by_parent(AW_event *event, AW_window *aww) // handles an input event coming from parent |
|---|
| 407 | { |
|---|
| 408 | static ED4_species_name_terminal *dragged_name_terminal = 0; |
|---|
| 409 | static int dragged_was_selected; |
|---|
| 410 | static bool pressed_left_button = 0; |
|---|
| 411 | static int other_x, other_y; // coordinates of last event |
|---|
| 412 | static bool right_button_started_on_sequence_term = 0; |
|---|
| 413 | |
|---|
| 414 | switch (event->type) { |
|---|
| 415 | case AW_Mouse_Press: { |
|---|
| 416 | switch (event->button) { |
|---|
| 417 | case AW_BUTTON_LEFT: { |
|---|
| 418 | pressed_left_button = 0; |
|---|
| 419 | if (is_species_name_terminal()) { |
|---|
| 420 | switch (ED4_ROOT->species_mode) { |
|---|
| 421 | case ED4_SM_KILL: { |
|---|
| 422 | if (containing_species_manager()->is_selected()) ED4_ROOT->remove_from_selected(this->to_species_name_terminal()); |
|---|
| 423 | kill_object(); |
|---|
| 424 | return ED4_R_BREAK; |
|---|
| 425 | } |
|---|
| 426 | case ED4_SM_MOVE: { |
|---|
| 427 | dragged_name_terminal = to_species_name_terminal(); |
|---|
| 428 | pressed_left_button = 1; |
|---|
| 429 | other_x = event->x; |
|---|
| 430 | other_y = event->y; |
|---|
| 431 | |
|---|
| 432 | if (!containing_species_manager()->is_selected()) { |
|---|
| 433 | ED4_ROOT->add_to_selected(dragged_name_terminal); |
|---|
| 434 | dragged_was_selected = 0; |
|---|
| 435 | ED4_trigger_instant_refresh(); |
|---|
| 436 | } |
|---|
| 437 | else { |
|---|
| 438 | dragged_was_selected = 1; |
|---|
| 439 | } |
|---|
| 440 | break; |
|---|
| 441 | } |
|---|
| 442 | case ED4_SM_MARK: { |
|---|
| 443 | ED4_species_manager *species_man = get_parent(ED4_L_SPECIES)->to_species_manager(); |
|---|
| 444 | GBDATA *gbd = species_man->get_species_pointer(); |
|---|
| 445 | |
|---|
| 446 | if (gbd) { |
|---|
| 447 | GB_write_flag(gbd, !GB_read_flag(gbd)); |
|---|
| 448 | request_refresh(); |
|---|
| 449 | // ProtView: Refreshing orf terminals |
|---|
| 450 | if (ED4_ROOT->alignment_type == GB_AT_DNA) { |
|---|
| 451 | PV_RefreshWindow(aww->get_root()); |
|---|
| 452 | } |
|---|
| 453 | } |
|---|
| 454 | break; |
|---|
| 455 | } |
|---|
| 456 | default: { |
|---|
| 457 | e4_assert(0); |
|---|
| 458 | break; |
|---|
| 459 | } |
|---|
| 460 | } |
|---|
| 461 | } |
|---|
| 462 | else if (is_bracket_terminal()) { // fold/unfold group |
|---|
| 463 | if (dynamic_prop & ED4_P_IS_FOLDED) { |
|---|
| 464 | to_bracket_terminal()->unfold(); |
|---|
| 465 | } |
|---|
| 466 | else { |
|---|
| 467 | to_bracket_terminal()->fold(); |
|---|
| 468 | } |
|---|
| 469 | } |
|---|
| 470 | else { |
|---|
| 471 | if (dynamic_prop & ED4_P_CURSOR_ALLOWED) { |
|---|
| 472 | ED4_no_dangerous_modes(); |
|---|
| 473 | current_cursor().show_clicked_cursor(event->x, this); |
|---|
| 474 | } |
|---|
| 475 | } |
|---|
| 476 | break; |
|---|
| 477 | } |
|---|
| 478 | case AW_BUTTON_RIGHT: { |
|---|
| 479 | right_button_started_on_sequence_term = 0; |
|---|
| 480 | if (is_bracket_terminal()) { // right click on bracket terminal |
|---|
| 481 | ED4_base *group = get_parent(ED4_L_GROUP); |
|---|
| 482 | if (group) { |
|---|
| 483 | group->to_group_manager()->get_multi_species_manager()->toggle_selected_species(); |
|---|
| 484 | } |
|---|
| 485 | } |
|---|
| 486 | else if (is_species_name_terminal()) { |
|---|
| 487 | ED4_species_manager *species_man = get_parent(ED4_L_SPECIES)->to_species_manager(); |
|---|
| 488 | |
|---|
| 489 | if (species_man->is_consensus_manager()) { // click on consensus-name |
|---|
| 490 | ED4_multi_species_manager *multi_man = species_man->get_parent(ED4_L_MULTI_SPECIES)->to_multi_species_manager(); |
|---|
| 491 | multi_man->toggle_selected_species(); |
|---|
| 492 | } |
|---|
| 493 | else { // click on species or SAI name |
|---|
| 494 | if (!species_man->is_selected()) { // select if not selected |
|---|
| 495 | if (ED4_ROOT->add_to_selected(this->to_species_name_terminal()) == ED4_R_OK) ED4_correctBlocktypeAfterSelection(); |
|---|
| 496 | } |
|---|
| 497 | else { // deselect if already selected |
|---|
| 498 | ED4_ROOT->remove_from_selected(this->to_species_name_terminal()); |
|---|
| 499 | ED4_correctBlocktypeAfterSelection(); |
|---|
| 500 | } |
|---|
| 501 | } |
|---|
| 502 | } |
|---|
| 503 | else if (is_sequence_terminal()) { |
|---|
| 504 | dumpEvent("Press", event); |
|---|
| 505 | |
|---|
| 506 | ED4_no_dangerous_modes(); |
|---|
| 507 | ED4_setColumnblockCorner(event, to_sequence_terminal()); // mark columnblock |
|---|
| 508 | right_button_started_on_sequence_term = 1; |
|---|
| 509 | } |
|---|
| 510 | break; |
|---|
| 511 | } |
|---|
| 512 | default : break; |
|---|
| 513 | } |
|---|
| 514 | break; |
|---|
| 515 | } |
|---|
| 516 | case AW_Mouse_Drag: { |
|---|
| 517 | switch (event->button) { |
|---|
| 518 | case AW_BUTTON_LEFT: { |
|---|
| 519 | if (dragged_name_terminal) { |
|---|
| 520 | ED4_selection_entry *sel_info = dragged_name_terminal->selection_info; |
|---|
| 521 | |
|---|
| 522 | if (pressed_left_button) { |
|---|
| 523 | AW_pos world_x, world_y; |
|---|
| 524 | |
|---|
| 525 | dragged_name_terminal->calc_world_coords(&world_x, &world_y); |
|---|
| 526 | current_ed4w()->world_to_win_coords(&world_x, &world_y); |
|---|
| 527 | |
|---|
| 528 | sel_info->drag_old_x = world_x; |
|---|
| 529 | sel_info->drag_old_y = world_y; |
|---|
| 530 | sel_info->drag_off_x = world_x-other_x; |
|---|
| 531 | sel_info->drag_off_y = world_y-other_y; |
|---|
| 532 | sel_info->old_event_y = -1; |
|---|
| 533 | |
|---|
| 534 | pressed_left_button = 0; |
|---|
| 535 | } |
|---|
| 536 | |
|---|
| 537 | GB_CSTR text = dragged_name_terminal->get_displayed_text(); |
|---|
| 538 | |
|---|
| 539 | if (dragged_name_terminal->dragged) { |
|---|
| 540 | dragged_name_terminal->draw_drag_box(sel_info->drag_old_x, sel_info->drag_old_y, text, sel_info->old_event_y); |
|---|
| 541 | } |
|---|
| 542 | |
|---|
| 543 | AW_pos new_x = sel_info->drag_off_x + event->x; |
|---|
| 544 | AW_pos new_y = sel_info->drag_off_y + event->y; |
|---|
| 545 | |
|---|
| 546 | dragged_name_terminal->draw_drag_box(new_x, new_y, text, event->y); // @@@ event->y ist falsch, falls vertikal gescrollt ist! |
|---|
| 547 | |
|---|
| 548 | sel_info->drag_old_x = new_x; |
|---|
| 549 | sel_info->drag_old_y = new_y; |
|---|
| 550 | sel_info->old_event_y = event->y; |
|---|
| 551 | |
|---|
| 552 | dragged_name_terminal->dragged = true; |
|---|
| 553 | } |
|---|
| 554 | |
|---|
| 555 | break; |
|---|
| 556 | } |
|---|
| 557 | case AW_BUTTON_RIGHT: { |
|---|
| 558 | if (is_sequence_terminal() && right_button_started_on_sequence_term) { |
|---|
| 559 | ED4_no_dangerous_modes(); |
|---|
| 560 | ED4_setColumnblockCorner(event, to_sequence_terminal()); // mark columnblock |
|---|
| 561 | } |
|---|
| 562 | break; |
|---|
| 563 | } |
|---|
| 564 | default: break; |
|---|
| 565 | } |
|---|
| 566 | break; |
|---|
| 567 | } |
|---|
| 568 | case AW_Mouse_Release: { |
|---|
| 569 | switch (event->button) { |
|---|
| 570 | case AW_BUTTON_LEFT: { |
|---|
| 571 | if (dragged_name_terminal) { |
|---|
| 572 | if (dragged_name_terminal->dragged) { |
|---|
| 573 | { |
|---|
| 574 | char *db_pointer = dragged_name_terminal->resolve_pointer_to_string_copy(); |
|---|
| 575 | ED4_selection_entry *sel_info = dragged_name_terminal->selection_info; |
|---|
| 576 | |
|---|
| 577 | dragged_name_terminal->draw_drag_box(sel_info->drag_old_x, sel_info->drag_old_y, db_pointer, sel_info->old_event_y); |
|---|
| 578 | dragged_name_terminal->dragged = false; |
|---|
| 579 | |
|---|
| 580 | free(db_pointer); |
|---|
| 581 | } |
|---|
| 582 | { |
|---|
| 583 | ED4_move_info mi; |
|---|
| 584 | |
|---|
| 585 | mi.object = dragged_name_terminal; |
|---|
| 586 | mi.end_x = event->x; |
|---|
| 587 | mi.end_y = event->y; |
|---|
| 588 | mi.mode = ED4_M_FREE; |
|---|
| 589 | mi.preferred_parent = ED4_L_NO_LEVEL; |
|---|
| 590 | |
|---|
| 591 | dragged_name_terminal->parent->move_requested_by_child(&mi); |
|---|
| 592 | } |
|---|
| 593 | { |
|---|
| 594 | ED4_device_manager *device_manager = ED4_ROOT->get_device_manager(); |
|---|
| 595 | |
|---|
| 596 | for (int i=0; i<device_manager->children->members(); i++) { // when moving species numbers have to be recalculated |
|---|
| 597 | ED4_base *member = device_manager->children->member(i); |
|---|
| 598 | |
|---|
| 599 | if (member->is_area_manager()) { |
|---|
| 600 | member->to_area_manager()->get_multi_species_manager()->update_requested_by_child(); |
|---|
| 601 | } |
|---|
| 602 | } |
|---|
| 603 | } |
|---|
| 604 | } |
|---|
| 605 | if (!dragged_was_selected) { |
|---|
| 606 | ED4_ROOT->remove_from_selected(dragged_name_terminal); |
|---|
| 607 | } |
|---|
| 608 | |
|---|
| 609 | pressed_left_button = 0; |
|---|
| 610 | dragged_name_terminal = 0; |
|---|
| 611 | } |
|---|
| 612 | break; |
|---|
| 613 | } |
|---|
| 614 | |
|---|
| 615 | case AW_BUTTON_RIGHT: { |
|---|
| 616 | if (right_button_started_on_sequence_term && is_sequence_terminal()) { |
|---|
| 617 | dumpEvent("Relea", event); |
|---|
| 618 | ED4_no_dangerous_modes(); |
|---|
| 619 | ED4_setColumnblockCorner(event, to_sequence_terminal()); // mark columnblock |
|---|
| 620 | } |
|---|
| 621 | break; |
|---|
| 622 | } |
|---|
| 623 | default: break; |
|---|
| 624 | } |
|---|
| 625 | break; |
|---|
| 626 | } |
|---|
| 627 | default: |
|---|
| 628 | e4_assert(0); |
|---|
| 629 | break; |
|---|
| 630 | } |
|---|
| 631 | return (ED4_R_OK); |
|---|
| 632 | } |
|---|
| 633 | |
|---|
| 634 | void ED4_terminal::update_requested_children() {} |
|---|
| 635 | |
|---|
| 636 | bool ED4_terminal::calc_bounding_box() { |
|---|
| 637 | // calculates the smallest rectangle containing the object. |
|---|
| 638 | // requests refresh and returns true if bounding box has changed. |
|---|
| 639 | |
|---|
| 640 | bool bb_changed = false; |
|---|
| 641 | |
|---|
| 642 | if (width_link) { |
|---|
| 643 | if (extension.size[WIDTH] != width_link->extension.size[WIDTH]) { // all bounding Boxes have the same size !!! |
|---|
| 644 | extension.size[WIDTH] = width_link->extension.size[WIDTH]; |
|---|
| 645 | bb_changed = true; |
|---|
| 646 | } |
|---|
| 647 | } |
|---|
| 648 | |
|---|
| 649 | if (height_link) { |
|---|
| 650 | if (extension.size[HEIGHT] != height_link->extension.size[HEIGHT]) { |
|---|
| 651 | extension.size[HEIGHT] = height_link->extension.size[HEIGHT]; |
|---|
| 652 | bb_changed = true; |
|---|
| 653 | } |
|---|
| 654 | } |
|---|
| 655 | |
|---|
| 656 | |
|---|
| 657 | if (bb_changed) { |
|---|
| 658 | request_resize_of_linked(); |
|---|
| 659 | request_refresh(); |
|---|
| 660 | } |
|---|
| 661 | return bb_changed; |
|---|
| 662 | } |
|---|
| 663 | |
|---|
| 664 | void ED4_terminal::resize_requested_children() { |
|---|
| 665 | if (update_info.resize) { // likes to resize? |
|---|
| 666 | if (calc_bounding_box()) { |
|---|
| 667 | request_resize(); |
|---|
| 668 | } |
|---|
| 669 | } |
|---|
| 670 | } |
|---|
| 671 | |
|---|
| 672 | |
|---|
| 673 | void ED4_terminal::request_refresh(int clear) { |
|---|
| 674 | update_info.set_refresh(1); |
|---|
| 675 | update_info.set_clear_at_refresh(clear); |
|---|
| 676 | if (parent) parent->refresh_requested_by_child(); |
|---|
| 677 | } |
|---|
| 678 | |
|---|
| 679 | |
|---|
| 680 | ED4_base* ED4_terminal::search_ID(const char *temp_id) |
|---|
| 681 | { |
|---|
| 682 | if (id && strcmp(temp_id, id) == 0) return (this); |
|---|
| 683 | return (NULL); |
|---|
| 684 | } |
|---|
| 685 | |
|---|
| 686 | ED4_terminal::ED4_terminal(const ED4_objspec& spec_, GB_CSTR temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) : |
|---|
| 687 | ED4_base(spec_, temp_id, x, y, width, height, temp_parent) |
|---|
| 688 | { |
|---|
| 689 | memset((char*)&tflag, 0, sizeof(tflag)); |
|---|
| 690 | curr_timestamp = 0; |
|---|
| 691 | } |
|---|
| 692 | |
|---|
| 693 | |
|---|
| 694 | ED4_terminal::~ED4_terminal() { |
|---|
| 695 | for (ED4_window *window = ED4_ROOT->first_window; window; window=window->next) { |
|---|
| 696 | ED4_cursor& cursor = window->cursor; |
|---|
| 697 | if (this == cursor.owner_of_cursor) { |
|---|
| 698 | cursor.init(); |
|---|
| 699 | } |
|---|
| 700 | } |
|---|
| 701 | } |
|---|
| 702 | |
|---|
| 703 | ED4_tree_terminal::ED4_tree_terminal(const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 704 | : ED4_terminal(tree_terminal_spec, temp_id, x, y, width, height, temp_parent) |
|---|
| 705 | { |
|---|
| 706 | } |
|---|
| 707 | |
|---|
| 708 | ED4_returncode ED4_tree_terminal::Show(int IF_ASSERTION_USED(refresh_all), int is_cleared) |
|---|
| 709 | { |
|---|
| 710 | e4_assert(update_info.refresh || refresh_all); |
|---|
| 711 | current_device()->push_clip_scale(); |
|---|
| 712 | if (adjust_clipping_rectangle()) { |
|---|
| 713 | if (update_info.clear_at_refresh && !is_cleared) { |
|---|
| 714 | clear_background(); |
|---|
| 715 | } |
|---|
| 716 | draw(); |
|---|
| 717 | } |
|---|
| 718 | current_device()->pop_clip_scale(); |
|---|
| 719 | |
|---|
| 720 | return (ED4_R_OK); |
|---|
| 721 | } |
|---|
| 722 | |
|---|
| 723 | |
|---|
| 724 | |
|---|
| 725 | ED4_returncode ED4_tree_terminal::draw() { |
|---|
| 726 | AW_pos x, y; |
|---|
| 727 | AW_pos text_x, text_y; |
|---|
| 728 | char *db_pointer; |
|---|
| 729 | |
|---|
| 730 | calc_world_coords(&x, &y); |
|---|
| 731 | current_ed4w()->world_to_win_coords(&x, &y); |
|---|
| 732 | |
|---|
| 733 | text_x = x + CHARACTEROFFSET; // don't change |
|---|
| 734 | text_y = y + SEQ_TERM_TEXT_YOFFSET; |
|---|
| 735 | |
|---|
| 736 | db_pointer = resolve_pointer_to_string_copy(); |
|---|
| 737 | current_device()->text(ED4_G_STANDARD, db_pointer, text_x, text_y, 0, AW_SCREEN); |
|---|
| 738 | free(db_pointer); |
|---|
| 739 | |
|---|
| 740 | return (ED4_R_OK); |
|---|
| 741 | } |
|---|
| 742 | |
|---|
| 743 | ED4_bracket_terminal::ED4_bracket_terminal(const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 744 | : ED4_terminal(bracket_terminal_spec, temp_id, x, y, width, height, temp_parent) |
|---|
| 745 | { |
|---|
| 746 | } |
|---|
| 747 | |
|---|
| 748 | ED4_returncode ED4_bracket_terminal::Show(int IF_ASSERTION_USED(refresh_all), int is_cleared) |
|---|
| 749 | { |
|---|
| 750 | e4_assert(update_info.refresh || refresh_all); |
|---|
| 751 | current_device()->push_clip_scale(); |
|---|
| 752 | if (adjust_clipping_rectangle()) { |
|---|
| 753 | if (update_info.clear_at_refresh && !is_cleared) { |
|---|
| 754 | clear_background(); |
|---|
| 755 | } |
|---|
| 756 | draw(); |
|---|
| 757 | } |
|---|
| 758 | current_device()->pop_clip_scale(); |
|---|
| 759 | |
|---|
| 760 | return ED4_R_OK; |
|---|
| 761 | } |
|---|
| 762 | |
|---|
| 763 | |
|---|
| 764 | ED4_returncode ED4_bracket_terminal::draw() { |
|---|
| 765 | using namespace AW; |
|---|
| 766 | |
|---|
| 767 | Rectangle term_area = get_win_area(current_ed4w()); |
|---|
| 768 | AW_device *device = current_device(); |
|---|
| 769 | |
|---|
| 770 | ED4_multi_species_manager *multi_man = get_parent(ED4_L_GROUP)->to_group_manager()->get_multi_species_manager(); |
|---|
| 771 | if (multi_man->get_no_of_selected_species()) { // if multi_species_manager contains selected species |
|---|
| 772 | #if defined(DEBUG) && 0 |
|---|
| 773 | static bool toggle = false; |
|---|
| 774 | toggle = !toggle; |
|---|
| 775 | device->box(toggle ? ED4_G_SELECTED : ED4_G_SELECTED+1, true, term_area); |
|---|
| 776 | #else // !defined(DEBUG) |
|---|
| 777 | device->box(ED4_G_SELECTED, true, term_area); |
|---|
| 778 | #endif |
|---|
| 779 | } |
|---|
| 780 | |
|---|
| 781 | if (dynamic_prop & ED4_P_IS_FOLDED) { // paint triangle for folded group |
|---|
| 782 | Position t = term_area.upper_left_corner()+Vector(4,4); |
|---|
| 783 | Position b = t+Vector(0,12); |
|---|
| 784 | |
|---|
| 785 | for (int i = 0; i<6; ++i) { |
|---|
| 786 | device->line(ED4_G_STANDARD, t, b, AW_SCREEN); |
|---|
| 787 | t += Vector(1, 1); |
|---|
| 788 | b += Vector(1, -1); |
|---|
| 789 | } |
|---|
| 790 | e4_assert(nearlyEqual(t, b)); |
|---|
| 791 | device->line(ED4_G_STANDARD, t, b, AW_SCREEN); // arrowhead |
|---|
| 792 | } |
|---|
| 793 | else { |
|---|
| 794 | Position l = term_area.upper_left_corner()+Vector(4,5); |
|---|
| 795 | Position r = l+Vector(6,0); |
|---|
| 796 | |
|---|
| 797 | for (int i = 0; i<3; ++i) { |
|---|
| 798 | device->line(ED4_G_STANDARD, l, r, AW_SCREEN); |
|---|
| 799 | l += Vector( 0, 1); |
|---|
| 800 | r += Vector( 0, 1); |
|---|
| 801 | device->line(ED4_G_STANDARD, l, r, AW_SCREEN); |
|---|
| 802 | l += Vector( 1, 1); |
|---|
| 803 | r += Vector(-1, 1); |
|---|
| 804 | } |
|---|
| 805 | e4_assert(nearlyEqual(l, r)); |
|---|
| 806 | device->line(ED4_G_STANDARD, l, r+Vector(0,1), AW_SCREEN); // arrowhead |
|---|
| 807 | } |
|---|
| 808 | |
|---|
| 809 | { |
|---|
| 810 | Rectangle bracket(term_area.upper_left_corner()+Vector(2,2), term_area.diagonal()+Vector(-2,-4)); |
|---|
| 811 | |
|---|
| 812 | device->line(ED4_G_STANDARD, bracket.upper_edge(), AW_SCREEN); |
|---|
| 813 | device->line(ED4_G_STANDARD, bracket.lower_edge(), AW_SCREEN); |
|---|
| 814 | device->line(ED4_G_STANDARD, bracket.left_edge(), AW_SCREEN); |
|---|
| 815 | } |
|---|
| 816 | |
|---|
| 817 | return (ED4_R_OK); |
|---|
| 818 | } |
|---|
| 819 | |
|---|
| 820 | ED4_species_name_terminal::ED4_species_name_terminal(GB_CSTR temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) : |
|---|
| 821 | ED4_text_terminal(species_name_terminal_spec, temp_id, x, y, width, height, temp_parent), |
|---|
| 822 | selection_info(NULL) |
|---|
| 823 | { |
|---|
| 824 | } |
|---|
| 825 | |
|---|
| 826 | #define MAXNAMELEN MAXSPECIESWIDTH |
|---|
| 827 | #define BUFFERSIZE (MAXNAMELEN<<1) |
|---|
| 828 | GB_CSTR ED4_species_name_terminal::get_displayed_text() const |
|---|
| 829 | { |
|---|
| 830 | static char *real_name; |
|---|
| 831 | static int allocatedSize; |
|---|
| 832 | |
|---|
| 833 | if (!real_name || allocatedSize<(BUFFERSIZE+1)) { |
|---|
| 834 | free(real_name); |
|---|
| 835 | allocatedSize = BUFFERSIZE+1; |
|---|
| 836 | real_name = (char*)malloc(allocatedSize); |
|---|
| 837 | } |
|---|
| 838 | memset(real_name, 0, allocatedSize); |
|---|
| 839 | |
|---|
| 840 | ED4_species_manager *spec_man = get_parent(ED4_L_SPECIES)->to_species_manager(); |
|---|
| 841 | |
|---|
| 842 | if (spec_man->is_consensus_manager()) { |
|---|
| 843 | char *db_pointer = resolve_pointer_to_string_copy(); |
|---|
| 844 | char *bracket = strchr(db_pointer, '('); |
|---|
| 845 | |
|---|
| 846 | if (bracket) { |
|---|
| 847 | int bracket_len = strlen(bracket); |
|---|
| 848 | int name_len = bracket-db_pointer; |
|---|
| 849 | |
|---|
| 850 | if (bracket[-1]==' ') { |
|---|
| 851 | name_len--; |
|---|
| 852 | } |
|---|
| 853 | |
|---|
| 854 | if ((name_len+1+bracket_len)<=MAXNAMELEN) { |
|---|
| 855 | strcpy(real_name, db_pointer); |
|---|
| 856 | } |
|---|
| 857 | else { |
|---|
| 858 | int short_name_len = MAXNAMELEN-bracket_len-1; |
|---|
| 859 | |
|---|
| 860 | memcpy(real_name, db_pointer, short_name_len); |
|---|
| 861 | real_name[short_name_len] = ' '; |
|---|
| 862 | strcpy(real_name+short_name_len+1, bracket); |
|---|
| 863 | } |
|---|
| 864 | } |
|---|
| 865 | else { |
|---|
| 866 | strncpy(real_name, db_pointer, BUFFERSIZE); |
|---|
| 867 | } |
|---|
| 868 | |
|---|
| 869 | free(db_pointer); |
|---|
| 870 | } |
|---|
| 871 | else if (spec_man->is_SAI_manager()) { |
|---|
| 872 | char *db_pointer = resolve_pointer_to_string_copy(); |
|---|
| 873 | |
|---|
| 874 | strcpy(real_name, "SAI: "); |
|---|
| 875 | if (strcmp(db_pointer, "ECOLI")==0) { |
|---|
| 876 | const char *name_for_ecoli = ED4_ROOT->aw_root->awar(ED4_AWAR_NDS_ECOLI_NAME)->read_char_pntr(); |
|---|
| 877 | if (name_for_ecoli[0]==0) name_for_ecoli = db_pointer; |
|---|
| 878 | strncpy(real_name+5, name_for_ecoli, BUFFERSIZE-5); |
|---|
| 879 | } |
|---|
| 880 | else { |
|---|
| 881 | strncpy(real_name+5, db_pointer, BUFFERSIZE-5); |
|---|
| 882 | } |
|---|
| 883 | free(db_pointer); |
|---|
| 884 | } |
|---|
| 885 | else { // normal species |
|---|
| 886 | char *result = ED4_get_NDS_text(spec_man); |
|---|
| 887 | strncpy(real_name, result, BUFFERSIZE); |
|---|
| 888 | free(result); |
|---|
| 889 | } |
|---|
| 890 | |
|---|
| 891 | return real_name; |
|---|
| 892 | } |
|---|
| 893 | #undef MAXNAMELEN |
|---|
| 894 | #undef BUFFERSIZE |
|---|
| 895 | |
|---|
| 896 | |
|---|
| 897 | ED4_sequence_info_terminal::ED4_sequence_info_terminal(const char *temp_id, /* GBDATA *gbd, */ AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 898 | : ED4_text_terminal(sequence_info_terminal_spec, temp_id, x, y, width, height, temp_parent) |
|---|
| 899 | { |
|---|
| 900 | } |
|---|
| 901 | |
|---|
| 902 | ED4_consensus_sequence_terminal::ED4_consensus_sequence_terminal(const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 903 | : ED4_sequence_terminal(temp_id, x, y, width, height, temp_parent, false) |
|---|
| 904 | { |
|---|
| 905 | species_name = NULL; |
|---|
| 906 | } |
|---|
| 907 | |
|---|
| 908 | ED4_abstract_sequence_terminal::ED4_abstract_sequence_terminal(const ED4_objspec& spec_, const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 909 | : ED4_text_terminal(spec_, temp_id, x, y, width, height, temp_parent) |
|---|
| 910 | { |
|---|
| 911 | species_name = NULL; |
|---|
| 912 | } |
|---|
| 913 | |
|---|
| 914 | ED4_abstract_sequence_terminal::~ED4_abstract_sequence_terminal() { |
|---|
| 915 | free(species_name); |
|---|
| 916 | } |
|---|
| 917 | |
|---|
| 918 | ED4_orf_terminal::ED4_orf_terminal(const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 919 | : ED4_abstract_sequence_terminal(orf_terminal_spec, temp_id, x, y, width, height, temp_parent) |
|---|
| 920 | { |
|---|
| 921 | aaSequence = 0; |
|---|
| 922 | aaSeqLen = 0; |
|---|
| 923 | aaColor = 0; |
|---|
| 924 | aaStartPos = 0; |
|---|
| 925 | aaStrandType = 0; |
|---|
| 926 | } |
|---|
| 927 | |
|---|
| 928 | GB_alignment_type ED4_orf_terminal::GetAliType() |
|---|
| 929 | { |
|---|
| 930 | return (GB_alignment_type) GB_AT_AA; |
|---|
| 931 | } |
|---|
| 932 | |
|---|
| 933 | ED4_orf_terminal::~ED4_orf_terminal() |
|---|
| 934 | { |
|---|
| 935 | free(aaSequence); |
|---|
| 936 | free(aaColor); |
|---|
| 937 | } |
|---|
| 938 | |
|---|
| 939 | ED4_sequence_terminal::ED4_sequence_terminal(const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent, bool shall_display_secstruct_info_) |
|---|
| 940 | : ED4_abstract_sequence_terminal(sequence_terminal_spec, temp_id, x, y, width, height, temp_parent), |
|---|
| 941 | shall_display_secstruct_info(shall_display_secstruct_info_) |
|---|
| 942 | { |
|---|
| 943 | st_ml_node = NULL; |
|---|
| 944 | } |
|---|
| 945 | |
|---|
| 946 | GB_alignment_type ED4_sequence_terminal::GetAliType() |
|---|
| 947 | { |
|---|
| 948 | return ED4_ROOT->alignment_type; |
|---|
| 949 | } |
|---|
| 950 | |
|---|
| 951 | ED4_pure_text_terminal::ED4_pure_text_terminal(const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 952 | : ED4_text_terminal(pure_text_terminal_spec, temp_id, x, y, width, height, temp_parent) |
|---|
| 953 | { |
|---|
| 954 | } |
|---|
| 955 | |
|---|
| 956 | ED4_returncode ED4_spacer_terminal::Show(int /* refresh_all */, int is_cleared) { |
|---|
| 957 | if (shallDraw) { |
|---|
| 958 | if (update_info.clear_at_refresh && !is_cleared) { |
|---|
| 959 | clear_background(); |
|---|
| 960 | } |
|---|
| 961 | draw(); |
|---|
| 962 | } |
|---|
| 963 | return ED4_R_OK; |
|---|
| 964 | } |
|---|
| 965 | |
|---|
| 966 | |
|---|
| 967 | ED4_returncode ED4_spacer_terminal::draw() { |
|---|
| 968 | #if defined(DEBUG) && 0 |
|---|
| 969 | clear_background(ED4_G_FIRST_COLOR_GROUP); // draw colored spacers to make them visible |
|---|
| 970 | #else |
|---|
| 971 | clear_background(0); |
|---|
| 972 | #endif // DEBUG |
|---|
| 973 | return (ED4_R_OK); |
|---|
| 974 | } |
|---|
| 975 | |
|---|
| 976 | ED4_spacer_terminal::ED4_spacer_terminal(const char *temp_id, bool shallDraw_, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 977 | : ED4_terminal(spacer_terminal_spec, temp_id, x, y, width, height, temp_parent), |
|---|
| 978 | shallDraw(shallDraw_) |
|---|
| 979 | { |
|---|
| 980 | } |
|---|
| 981 | |
|---|
| 982 | ED4_returncode ED4_line_terminal::draw() { |
|---|
| 983 | AW_pos x1, y1; |
|---|
| 984 | calc_world_coords(&x1, &y1); |
|---|
| 985 | current_ed4w()->world_to_win_coords(&x1, &y1); |
|---|
| 986 | |
|---|
| 987 | AW_pos x2 = x1+extension.size[WIDTH]-1; |
|---|
| 988 | AW_pos y2 = y1+extension.size[HEIGHT]-1; |
|---|
| 989 | |
|---|
| 990 | AW_device *device = current_device(); |
|---|
| 991 | |
|---|
| 992 | device->line(ED4_G_STANDARD, x1, y1, x2, y1); |
|---|
| 993 | #if defined(DEBUG) |
|---|
| 994 | device->box(ED4_G_MARKED, true, x1, y1+1, x2-x1+1, y2-y1-1); |
|---|
| 995 | #else |
|---|
| 996 | device->clear_part(x1, y1+1, x2-x1+1, y2-y1-1, AW_ALL_DEVICES); |
|---|
| 997 | #endif // DEBUG |
|---|
| 998 | device->line(ED4_G_STANDARD, x1, y2, x2, y2); |
|---|
| 999 | |
|---|
| 1000 | return ED4_R_OK; |
|---|
| 1001 | } |
|---|
| 1002 | |
|---|
| 1003 | ED4_returncode ED4_line_terminal::Show(int /* refresh_all */, int is_cleared) |
|---|
| 1004 | { |
|---|
| 1005 | if (update_info.clear_at_refresh && !is_cleared) { |
|---|
| 1006 | clear_background(); |
|---|
| 1007 | } |
|---|
| 1008 | draw(); |
|---|
| 1009 | return ED4_R_OK; |
|---|
| 1010 | } |
|---|
| 1011 | |
|---|
| 1012 | |
|---|
| 1013 | ED4_line_terminal::ED4_line_terminal(const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 1014 | : ED4_terminal(line_terminal_spec, temp_id, x, y, width, height, temp_parent) |
|---|
| 1015 | { |
|---|
| 1016 | } |
|---|
| 1017 | |
|---|
| 1018 | // --------------------------------- |
|---|
| 1019 | // ED4_columnStat_terminal |
|---|
| 1020 | |
|---|
| 1021 | ED4_returncode ED4_columnStat_terminal::Show(int IF_ASSERTION_USED(refresh_all), int is_cleared) |
|---|
| 1022 | { |
|---|
| 1023 | e4_assert(update_info.refresh || refresh_all); |
|---|
| 1024 | current_device()->push_clip_scale(); |
|---|
| 1025 | if (adjust_clipping_rectangle()) { |
|---|
| 1026 | if (update_info.clear_at_refresh && !is_cleared) { |
|---|
| 1027 | clear_background(); |
|---|
| 1028 | } |
|---|
| 1029 | draw(); |
|---|
| 1030 | } |
|---|
| 1031 | current_device()->pop_clip_scale(); |
|---|
| 1032 | |
|---|
| 1033 | return ED4_R_OK; |
|---|
| 1034 | } |
|---|
| 1035 | |
|---|
| 1036 | inline char stat2display(int val, bool is_upper_digit) { |
|---|
| 1037 | if (val<0) { |
|---|
| 1038 | e4_assert(val==-1); // -1 indicates that no statistic is existing for that column |
|---|
| 1039 | return '?'; |
|---|
| 1040 | } |
|---|
| 1041 | if (val==20) return ' '; // value if ACGT and - are distributed equally |
|---|
| 1042 | if (val==100) return '^'; // we have only 2 characters to display likelihood (100 cannot be displayed) |
|---|
| 1043 | |
|---|
| 1044 | e4_assert(val>=0 && val<100); |
|---|
| 1045 | |
|---|
| 1046 | return '0' + (is_upper_digit ? (val/10) : (val%10)); |
|---|
| 1047 | } |
|---|
| 1048 | |
|---|
| 1049 | inline int find_significant_positions(int sig, int like_A, int like_C, int like_G, int like_TU, int *sumPtr) { |
|---|
| 1050 | // result == 0 -> no base-char has a significant likelihood (>=sig) |
|---|
| 1051 | // result == 1, 2, 4, 8 -> A, C, G, T/U has a significant likelihood |
|---|
| 1052 | // else -> the sum two of the likelihoods >= sig (bit-or-ed as in line above) |
|---|
| 1053 | |
|---|
| 1054 | int like[4]; |
|---|
| 1055 | like[0] = like_A; |
|---|
| 1056 | like[1] = like_C; |
|---|
| 1057 | like[2] = like_G; |
|---|
| 1058 | like[3] = like_TU; |
|---|
| 1059 | |
|---|
| 1060 | int bestSum = 0; |
|---|
| 1061 | int bestResult = 0; |
|---|
| 1062 | |
|---|
| 1063 | int b, c; |
|---|
| 1064 | for (b=0; b<4; b++) { |
|---|
| 1065 | int sum = like[b]; |
|---|
| 1066 | if (sum>=sig && sum>=bestSum) { |
|---|
| 1067 | bestSum = sum; |
|---|
| 1068 | bestResult = 1<<b; |
|---|
| 1069 | } |
|---|
| 1070 | } |
|---|
| 1071 | |
|---|
| 1072 | if (!bestResult) { |
|---|
| 1073 | for (b=0; b<4; b++) { |
|---|
| 1074 | for (c=b+1; c<4; c++) { |
|---|
| 1075 | int sum = like[b]+like[c]; |
|---|
| 1076 | if (sum>=sig && sum>=bestSum) { |
|---|
| 1077 | bestSum = sum; |
|---|
| 1078 | bestResult = (1<<b)|(1<<c); |
|---|
| 1079 | } |
|---|
| 1080 | } |
|---|
| 1081 | } |
|---|
| 1082 | } |
|---|
| 1083 | |
|---|
| 1084 | if (bestResult) { |
|---|
| 1085 | if (sumPtr) *sumPtr = bestSum; |
|---|
| 1086 | return bestResult; |
|---|
| 1087 | } |
|---|
| 1088 | |
|---|
| 1089 | return 0; |
|---|
| 1090 | } |
|---|
| 1091 | |
|---|
| 1092 | #define PROBE_MATCH_TARGET_STRING_LENGTH 32 |
|---|
| 1093 | |
|---|
| 1094 | GB_CSTR ED4_columnStat_terminal::build_probe_match_string(PosRange range) const { |
|---|
| 1095 | static char result[PROBE_MATCH_TARGET_STRING_LENGTH+1]; // see create_probe_match_window() for length |
|---|
| 1096 | int max_insert = PROBE_MATCH_TARGET_STRING_LENGTH; |
|---|
| 1097 | char *r = result; |
|---|
| 1098 | int significance = int(get_threshold()); |
|---|
| 1099 | ED4_sequence_terminal *seq_term = corresponding_sequence_terminal(); |
|---|
| 1100 | char *seq = seq_term->resolve_pointer_to_string_copy(); |
|---|
| 1101 | |
|---|
| 1102 | for (int pos=range.start(); pos<=range.end(); pos++) { |
|---|
| 1103 | int found = find_significant_positions(significance, likelihood[0][pos], likelihood[1][pos], likelihood[2][pos], likelihood[3][pos], 0); |
|---|
| 1104 | |
|---|
| 1105 | if (found || strchr("-=.", seq[pos])==0) { |
|---|
| 1106 | // '?' is inserted at every base position without significant bases (not at gaps!) |
|---|
| 1107 | |
|---|
| 1108 | *r++ = "NACMGRSVUWYHKDBN"[found]; // this creates a string containing the full IUPAC code |
|---|
| 1109 | |
|---|
| 1110 | if (max_insert--==0) { |
|---|
| 1111 | r--; |
|---|
| 1112 | break; |
|---|
| 1113 | } |
|---|
| 1114 | } |
|---|
| 1115 | } |
|---|
| 1116 | r[0] = 0; |
|---|
| 1117 | free(seq); |
|---|
| 1118 | |
|---|
| 1119 | if (max_insert<0) { |
|---|
| 1120 | aw_message(GBS_global_string("Max. %i bases allowed in Probe Match", PROBE_MATCH_TARGET_STRING_LENGTH)); |
|---|
| 1121 | result[0] = 0; |
|---|
| 1122 | } |
|---|
| 1123 | return result; |
|---|
| 1124 | } |
|---|
| 1125 | #undef PROBE_MATCH_TARGET_STRING_LENGTH |
|---|
| 1126 | |
|---|
| 1127 | ED4_returncode ED4_columnStat_terminal::draw() { |
|---|
| 1128 | if (!update_likelihood()) { |
|---|
| 1129 | aw_message("Can't calculate likelihood."); |
|---|
| 1130 | return ED4_R_IMPOSSIBLE; |
|---|
| 1131 | } |
|---|
| 1132 | |
|---|
| 1133 | AW_pos x, y; |
|---|
| 1134 | calc_world_coords(&x, &y); |
|---|
| 1135 | current_ed4w()->world_to_win_coords(&x, &y); |
|---|
| 1136 | |
|---|
| 1137 | AW_pos term_height = extension.size[HEIGHT]; |
|---|
| 1138 | AW_pos font_height = ED4_ROOT->font_group.get_height(ED4_G_SEQUENCES); |
|---|
| 1139 | AW_pos font_width = ED4_ROOT->font_group.get_width(ED4_G_SEQUENCES); |
|---|
| 1140 | |
|---|
| 1141 | AW_pos text_x = x + CHARACTEROFFSET; |
|---|
| 1142 | AW_pos text_y = y + term_height - font_height; |
|---|
| 1143 | |
|---|
| 1144 | AW_device *device = current_device(); |
|---|
| 1145 | ED4_sequence_terminal *seq_term = corresponding_sequence_terminal(); |
|---|
| 1146 | const ED4_remap *rm = ED4_ROOT->root_group_man->remap(); |
|---|
| 1147 | |
|---|
| 1148 | PosRange index_range = rm->clip_screen_range(seq_term->calc_update_interval()); |
|---|
| 1149 | { |
|---|
| 1150 | int max_seq_len = seq_term->get_length(); |
|---|
| 1151 | int max_seq_pos = rm->sequence_to_screen(max_seq_len); |
|---|
| 1152 | |
|---|
| 1153 | index_range = ExplicitRange(index_range, max_seq_pos); |
|---|
| 1154 | if (index_range.is_empty()) return ED4_R_OK; |
|---|
| 1155 | } |
|---|
| 1156 | |
|---|
| 1157 | const int left = index_range.start(); |
|---|
| 1158 | const int right = index_range.end(); |
|---|
| 1159 | |
|---|
| 1160 | char *sbuffer = new char[right+2]; // used to build displayed terminal content (values = '0'-'9') |
|---|
| 1161 | memset(sbuffer, ' ', right+1); |
|---|
| 1162 | sbuffer[right+1] = 0; // eos |
|---|
| 1163 | |
|---|
| 1164 | AW_pos y2; |
|---|
| 1165 | int r; |
|---|
| 1166 | |
|---|
| 1167 | // Set background: |
|---|
| 1168 | { |
|---|
| 1169 | int significance = int(get_threshold()); |
|---|
| 1170 | // normal columns are colored in ED4_G_STANDARD |
|---|
| 1171 | // all columns with one (or sum of two) probability above 'significance' are back-colored in ED4_G_CBACK_0 |
|---|
| 1172 | // the responsible probabilities (one or two) are back-colored in ED4_G_CBACK_1..ED4_G_CBACK_9 |
|---|
| 1173 | |
|---|
| 1174 | int color = ED4_G_STANDARD; |
|---|
| 1175 | int old_color = ED4_G_STANDARD; |
|---|
| 1176 | |
|---|
| 1177 | AW_pos x2 = text_x + font_width*left + 1; |
|---|
| 1178 | AW_pos old_x2 = x2; |
|---|
| 1179 | |
|---|
| 1180 | PosRange selection; |
|---|
| 1181 | bool is_selected = ED4_get_selected_range(seq_term, selection); |
|---|
| 1182 | |
|---|
| 1183 | for (int i=left; i<=right; i++, x2+=font_width) { // colorize significant columns in ALL rows |
|---|
| 1184 | int p = rm->screen_to_sequence(i); |
|---|
| 1185 | int found = find_significant_positions(significance, likelihood[0][p], likelihood[1][p], likelihood[2][p], likelihood[3][p], 0); |
|---|
| 1186 | |
|---|
| 1187 | if (found) color = ED4_G_CBACK_0; |
|---|
| 1188 | else color = ED4_G_STANDARD; |
|---|
| 1189 | |
|---|
| 1190 | if (is_selected && selection.contains(p)) { |
|---|
| 1191 | color = ED4_G_SELECTED; |
|---|
| 1192 | } |
|---|
| 1193 | |
|---|
| 1194 | if (color!=old_color) { |
|---|
| 1195 | if (x2>old_x2 && old_color!=ED4_G_STANDARD) { |
|---|
| 1196 | device->box(old_color, true, old_x2, y, x2-old_x2, term_height); |
|---|
| 1197 | } |
|---|
| 1198 | old_color = color; |
|---|
| 1199 | old_x2 = x2; |
|---|
| 1200 | } |
|---|
| 1201 | } |
|---|
| 1202 | if (x2>old_x2 && old_color!=ED4_G_STANDARD) { |
|---|
| 1203 | device->box(old_color, true, old_x2, y, x2-old_x2, term_height); |
|---|
| 1204 | } |
|---|
| 1205 | |
|---|
| 1206 | color = ED4_G_STANDARD; |
|---|
| 1207 | x2 = text_x + font_width*left + 1; |
|---|
| 1208 | |
|---|
| 1209 | for (int i=left; i<=right; i++, x2+=font_width) { // colorize significant columns in SINGLE rows |
|---|
| 1210 | int p = rm->screen_to_sequence(i); |
|---|
| 1211 | int sum; |
|---|
| 1212 | int found = find_significant_positions(significance, likelihood[0][p], likelihood[1][p], likelihood[2][p], likelihood[3][p], &sum); |
|---|
| 1213 | |
|---|
| 1214 | if (found && significance<100) { |
|---|
| 1215 | e4_assert(sum>=significance && sum<=100); |
|---|
| 1216 | color = ED4_G_CBACK_1+((sum-significance)*(ED4_G_CBACK_9-ED4_G_CBACK_1))/(100-significance); |
|---|
| 1217 | e4_assert(color>=ED4_G_CBACK_1 && color<=ED4_G_CBACK_9); |
|---|
| 1218 | } |
|---|
| 1219 | else { |
|---|
| 1220 | color = ED4_G_STANDARD; |
|---|
| 1221 | } |
|---|
| 1222 | |
|---|
| 1223 | if (color!=ED4_G_STANDARD) { |
|---|
| 1224 | int bit; |
|---|
| 1225 | |
|---|
| 1226 | for (r=3, y2=text_y+1, bit=1<<3; |
|---|
| 1227 | r>=0; |
|---|
| 1228 | r--, y2-=COLUMN_STAT_ROW_HEIGHT(font_height), bit>>=1) |
|---|
| 1229 | { |
|---|
| 1230 | if (found&bit) { |
|---|
| 1231 | device->box(color, true, x2, y2-2*font_height+1, font_width, 2*font_height); |
|---|
| 1232 | } |
|---|
| 1233 | } |
|---|
| 1234 | } |
|---|
| 1235 | } |
|---|
| 1236 | } |
|---|
| 1237 | |
|---|
| 1238 | // Draw text: |
|---|
| 1239 | for (r=3, y2=text_y; |
|---|
| 1240 | r>=0; |
|---|
| 1241 | r--, y2-=COLUMN_STAT_ROW_HEIGHT(font_height)) { // 4 rows (one for T/U, G, C and A) |
|---|
| 1242 | |
|---|
| 1243 | int gc = ED4_ROOT->sequence_colors->char_2_gc[(unsigned char)"ACGU"[r]]; |
|---|
| 1244 | int i; |
|---|
| 1245 | for (i=left; i<=right; i++) { |
|---|
| 1246 | int p = rm->screen_to_sequence(i); |
|---|
| 1247 | int val = likelihood[r][p]; |
|---|
| 1248 | sbuffer[i] = stat2display(val, 0); // calc lower digit |
|---|
| 1249 | } |
|---|
| 1250 | device->text(gc, sbuffer, text_x+font_width*0.2, y2, 0, AW_SCREEN, right); // draw lower-significant digit (shifted a bit to the right) |
|---|
| 1251 | |
|---|
| 1252 | for (i=left; i<=right; i++) { |
|---|
| 1253 | int p = rm->screen_to_sequence(i); |
|---|
| 1254 | int val = likelihood[r][p]; |
|---|
| 1255 | sbuffer[i] = stat2display(val, 1); // calc upper digit |
|---|
| 1256 | } |
|---|
| 1257 | device->text(gc, sbuffer, text_x, y2-font_height, 0, AW_SCREEN, right); // draw higher-significant digit |
|---|
| 1258 | } |
|---|
| 1259 | |
|---|
| 1260 | delete [] sbuffer; |
|---|
| 1261 | return ED4_R_OK; |
|---|
| 1262 | } |
|---|
| 1263 | |
|---|
| 1264 | int ED4_columnStat_terminal::update_likelihood() { |
|---|
| 1265 | ED4_sequence_terminal *seq_term = corresponding_sequence_terminal(); |
|---|
| 1266 | |
|---|
| 1267 | return STAT_update_ml_likelihood(ED4_ROOT->st_ml, likelihood, latest_update, 0, seq_term->st_ml_node); |
|---|
| 1268 | } |
|---|
| 1269 | |
|---|
| 1270 | ED4_columnStat_terminal::ED4_columnStat_terminal(GB_CSTR temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) : |
|---|
| 1271 | ED4_text_terminal(column_stat_terminal_spec, temp_id, x, y, width, height, temp_parent) |
|---|
| 1272 | { |
|---|
| 1273 | for (int i=0; i<4; i++) likelihood[i] = 0; |
|---|
| 1274 | latest_update = 0; |
|---|
| 1275 | } |
|---|
| 1276 | |
|---|
| 1277 | ED4_columnStat_terminal::~ED4_columnStat_terminal() |
|---|
| 1278 | { |
|---|
| 1279 | for (int i=0; i<4; i++) free(likelihood[i]); |
|---|
| 1280 | } |
|---|
| 1281 | |
|---|
| 1282 | // --------------------------------- |
|---|
| 1283 | // ED4_reference_terminals |
|---|
| 1284 | |
|---|
| 1285 | void ED4_reference_terminals::clear() |
|---|
| 1286 | { |
|---|
| 1287 | delete ref_sequence_info; |
|---|
| 1288 | delete ref_sequence; |
|---|
| 1289 | delete ref_column_stat; |
|---|
| 1290 | delete ref_column_stat_info; |
|---|
| 1291 | null(); |
|---|
| 1292 | } |
|---|
| 1293 | |
|---|
| 1294 | void ED4_reference_terminals::init(ED4_sequence_info_terminal *ref_sequence_info_, |
|---|
| 1295 | ED4_sequence_terminal *ref_sequence_, |
|---|
| 1296 | ED4_sequence_info_terminal *ref_column_stat_info_, |
|---|
| 1297 | ED4_columnStat_terminal *ref_column_stat_) |
|---|
| 1298 | { |
|---|
| 1299 | clear(); |
|---|
| 1300 | ref_sequence_info = ref_sequence_info_; |
|---|
| 1301 | ref_sequence = ref_sequence_; |
|---|
| 1302 | ref_column_stat_info = ref_column_stat_info_; |
|---|
| 1303 | ref_column_stat = ref_column_stat_; |
|---|
| 1304 | } |
|---|