ARB
ED4_ProteinViewer.cxx
Go to the documentation of this file.
1 // =======================================================================================
2 //
3 // File : ED4_ProteinViewer.cxx
4 // Purpose : Protein Viewer: Dynamical translation and display of
5 // aminoacid sequences in the dna alignment.
6 // Author : Yadhu Kumar (yadhu@arb-home.de)
7 // web site : http://www.arb-home.de/
8 //
9 // Copyright Department of Microbiology (Technical University Munich)
10 //
11 // =======================================================================================
12 
13 #include "ed4_ProteinViewer.hxx"
14 #include "ed4_edit_string.hxx"
15 #include "ed4_seq_colors.hxx"
16 #include "ed4_class.hxx"
17 
18 #include <AP_pro_a_nucs.hxx>
19 #include <AP_codon_table.hxx>
20 #include <Translate.hxx>
21 #include <aw_question.hxx>
22 #include <aw_preset.hxx>
23 #include <aw_awars.hxx>
24 #include <aw_msg.hxx>
25 #include <aw_root.hxx>
26 #include <arbdbt.h>
27 
28 #include <iostream>
29 
30 using namespace std;
31 
32 // Definitions used
33 #define FORWARD_STRAND 1
34 #define COMPLEMENTARY_STRAND 2
35 #define DB_FIELD_STRAND 3
36 
37 #define FORWARD_STRANDS 3
38 #define COMPLEMENTARY_STRANDS 3
39 #define DB_FIELD_STRANDS 1
40 
41 enum {
42  PV_MARKED = 0,
46 };
47 
48 // Global Variables
49 extern GBDATA *GLOBAL_gb_main;
50 
51 static bool gTerminalsCreated = false;
52 static int PV_AA_Terminals4Species = 0;
53 static int gMissingTransTable = 0;
54 static int gMissingCodonStart = 0;
55 static bool gbWritingData = false;
56 static int giNewAlignments = 0;
57 
58 static AW_repeated_question *ASKtoOverWriteData = NULp;
59 
60 static bool PV_LookForNewTerminals(AW_root *root) {
61  bool bTerminalsFound = true;
62 
63  int all = root->awar(AWAR_PV_DISPLAY_ALL)->read_int();
64  int all_f1 = root->awar(AWAR_PROTVIEW_FORWARD_STRAND_1)->read_int();
65  int all_f2 = root->awar(AWAR_PROTVIEW_FORWARD_STRAND_2)->read_int();
66  int all_f3 = root->awar(AWAR_PROTVIEW_FORWARD_STRAND_3)->read_int();
67  int all_c1 = root->awar(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_1)->read_int();
68  int all_c2 = root->awar(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_2)->read_int();
69  int all_c3 = root->awar(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_3)->read_int();
70  int all_db = root->awar(AWAR_PROTVIEW_DEFINED_FIELDS)->read_int();
71 
72  int sel = root->awar(AWAR_PV_SELECTED)->read_int();
73  int sel_db = root->awar(AWAR_PV_SELECTED_DB)->read_int();
74  int sel_f1 = root->awar(AWAR_PV_SELECTED_FS_1)->read_int();
75  int sel_f2 = root->awar(AWAR_PV_SELECTED_FS_2)->read_int();
76  int sel_f3 = root->awar(AWAR_PV_SELECTED_FS_3)->read_int();
77  int sel_c1 = root->awar(AWAR_PV_SELECTED_CS_1)->read_int();
78  int sel_c2 = root->awar(AWAR_PV_SELECTED_CS_2)->read_int();
79  int sel_c3 = root->awar(AWAR_PV_SELECTED_CS_3)->read_int();
80 
81  int mrk = root->awar(AWAR_PV_MARKED)->read_int();
82  int mrk_db = root->awar(AWAR_PV_MARKED_DB)->read_int();
83  int mrk_f1 = root->awar(AWAR_PV_MARKED_FS_1)->read_int();
84  int mrk_f2 = root->awar(AWAR_PV_MARKED_FS_2)->read_int();
85  int mrk_f3 = root->awar(AWAR_PV_MARKED_FS_3)->read_int();
86  int mrk_c1 = root->awar(AWAR_PV_MARKED_CS_1)->read_int();
87  int mrk_c2 = root->awar(AWAR_PV_MARKED_CS_2)->read_int();
88  int mrk_c3 = root->awar(AWAR_PV_MARKED_CS_3)->read_int();
89 
90  int cur = root->awar(AWAR_PV_CURSOR)->read_int();
91  int cur_db = root->awar(AWAR_PV_CURSOR_DB)->read_int();
92  int cur_f1 = root->awar(AWAR_PV_CURSOR_FS_1)->read_int();
93  int cur_f2 = root->awar(AWAR_PV_CURSOR_FS_2)->read_int();
94  int cur_f3 = root->awar(AWAR_PV_CURSOR_FS_3)->read_int();
95  int cur_c1 = root->awar(AWAR_PV_CURSOR_CS_1)->read_int();
96  int cur_c2 = root->awar(AWAR_PV_CURSOR_CS_2)->read_int();
97  int cur_c3 = root->awar(AWAR_PV_CURSOR_CS_3)->read_int();
98 
99  // Test whether any of the options are selected or not?
100  if ((all && (all_f1 || all_f2 || all_f3 || all_c1 || all_c2 || all_c3 || all_db)) ||
101  (sel && (sel_db || sel_f1 || sel_f2 || sel_f3 || sel_c1 || sel_c2 || sel_c3)) ||
102  (mrk && (mrk_db || mrk_f1 || mrk_f2 || mrk_f3 || mrk_c1 || mrk_c2 || mrk_c3)) ||
103  (cur && (cur_db || cur_f1 || cur_f2 || cur_f3 || cur_c1 || cur_c2 || cur_c3)))
104  {
105  // if so, then test whether the terminals are created already or not?
106  if (gTerminalsCreated) {
107  // if yes, then set the flag to true
108  bTerminalsFound = true;
109  }
110  else {
111  // if not, then new terminals has to be created
112  bTerminalsFound = false;
113  }
114  }
115  return bTerminalsFound;
116 }
117 
118 static void PV_HideTerminal(ED4_orf_terminal *orfTerm) {
119  ED4_sequence_manager *seqManager = orfTerm->get_parent(LEV_SEQUENCE)->to_sequence_manager();
120  seqManager->hide_children();
121 }
122 
123 static void PV_UnHideTerminal(ED4_orf_terminal *orfTerm) {
124  ED4_sequence_manager *seqManager = orfTerm->get_parent(LEV_SEQUENCE)->to_sequence_manager();
125  seqManager->unhide_children();
126 }
127 
128 static void PV_HideAllTerminals() {
129  ED4_terminal *terminal = NULp;
130  for (terminal = ED4_ROOT->root_group_man->get_first_terminal();
131  terminal;
132  terminal = terminal->get_next_terminal())
133  {
134  if (terminal->is_orf_terminal()) {
135  ED4_orf_terminal *orfTerm = terminal->to_orf_terminal();
136  PV_HideTerminal(orfTerm);
137  }
138  }
139 }
140 
141 
142 static void PV_ManageTerminalDisplay(AW_root *root, ED4_orf_terminal *orfTerm, long int DispMode) {
143  int all, af_1, af_2, af_3, ac_1, ac_2, ac_3, adb;
144  all = root->awar(AWAR_PV_DISPLAY_ALL)->read_int();
152 
153  int mrk, mf_1, mf_2, mf_3, mc_1, mc_2, mc_3, mdb;
154  mrk = root->awar(AWAR_PV_MARKED)->read_int();
155  mdb = root->awar(AWAR_PV_MARKED_DB)->read_int();
156  mf_1 = root->awar(AWAR_PV_MARKED_FS_1)->read_int();
157  mf_2 = root->awar(AWAR_PV_MARKED_FS_2)->read_int();
158  mf_3 = root->awar(AWAR_PV_MARKED_FS_3)->read_int();
159  mc_1 = root->awar(AWAR_PV_MARKED_CS_1)->read_int();
160  mc_2 = root->awar(AWAR_PV_MARKED_CS_2)->read_int();
161  mc_3 = root->awar(AWAR_PV_MARKED_CS_3)->read_int();
162 
163  int sel, sf_1, sf_2, sf_3, sc_1, sc_2, sc_3, sdb;
164  sel = root->awar(AWAR_PV_SELECTED)->read_int();
165  sdb = root->awar(AWAR_PV_SELECTED_DB)->read_int();
166  sf_1 = root->awar(AWAR_PV_SELECTED_FS_1)->read_int();
167  sf_2 = root->awar(AWAR_PV_SELECTED_FS_2)->read_int();
168  sf_3 = root->awar(AWAR_PV_SELECTED_FS_3)->read_int();
169  sc_1 = root->awar(AWAR_PV_SELECTED_CS_1)->read_int();
170  sc_2 = root->awar(AWAR_PV_SELECTED_CS_2)->read_int();
171  sc_3 = root->awar(AWAR_PV_SELECTED_CS_3)->read_int();
172 
173  int cur, cf_1, cf_2, cf_3, cc_1, cc_2, cc_3, cdb;
174  cur = root->awar(AWAR_PV_CURSOR)->read_int();
175  cdb = root->awar(AWAR_PV_CURSOR_DB)->read_int();
176  cf_1 = root->awar(AWAR_PV_CURSOR_FS_1)->read_int();
177  cf_2 = root->awar(AWAR_PV_CURSOR_FS_2)->read_int();
178  cf_3 = root->awar(AWAR_PV_CURSOR_FS_3)->read_int();
179  cc_1 = root->awar(AWAR_PV_CURSOR_CS_1)->read_int();
180  cc_2 = root->awar(AWAR_PV_CURSOR_CS_2)->read_int();
181  cc_3 = root->awar(AWAR_PV_CURSOR_CS_3)->read_int();
182 
183  // Get the AA sequence flag - says which strand we are in
184  int aaStrandType = int(orfTerm->GET_aaStrandType());
185  // Check the display options and make visible or hide the AA seq terminal
186  switch (aaStrandType) {
187  case FORWARD_STRAND: {
188  int aaStartPos = int(orfTerm->GET_aaStartPos());
189  switch (aaStartPos) {
190  case 1:
191  switch (DispMode) {
192  case PV_ALL: (all && af_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
193  case PV_MARKED: (mrk && mf_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
194  case PV_SELECTED: (sel && sf_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
195  case PV_CURSOR: (cur && cf_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
196  }
197  break;
198  case 2:
199  switch (DispMode) {
200  case PV_ALL: (all && af_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
201  case PV_MARKED: (mrk && mf_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
202  case PV_SELECTED: (sel && sf_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
203  case PV_CURSOR: (cur && cf_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
204  }
205  break;
206  case 3:
207  switch (DispMode) {
208  case PV_ALL: (all && af_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
209  case PV_MARKED: (mrk && mf_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
210  case PV_SELECTED: (sel && sf_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
211  case PV_CURSOR: (cur && cf_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
212  }
213  break;
214  }
215  break;
216  }
217  case COMPLEMENTARY_STRAND: {
218  int aaStartPos = int(orfTerm->GET_aaStartPos());
219  switch (aaStartPos) {
220  case 1:
221  switch (DispMode) {
222  case PV_ALL: (all && ac_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
223  case PV_MARKED: (mrk && mc_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
224  case PV_SELECTED: (sel && sc_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
225  case PV_CURSOR: (cur && cc_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
226  }
227  break;
228  case 2:
229  switch (DispMode) {
230  case PV_ALL: (all && ac_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
231  case PV_MARKED: (mrk && mc_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
232  case PV_SELECTED: (sel && sc_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
233  case PV_CURSOR: (cur && cc_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
234  }
235  break;
236  case 3:
237  switch (DispMode) {
238  case PV_ALL: (all && ac_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
239  case PV_MARKED: (mrk && mc_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
240  case PV_SELECTED: (sel && sc_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
241  case PV_CURSOR: (cur && cc_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
242  }
243  break;
244  }
245  break;
246  }
247  case DB_FIELD_STRAND:
248  switch (DispMode) {
249  case PV_ALL: (all && adb) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
250  case PV_MARKED: (mrk && mdb) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
251  case PV_SELECTED: (sel && sdb) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
252  case PV_CURSOR: (cur && cdb) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
253  }
254  break;
255  }
256 }
257 
258 static void PV_ManageTerminals(AW_root *root) {
259 
260  // First Hide all orf Terminals
262 
263  int dispAll = root->awar(AWAR_PV_DISPLAY_ALL)->read_int();
264  if (dispAll) {
266  terminal;
267  terminal = terminal->get_next_terminal())
268  {
269  if (terminal->is_orf_terminal()) {
270  ED4_orf_terminal *orfTerm = terminal->to_orf_terminal();
271  PV_ManageTerminalDisplay(root, orfTerm, PV_ALL);
272  }
273  }
274  }
275 
276  int dispMarked = root->awar(AWAR_PV_MARKED)->read_int();
277  if (dispMarked) {
278  GB_transaction ta(GLOBAL_gb_main);
279  int marked = GBT_count_marked_species(GLOBAL_gb_main);
280  if (marked) {
281  for (GBDATA *gbSpecies = GBT_first_marked_species(GLOBAL_gb_main);
282  gbSpecies;
283  gbSpecies = GBT_next_marked_species(gbSpecies))
284  {
285  ED4_species_name_terminal *spNameTerm = ED4_find_species_name_terminal(GBT_get_name_or_description(gbSpecies));
286  if (spNameTerm) {
287  ED4_terminal *terminal = spNameTerm->corresponding_sequence_terminal();
288  for (int i=0; i<PV_AA_Terminals4Species; i++) {
289  // get the corresponding orf_terminal skipping sequence_info terminal
290  // $$$$$ sequence_terminal->sequence_info_terminal->aa_sequence_terminal $$$$$$
291  terminal = terminal->get_next_terminal()->get_next_terminal();
292  // Make sure it is ORF terminal
293  if (terminal->is_orf_terminal()) {
294  ED4_orf_terminal *orfTerm = terminal->to_orf_terminal();
295  PV_ManageTerminalDisplay(root, orfTerm, PV_MARKED);
296  }
297  }
298  }
299  }
300  }
301  }
302 
303  int dispSelected = root->awar(AWAR_PV_SELECTED)->read_int();
304  if (dispSelected) {
306  terminal;
307  terminal = terminal->get_next_terminal())
308  {
309  if (terminal->is_sequence_terminal()) {
310  ED4_species_manager *speciesManager = terminal->get_parent(LEV_SPECIES)->to_species_manager();
311  if (speciesManager->is_species_seq_terminal()) {
312  // we are in the sequence terminal section of a species
313  // walk through all the corresponding ORF terminals for the species and
314  // hide or unhide the terminals based on the display options set by the user
315  if (speciesManager->is_selected()) {
316  for (int i=0; i<PV_AA_Terminals4Species; i++) {
317  // get the corresponding orf_terminal skipping sequence_info terminal
318  // $$$$$ sequence_terminal->sequence_info_terminal->aa_sequence_terminal $$$$$$
319  terminal = terminal->get_next_terminal()->get_next_terminal();
320  // Make sure it is ORF terminal
321  if (terminal->is_orf_terminal()) {
322  ED4_orf_terminal *orfTerm = terminal->to_orf_terminal();
323  PV_ManageTerminalDisplay(root, orfTerm, PV_SELECTED);
324  }
325  }
326  }
327  }
328  }
329  }
330  }
331 
332  int dispAtCursor = root->awar(AWAR_PV_CURSOR)->read_int();
333  if (dispAtCursor) {
334  // only display terminals for species at cursor
336  ED4_MostRecentWinContext context;
337  ED4_cursor& cursor = current_cursor();
338 
339  if (cursor.owner_of_cursor) {
340  // Get The Cursor Terminal And The Corresponding Aa_Sequence Terminals And Set The Display Options
341  ED4_terminal *cursorTerminal = cursor.owner_of_cursor;
342  if (cursorTerminal->is_species_seq_terminal()) {
343  for (int i=0; i<PV_AA_Terminals4Species; i++) {
344  // get the corresponding orf_terminal skipping sequence_info terminal
345  // $$$$$ sequence_terminal->sequence_info_terminal->aa_sequence_terminal $$$$$$
346  cursorTerminal = cursorTerminal->get_next_terminal()->get_next_terminal();
347  // Make sure it is ORF terminal
348  if (cursorTerminal->is_orf_terminal()) {
349  ED4_orf_terminal *orfTerm = cursorTerminal->to_orf_terminal();
350  PV_ManageTerminalDisplay(root, orfTerm, PV_CURSOR);
351  }
352  }
353  }
354  }
355  }
356  }
357 }
358 
360  // Manage the terminals showing only those selected by the user
361  if (gTerminalsCreated) {
362  PV_ManageTerminals(root);
363  }
364  // Refresh all windows
365  // ED4_ROOT->refresh_all_windows(0);
366 }
367 
368 static GB_ERROR PV_ComplementarySequence(char *sequence) {
369  char T_or_U;
370  GB_ERROR error = GBT_determine_T_or_U(ED4_ROOT->alignment_type, &T_or_U, "complement");
371  if (!error) {
372  int seqLen = strlen(sequence);
373  char *complementarySeq = GBT_complementNucSequence((const char*) sequence, seqLen, T_or_U);
374 
375  strcpy(sequence, complementarySeq);
376  free(complementarySeq);
377  }
378  return error;
379 }
380 
381 static void PV_WriteTranslatedSequenceToDB(ED4_orf_terminal *aaSeqTerm, const char *spName) {
382  GB_ERROR error = GB_begin_transaction(GLOBAL_gb_main);
383  GBDATA *gb_species = GBT_find_species(GLOBAL_gb_main, spName);
384  if (!gb_species) error = GBS_global_string("Species '%s' does not exist", spName);
385  else {
386  char *defaultAlignment = GBT_get_default_alignment(GLOBAL_gb_main);
387  if (!defaultAlignment) error = GB_await_error();
388  else {
389  GBDATA *gb_SeqData = GBT_find_sequence(gb_species, defaultAlignment);
390  if (!gb_SeqData) {
391  error = GB_have_error()
392  ? GB_await_error()
393  : GBS_global_string("Species '%s' has no data in alignment '%s'", spName, defaultAlignment);
394  }
395  else {
396  char *str_SeqData = GB_read_string(gb_SeqData);
397  if (!str_SeqData) error = GB_await_error();
398  else {
399  int aaStrandType = int(aaSeqTerm->GET_aaStrandType());
400  if (aaStrandType == COMPLEMENTARY_STRAND) {
401  GB_ERROR compl_err = PV_ComplementarySequence(str_SeqData);
402  if (compl_err) error = GBS_global_string("Failed to calc complementary strand (Reason: %s)", compl_err);
403  }
404 
405  if (!error) {
406  char newAlignmentName[100];
407  int aaStartPos = int(aaSeqTerm->GET_aaStartPos());
408 
409  switch (aaStrandType) {
410  case FORWARD_STRAND: sprintf(newAlignmentName, "ali_pro_ProtView_forward_start_pos_%ld", (long)aaStartPos); break;
411  case COMPLEMENTARY_STRAND: sprintf(newAlignmentName, "ali_pro_ProtView_complementary_start_pos_%ld", (long)aaStartPos); break;
412  case DB_FIELD_STRAND: sprintf(newAlignmentName, "ali_pro_ProtView_database_field_start_pos_%ld", (long)aaStartPos); break;
413  }
414 
415  int len = GB_read_string_count(gb_SeqData);
416  translate_nuc2aa(AWT_default_protein_type(), str_SeqData, len, aaStartPos-1, false, true, false, NULp);
417 
418  // Create alignment data to store the translated sequence
419  GBDATA *gb_presets = GBT_get_presets(GLOBAL_gb_main);
420  GBDATA *gb_alignment_exists = GB_find_string(gb_presets, "alignment_name", newAlignmentName, GB_IGNORE_CASE, SEARCH_GRANDCHILD);
421  GBDATA *gb_new_alignment = NULp;
422 
423  if (gb_alignment_exists) {
424  int skip_sp = 0;
425  char *question = NULp;
426  GBDATA *gb_seq_data = GBT_find_sequence(gb_species, newAlignmentName);
427  if (gb_seq_data) {
429  question = GBS_global_string_copy("\"%s\" contain data in the alignment \"%s\"!", spName, newAlignmentName);
430  skip_sp = ASKtoOverWriteData->get_answer("overwrite_translated", question, "Overwrite, Skip Species", "all", false);
431  }
432  if (skip_sp) {
433  error = GBS_global_string_copy("%s You chose to skip this Species!", question);
434  }
435  else {
436  gb_new_alignment = GBT_get_alignment(GLOBAL_gb_main, newAlignmentName);
437  if (!gb_new_alignment) error = GB_await_error();
438  }
439  free(question);
440  }
441  else {
442  long aliLen = GBT_get_alignment_len(GLOBAL_gb_main, defaultAlignment);
443  gb_new_alignment = GBT_create_alignment(GLOBAL_gb_main, newAlignmentName, aliLen/3+1, 0, 1, "ami");
444 
445  if (!gb_new_alignment) error = GB_await_error();
446  else giNewAlignments++;
447  }
448 
449  if (!error) {
450  GBDATA *gb_ProSeqData = GBT_add_data(gb_species, newAlignmentName, "data", GB_STRING);
451  if (!gb_ProSeqData) error = GB_await_error();
452  else error = GB_write_string(gb_ProSeqData, str_SeqData);
453  }
454 
455  if (!error) error = GBT_check_data(GLOBAL_gb_main, NULp);
456  }
457 
458  free(str_SeqData);
459  }
460  }
461  free(defaultAlignment);
462  }
463  }
464  GB_end_transaction_show_error(GLOBAL_gb_main, error, aw_message);
465 }
466 
467 static void PV_SaveData(AW_window */*aww*/) {
468  // IDEA:
469  // 1. walk thru the orf terminals
470  // 2. check the visibility status
471  // 3. select only the visible terminals
472  // 4. get the corresponding species name
473  // 5. translate the sequence
474  // 6. write to the database
475  gbWritingData = true;
476  if (gTerminalsCreated) {
477  ASKtoOverWriteData = new AW_repeated_question;
478 
480  terminal;
481  terminal = terminal->get_next_terminal())
482  {
483  if (terminal->is_species_seq_terminal()) {
484  const char *speciesName = terminal->to_sequence_terminal()->species_name;
485 
486  for (int i=0; i<PV_AA_Terminals4Species; i++) {
487  // get the corresponding orf_terminal skipping sequence_info terminal
488  terminal = terminal->get_next_terminal()->get_next_terminal();
489  // Make sure it is ORF terminal
490  if (terminal->is_orf_terminal()) {
491  ED4_orf_terminal *orfTerm = terminal->to_orf_terminal();
492  ED4_base *base = (ED4_base*)orfTerm;
493  if (!base->flag.hidden) {
494  PV_WriteTranslatedSequenceToDB(orfTerm, speciesName);
495  }
496  }
497  }
498  }
499  }
500  if (giNewAlignments>0) {
501  char *msg = GBS_global_string_copy("Protein data saved to NEW alignments.\n%d new alignments were created and named ali_prot_ProtView_XXXX", giNewAlignments);
502  aw_message(msg);
503  free(msg);
504 
505  giNewAlignments = 0;
506  }
507  }
508  gbWritingData = false;
509 }
510 
511 static void TranslateGeneToAminoAcidSequence(AW_root * /* root */, ED4_orf_terminal *seqTerm, const char *speciesName, int startPos4Translation, int translationMode) {
512  // This function translates gene sequence to aminoacid sequence and stores translation into the respective AA_Sequence_terminal
513  GB_ERROR error = NULp;
514  GBDATA *gb_species = GBT_find_species(GLOBAL_gb_main, speciesName);
515  if (!gb_species) error = GBS_global_string("Species '%s' does not exist", speciesName);
516  else {
517  char *defaultAlignment = GBT_get_default_alignment(GLOBAL_gb_main);
518  if (!defaultAlignment) error = GB_await_error();
519  else {
520  GBDATA *gb_SeqData = GBT_find_sequence(gb_species, defaultAlignment);
521  if (!gb_SeqData) {
522  error = GB_have_error()
523  ? GB_await_error()
524  : GBS_global_string("Species '%s' has no data in alignment '%s'", speciesName, defaultAlignment);
525  }
526  else {
527  e4_assert(startPos4Translation>=0 && startPos4Translation<=2);
528 
529  char *str_SeqData = GB_read_string(gb_SeqData);
530  if (!str_SeqData) error = GB_await_error();
531  else {
532  int len = GB_read_string_count(gb_SeqData);
533  int translationTable = AWT_default_protein_type(GLOBAL_gb_main);
534 
535  switch (translationMode) {
536  case FORWARD_STRAND:
537  break;
538 
539  case COMPLEMENTARY_STRAND: {
540  // convert sequence to the complementary sequence
541  GB_ERROR compl_err = PV_ComplementarySequence(str_SeqData);
542  if (compl_err) error = GBS_global_string("Failed to calc complementary strand for '%s' (Reason: %s)", speciesName, compl_err);
543  break;
544  }
545  case DB_FIELD_STRAND: {
546  // for use database field options - fetch codon start and translation table from the respective species data
547  GBDATA *gb_translTable = GB_entry(gb_species, "transl_table");
548  if (gb_translTable) {
549  int sp_embl_table = atoi(GB_read_char_pntr(gb_translTable));
550  translationTable = TTIT_embl2arb(sp_embl_table);
551  }
552  else { // use selected translation table as default (if 'transl_table' field is missing)
553  gMissingTransTable++;
554  }
555  GBDATA *gb_codonStart = GB_entry(gb_species, "codon_start");
556  if (gb_codonStart) {
557  startPos4Translation = atoi(GB_read_char_pntr(gb_codonStart))-1;
558  if (startPos4Translation<0 || startPos4Translation>2) {
559  error = GB_export_errorf("'%s' has invalid codon_start entry %i (allowed: 1..3)", speciesName, startPos4Translation+1);
560  }
561  }
562  else {
563  gMissingCodonStart++;
564  startPos4Translation = 0;
565  }
566  break;
567  }
568  }
569 
570  if (!error) {
571  translate_nuc2aa(translationTable, str_SeqData, len, startPos4Translation, false, true, false, NULp); // translate
572 
573  char *s = new char[len+1];
575  int i, j;
576 
577  if (iDisplayMode == PV_AA_NAME) {
578  char *gc = new char[len+1];
579 
580  for (i=0, j=0; i<len && j<len;) {
581  // start from the start pos of aa sequence
582  for (; i<startPos4Translation; ++i) {
583  s[i] = ' ';
584  gc[i] = ' ';
585  }
586 
587  char base = str_SeqData[j++];
588  const char *AAname = getAminoAcidAbbr(base);
589  if (!AAname) AAname = ED4_is_gap_character(base) ? "---" : "<?>";
590 
591  e4_assert(AAname && strlen(AAname) == 3);
592  for (int n = 0; n<3 && i<len; ++n,++i) {
593  s[i] = AAname[n];
594  gc[i] = base;
595  }
596  }
597 
598  gc[i] = '\0';
599  seqTerm->SET_aaColor(gc);
600  delete [] gc;
601  }
602  else {
603  int k = startPos4Translation+1;
604  for (i=0, j=0; i<len; i++) {
605  if ((k==i) && (j<len)) {
606  s[i] = str_SeqData[j++];
607  k += 3;
608  }
609  else s[i] = ' ';
610  }
611  seqTerm->SET_aaColor(NULp);
612  }
613  s[i] = '\0';
614 
615  seqTerm->SET_aaSequence(s);
616  delete [] s;
617  }
618  free(str_SeqData);
619  }
620  }
621  }
622  free(defaultAlignment);
623  }
624 
625  if (error) aw_message(GBS_global_string("Error: %s", error));
626 }
627 
629  if (gMissingCodonStart>0) {
630  aw_message(GBS_global_string("WARNING: 'codon start' entry not found in %d of %d species! Using 1st base as codon start...",
631  gMissingCodonStart,
632  (int)GBT_count_marked_species(GLOBAL_gb_main)));
633  gMissingCodonStart = 0;
634  }
635  if (gMissingTransTable>0) {
636  aw_message(GBS_global_string("WARNING: 'translation table' entry not found in %d of %d species! Using selected translation table as a default table...",
637  gMissingTransTable,
638  (int)GBT_count_marked_species(GLOBAL_gb_main)));
639  gMissingTransTable = 0;
640  }
641 }
642 
643 static void PV_DisplayAminoAcidNames(AW_root *root) {
644  GB_transaction ta(GLOBAL_gb_main);
645 
647  terminal;
648  terminal = terminal->get_next_terminal())
649  {
650  if (terminal->is_species_seq_terminal()) {
651  const char *speciesName = terminal->to_sequence_terminal()->species_name;
652 
653  // we are in the sequence terminal section of a species
654  // walk through all the corresponding ORF terminals for the species and
655  // hide or unhide the terminals based on the display options set by the user
656  for (int i=0; i<PV_AA_Terminals4Species; i++) {
657  // get the corresponding orf_terminal skipping sequence_info terminal
658  terminal = terminal->get_next_terminal()->get_next_terminal();
659  // Make sure it is ORF terminal
660  if (terminal->is_orf_terminal()) {
661  ED4_orf_terminal *orfTerm = terminal->to_orf_terminal();
662  // we are in ORF terminal
663  int aaStartPos = int(orfTerm->GET_aaStartPos());
664  int aaStrandType = int(orfTerm->GET_aaStrandType());
665  // retranslate the genesequence and store it to the orf_terminal
666  TranslateGeneToAminoAcidSequence(root, orfTerm, speciesName, aaStartPos-1, aaStrandType);
667  }
668  }
669  }
670  }
671  // Print missing DB entries
673  PV_RefreshWindow(root);
674 }
675 
676 static void PV_RefreshDisplay(AW_root *root) {
678 }
679 
681  if (gTerminalsCreated) {
682  PV_RefreshDisplay(aww->get_root());
683  }
684 }
685 
687  if (gbtype==GB_CB_CHANGED &&
690  !gbWritingData)
691  {
692  GB_transaction ta(GLOBAL_gb_main);
693 
694  for (ED4_window *win = ED4_ROOT->first_window; win; win = win->next) {
695  ED4_cursor& cursor = win->cursor;
696  if (cursor.in_species_seq_terminal()) {
697  ED4_terminal *cursorTerminal = cursor.owner_of_cursor;
698  char *speciesName = cursorTerminal->to_sequence_terminal()->species_name;
699  for (int i=0; i<PV_AA_Terminals4Species; i++) {
700  // get the corresponding orf_terminal skipping sequence_info terminal
701  // $$$$$ sequence_terminal->sequence_info_terminal->aa_sequence_terminal $$$$$$
702  cursorTerminal = cursorTerminal->get_next_terminal()->get_next_terminal();
703  // Make sure it is ORF terminal
704  if (cursorTerminal->is_orf_terminal()) {
705  ED4_orf_terminal *orfTerm = cursorTerminal->to_orf_terminal();
706  // Get the AA sequence flag - says which strand we are in
707  int aaStartPos = int(orfTerm->GET_aaStartPos());
708  int aaStrandType = int(orfTerm->GET_aaStrandType());
709  // retranslate the genesequence and store it to the orf_terminal
710  TranslateGeneToAminoAcidSequence(ED4_ROOT->aw_root, orfTerm, speciesName, aaStartPos-1, aaStrandType);
711  }
712  }
713  // Print missing DB entries
716  }
717  }
718  }
719 }
720 
721 static void PV_AddNewAAseqTerminals(ED4_sequence_terminal *seqTerminal, ED4_species_manager *speciesManager) {
722  int translationMode = 0;
723  char namebuffer[NAME_BUFFERSIZE];
724 
725  for (int i = 0; i<PV_AA_Terminals4Species; i++) {
726  int count = 1;
727  int startPos = 0;
728 
729  sprintf(namebuffer, "Sequence_Manager.%ld.%d", ED4_counter, count++);
730  ED4_multi_sequence_manager *multiSeqManager = speciesManager->search_spec_child_rek(LEV_MULTI_SEQUENCE)->to_multi_sequence_manager();
731  ED4_sequence_manager *new_SeqManager = new ED4_sequence_manager(namebuffer, 0, 0, multiSeqManager);
732  new_SeqManager->set_property(PROP_MOVABLE);
733  multiSeqManager->append_member(new_SeqManager);
734 
735  if (i<FORWARD_STRANDS) sprintf(namebuffer, "F%d ProteinInfo_Term%ld.%d", i+1, ED4_counter, count++);
736  else if ((i-FORWARD_STRANDS)<COMPLEMENTARY_STRANDS) sprintf(namebuffer, "C%dProteinInfo_Term%ld.%d", (i-FORWARD_STRANDS)+1, ED4_counter, count++);
737  else sprintf(namebuffer, "DBProteinInfo_Term%ld.%d", ED4_counter, count++);
738 
739  {
740  ED4_sequence_info_terminal *new_SeqInfoTerminal = new ED4_sequence_info_terminal(namebuffer, SEQUENCE_INFO_WIDTH, TERMINAL_HEIGHT, new_SeqManager);
741  new_SeqInfoTerminal->set_property((ED4_properties) (PROP_SELECTABLE | PROP_DRAGABLE | PROP_IS_HANDLE));
742 
743  ED4_sequence_info_terminal *seqInfoTerminal = speciesManager->search_spec_child_rek(LEV_SEQUENCE_INFO)->to_sequence_info_terminal();
744  new_SeqInfoTerminal->set_both_links(seqInfoTerminal);
745  new_SeqManager->append_member(new_SeqInfoTerminal);
746  }
747 
748  {
749  sprintf(namebuffer, "AA_Sequence_Term%ld.%d", ED4_counter, count++);
750  ED4_orf_terminal *AA_SeqTerminal = new ED4_orf_terminal(namebuffer, 0, TERMINAL_HEIGHT, new_SeqManager);
751  AA_SeqTerminal->set_both_links(seqTerminal);
752 
753  char *speciesName = seqTerminal->species_name;
754  if (i<FORWARD_STRANDS) {
755  startPos = i;
756  translationMode = FORWARD_STRAND;
757  }
758  else if ((i-FORWARD_STRANDS)<COMPLEMENTARY_STRANDS) {
759  startPos = i-FORWARD_STRANDS;
760  translationMode = COMPLEMENTARY_STRAND;
761  }
762  else {
763  startPos = 0;
764  translationMode = DB_FIELD_STRAND;
765  }
766  TranslateGeneToAminoAcidSequence(ED4_ROOT->aw_root, AA_SeqTerminal, speciesName, startPos, translationMode);
767  AA_SeqTerminal->SET_aaSeqFlags(startPos+1, translationMode);
768  new_SeqManager->append_member(AA_SeqTerminal);
769  }
770 
771  ED4_counter++;
772 
773  new_SeqManager->request_resize();
774  }
775 }
776 
777 void PV_AddCorrespondingOrfTerminals(ED4_species_name_terminal *spNameTerm) {
778  if (gTerminalsCreated && spNameTerm) {
779  ED4_sequence_terminal *seqTerminal = spNameTerm->corresponding_sequence_terminal();
780  ED4_species_manager *speciesManager = spNameTerm->get_parent(LEV_SPECIES)->to_species_manager();
781  PV_AddNewAAseqTerminals(seqTerminal, speciesManager);
783  }
784 }
785 
787  if (gTerminalsCreated) {
788  GB_transaction ta(GLOBAL_gb_main);
789  int marked = GBT_count_marked_species(GLOBAL_gb_main);
790  if (marked) {
791  GBDATA *gbSpecies;
792  for (gbSpecies = GBT_first_marked_species(GLOBAL_gb_main);
793  gbSpecies;
794  gbSpecies = GBT_next_marked_species(gbSpecies))
795  {
796  const char *spName = GBT_get_name_or_description(gbSpecies);
797  cout<<marked--<<". "<<spName<<endl;
798  ED4_species_name_terminal *spNameTerm = ED4_find_species_name_terminal(spName);
799  if (spNameTerm) {
800  ED4_terminal *terminal = spNameTerm->corresponding_sequence_terminal();
801  // $$$ If next terminal is species_name terminal => corresponding AA seq terminal doesn't exist ==> create one $$$
802  terminal = terminal->get_next_terminal();
803  if (terminal->is_species_name_terminal() || terminal->is_spacer_terminal()) {
804  ED4_sequence_terminal *seqTerminal = spNameTerm->corresponding_sequence_terminal();
805  ED4_species_manager *speciesManager = spNameTerm->get_parent(LEV_SPECIES)->to_species_manager();
806  PV_AddNewAAseqTerminals(seqTerminal, speciesManager);
807  }
808  }
809  }
811  }
812  }
813 }
814 
815 static void PV_CreateAllTerminals(AW_root *root) {
816  // 1. Get the species terminal pointer
817  // 2. Append the second terminal
818  // 3. resize the multi-species manager
819  // 4. refresh all the terminals including new appended terminals
820 
821  // Look for already created terminals, if found do nothing, otherwise, create
822  // new terminals and set gTerminalsCreated to true
823  bool bTerminalsFound = PV_LookForNewTerminals(root);
824  // if terminals are already created then do nothing exit the function
825  if (bTerminalsFound) return;
826 
827  GB_transaction ta(GLOBAL_gb_main);
828 
829  // Number of ORF terminals to be created = 3 forward strands + 3 complementary strands + 1 DB field strand
830  // totally 7 strands has to be created
831  int aaTerminalsToBeCreated = FORWARD_STRANDS + COMPLEMENTARY_STRANDS + DB_FIELD_STRANDS;
832  PV_AA_Terminals4Species = aaTerminalsToBeCreated;
833 
834  ED4_terminal *terminal = NULp;
835  for (terminal = ED4_ROOT->root_group_man->get_first_terminal();
836  terminal;
837  terminal = terminal->get_next_terminal())
838  {
839  if (terminal->is_sequence_terminal()) {
840  ED4_sequence_terminal *seqTerminal = terminal->to_sequence_terminal();
841  if (seqTerminal->species_name) {
842  ED4_species_manager *speciesManager = terminal->get_parent(LEV_SPECIES)->to_species_manager();
843  if (speciesManager->is_species_seq_manager()) {
844  PV_AddNewAAseqTerminals(seqTerminal, speciesManager);
845  }
846  }
847  }
848  }
849  ED4_ROOT->main_manager->request_resize(); // @@@ instead needs to be called whenever adding or deleting PV-terminals
850 
851  gTerminalsCreated = true;
852 
853  // Print missing DB entries
855 }
856 
858  // Create New Terminals If Aminoacid Sequence Terminals Are Not Created
859  if (!gTerminalsCreated) {
860  // AWAR_PROTEIN_TYPE is not initialized (if called from ED4_main before creating proteinViewer window)
861  // so, initialize it here
863  PV_CreateAllTerminals(root);
864  }
865 
866  PV_RefreshWindow(root);
867 }
868 
869 // --------------------------------------------------------------------------------
870 // Binding callback function to the AWARS
871 
872 static void PV_AddCallBacks(AW_root *awr) {
873 
882 
885 
894 
903 
912 }
913 
914 // --------------------------------------------------------------------------------
915 // Creating AWARS to be used by the PROTVIEW module
916 
917 void PV_CreateAwars(AW_root *root, AW_default aw_def) {
918 
919  root->awar_int(AWAR_PV_DISPLAY_ALL, 0, aw_def);
920 
921  root->awar_int(AWAR_PROTVIEW_FORWARD_STRAND_1, 0, aw_def);
922  root->awar_int(AWAR_PROTVIEW_FORWARD_STRAND_2, 0, aw_def);
923  root->awar_int(AWAR_PROTVIEW_FORWARD_STRAND_3, 0, aw_def);
924 
928 
929  root->awar_int(AWAR_PROTVIEW_DEFINED_FIELDS, 0, aw_def);
930  root->awar_int(AWAR_PROTVIEW_DISPLAY_OPTIONS, 0, aw_def);
931 
932  root->awar_int(AWAR_PV_SELECTED, 0, aw_def);
933  root->awar_int(AWAR_PV_SELECTED_DB, 0, aw_def);
934  root->awar_int(AWAR_PV_SELECTED_FS_1, 0, aw_def);
935  root->awar_int(AWAR_PV_SELECTED_FS_2, 0, aw_def);
936  root->awar_int(AWAR_PV_SELECTED_FS_3, 0, aw_def);
937  root->awar_int(AWAR_PV_SELECTED_CS_1, 0, aw_def);
938  root->awar_int(AWAR_PV_SELECTED_CS_2, 0, aw_def);
939  root->awar_int(AWAR_PV_SELECTED_CS_3, 0, aw_def);
940 
941  root->awar_int(AWAR_PV_MARKED, 0, aw_def);
942  root->awar_int(AWAR_PV_MARKED_DB, 0, aw_def);
943  root->awar_int(AWAR_PV_MARKED_FS_1, 0, aw_def);
944  root->awar_int(AWAR_PV_MARKED_FS_2, 0, aw_def);
945  root->awar_int(AWAR_PV_MARKED_FS_3, 0, aw_def);
946  root->awar_int(AWAR_PV_MARKED_CS_1, 0, aw_def);
947  root->awar_int(AWAR_PV_MARKED_CS_2, 0, aw_def);
948  root->awar_int(AWAR_PV_MARKED_CS_3, 0, aw_def);
949 
950  root->awar_int(AWAR_PV_CURSOR, 0, aw_def);
951  root->awar_int(AWAR_PV_CURSOR_DB, 0, aw_def);
952  root->awar_int(AWAR_PV_CURSOR_FS_1, 0, aw_def);
953  root->awar_int(AWAR_PV_CURSOR_FS_2, 0, aw_def);
954  root->awar_int(AWAR_PV_CURSOR_FS_3, 0, aw_def);
955  root->awar_int(AWAR_PV_CURSOR_CS_1, 0, aw_def);
956  root->awar_int(AWAR_PV_CURSOR_CS_2, 0, aw_def);
957  root->awar_int(AWAR_PV_CURSOR_CS_3, 0, aw_def);
958 }
959 
961  GB_transaction ta(GLOBAL_gb_main);
962 
963  static AW_window_simple *aws = NULp;
964  if (aws) return aws;
965 
966  aws = new AW_window_simple;
967 
968  aws->init(aw_root, "PROTEIN_VIEWER", "Protein Viewer");
969  aws->load_xfig("proteinViewer.fig");
970 
971  aws->at("refresh");
972  aws->callback(PV_RefreshProtViewDisplay);
973  aws->button_length(0);
974  aws->create_button("REFRESH", "#refresh_text.xpm");
975 
976  aws->callback(makeHelpCallback("proteinViewer.hlp"));
977  aws->at("help");
978  aws->button_length(0);
979  aws->create_button("HELP", "#help_text.xpm");
980 
981  aws->at("close");
982  aws->callback(AW_POPDOWN);
983  aws->button_length(0);
984  aws->create_button("CLOSE", "#close_text.xpm");
985 
986  {
988  aws->at("table");
989  aws->create_option_menu(AWAR_PROTEIN_TYPE, true);
990  for (int code_nr=0; code_nr<AWT_CODON_TABLES; code_nr++) {
991  aws->insert_option(AWT_get_codon_code_name(code_nr), "", code_nr);
992  }
993  aws->update_option_menu();
994 
995  aws->at("all");
996  aws->create_toggle(AWAR_PV_DISPLAY_ALL);
997 
998  aws->at("f1");
999  aws->create_toggle(AWAR_PROTVIEW_FORWARD_STRAND_1);
1000 
1001  aws->at("f2");
1002  aws->create_toggle(AWAR_PROTVIEW_FORWARD_STRAND_2);
1003 
1004  aws->at("f3");
1005  aws->create_toggle(AWAR_PROTVIEW_FORWARD_STRAND_3);
1006 
1007  aws->at("c1");
1008  aws->create_toggle(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_1);
1009 
1010  aws->at("c2");
1011  aws->create_toggle(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_2);
1012 
1013  aws->at("c3");
1014  aws->create_toggle(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_3);
1015 
1016  aws->at("defined");
1017  aws->create_toggle(AWAR_PROTVIEW_DEFINED_FIELDS);
1018 
1019  aws->at("dispOption");
1020  aws->create_toggle_field(AWAR_PROTVIEW_DISPLAY_OPTIONS, 0);
1021  aws->insert_toggle("Single Letter Code", "S", 0);
1022  aws->insert_toggle("Triple Letter Code", "T", 1);
1023  aws->insert_toggle("Colored Box", "B", 2);
1024  aws->update_toggle_field();
1025 
1026  aws->at("colMaps");
1027  aws->callback(makeCreateWindowCallback(ED4_create_seq_colors_window, ED4_ROOT->sequence_colors));
1028  aws->button_length(0);
1029  aws->create_button("COLORMAPS", "#colorMaps.xpm");
1030 
1031  aws->at("colors");
1032  aws->callback(makeWindowCallback(ED4_popup_gc_window, ED4_ROOT->gc_manager));
1033  aws->button_length(0);
1034  aws->create_button("COLORS", "#colors.xpm");
1035 
1036  {
1037  aws->at("sel"); aws->create_toggle(AWAR_PV_SELECTED);
1038  aws->at("sf1"); aws->create_toggle(AWAR_PV_SELECTED_FS_1);
1039  aws->at("sf2"); aws->create_toggle(AWAR_PV_SELECTED_FS_2);
1040  aws->at("sf3"); aws->create_toggle(AWAR_PV_SELECTED_FS_3);
1041  aws->at("sc1"); aws->create_toggle(AWAR_PV_SELECTED_CS_1);
1042  aws->at("sc2"); aws->create_toggle(AWAR_PV_SELECTED_CS_2);
1043  aws->at("sc3"); aws->create_toggle(AWAR_PV_SELECTED_CS_3);
1044  aws->at("sdb"); aws->create_toggle(AWAR_PV_SELECTED_DB);
1045 
1046  aws->at("mrk"); aws->create_toggle(AWAR_PV_MARKED);
1047  aws->at("mf1"); aws->create_toggle(AWAR_PV_MARKED_FS_1);
1048  aws->at("mf2"); aws->create_toggle(AWAR_PV_MARKED_FS_2);
1049  aws->at("mf3"); aws->create_toggle(AWAR_PV_MARKED_FS_3);
1050  aws->at("mc1"); aws->create_toggle(AWAR_PV_MARKED_CS_1);
1051  aws->at("mc2"); aws->create_toggle(AWAR_PV_MARKED_CS_2);
1052  aws->at("mc3"); aws->create_toggle(AWAR_PV_MARKED_CS_3);
1053  aws->at("mdb"); aws->create_toggle(AWAR_PV_MARKED_DB);
1054 
1055  aws->at("cur"); aws->create_toggle(AWAR_PV_CURSOR);
1056  aws->at("cf1"); aws->create_toggle(AWAR_PV_CURSOR_FS_1);
1057  aws->at("cf2"); aws->create_toggle(AWAR_PV_CURSOR_FS_2);
1058  aws->at("cf3"); aws->create_toggle(AWAR_PV_CURSOR_FS_3);
1059  aws->at("cc1"); aws->create_toggle(AWAR_PV_CURSOR_CS_1);
1060  aws->at("cc2"); aws->create_toggle(AWAR_PV_CURSOR_CS_2);
1061  aws->at("cc3"); aws->create_toggle(AWAR_PV_CURSOR_CS_3);
1062  aws->at("cdb"); aws->create_toggle(AWAR_PV_CURSOR_DB);
1063  }
1064 
1065  aws->at("save");
1066  aws->callback(PV_SaveData);
1067  aws->button_length(5);
1068  aws->create_button("SAVE", "#save.xpm");
1069  }
1070 
1071  // binding callback function to the AWARS
1072  PV_AddCallBacks(aw_root);
1073 
1074  // Create All Terminals
1075  PV_CreateAllTerminals(aw_root);
1076 
1077  aws->show();
1078 
1079  return aws;
1080 }
1081 
GB_ERROR GB_begin_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2492
static void PV_PrintMissingDBentryInformation()
#define AWAR_PV_MARKED_DB
void set_both_links(ED4_base *ref)
Definition: ed4_class.hxx:977
void PV_SequenceUpdate_CB(GB_CB_TYPE gbtype)
void unhide_children()
Definition: ED4_base.cxx:828
const char * GB_ERROR
Definition: arb_core.h:25
#define AWAR_PV_MARKED_CS_3
#define AWAR_PROTVIEW_COMPLEMENTARY_STRAND_1
#define COMPLEMENTARY_STRAND
bool is_species_seq_terminal() const
Definition: ed4_class.hxx:1852
#define AWAR_PROTVIEW_FORWARD_STRAND_2
group_matcher all()
Definition: test_unit.h:1000
GBDATA * GBT_first_marked_species(GBDATA *gb_main)
Definition: aditem.cxx:113
static void PV_RefreshDisplay(AW_root *root)
static bool PV_LookForNewTerminals(AW_root *root)
GB_ERROR GB_write_string(GBDATA *gbd, const char *s)
Definition: arbdb.cxx:1361
ED4_terminal * get_first_terminal(int start_index=0) const
static int gMissingTransTable
static void PV_HideTerminal(ED4_orf_terminal *orfTerm)
static void TranslateGeneToAminoAcidSequence(AW_root *, ED4_orf_terminal *seqTerm, const char *speciesName, int startPos4Translation, int translationMode)
#define FORWARD_STRANDS
char * GBT_complementNucSequence(const char *s, int len, char T_or_U)
Definition: adRevCompl.cxx:78
#define FORWARD_STRAND
bool in_species_seq_terminal() const
Definition: ed4_class.hxx:1854
#define AWAR_PV_SELECTED_FS_2
#define COMPLEMENTARY_STRANDS
#define AWAR_PV_MARKED_CS_1
GBDATA * GBT_get_alignment(GBDATA *gb_main, const char *aliname)
Definition: adali.cxx:684
#define AWAR_PV_SELECTED_FS_1
void request_resize()
Definition: ed4_class.hxx:2189
#define AWAR_PROTVIEW_FORWARD_STRAND_1
static AW_repeated_question * ASKtoOverWriteData
void GB_end_transaction_show_error(GBDATA *gbd, GB_ERROR error, void(*error_handler)(GB_ERROR))
Definition: arbdb.cxx:2548
long read_int() const
Definition: AW_awar.cxx:187
static void PV_ManageTerminalDisplay(AW_root *root, ED4_orf_terminal *orfTerm, long int DispMode)
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:204
void PV_CallBackFunction(AW_root *root)
static bool gbWritingData
ED4_root * ED4_ROOT
Definition: ED4_main.cxx:48
long GBT_get_alignment_len(GBDATA *gb_main, const char *aliname)
Definition: adali.cxx:706
static void PV_DisplayAminoAcidNames(AW_root *root)
bool GB_have_error()
Definition: arb_msg.cxx:349
STL namespace.
void AW_POPDOWN(AW_window *window)
Definition: AW_window.cxx:52
ED4_terminal * owner_of_cursor
Definition: ed4_class.hxx:649
void SET_aaSequence(const char *aaSeq)
Definition: ed4_class.hxx:1973
AW_gc_manager * gc_manager
Definition: ed4_class.hxx:1444
long ED4_counter
Definition: ED4_main.cxx:61
#define e4_assert(bed)
Definition: ed4_class.hxx:11
GBDATA * GLOBAL_gb_main
Definition: DI_main.cxx:27
static GB_ERROR PV_ComplementarySequence(char *sequence)
AW_awar * add_callback(const RootCallback &cb)
Definition: AW_awar.cxx:234
#define AWAR_PV_CURSOR_CS_3
#define AWAR_PV_SELECTED_CS_1
int TTIT_embl2arb(int embl_code_nr)
NOT4PERL GBDATA * GBT_add_data(GBDATA *species, const char *ali_name, const char *key, GB_TYPES type) __ATTR__DEPRECATED_TODO("better use GBT_create_sequence_data()")
Definition: adali.cxx:559
static void PV_SaveData(AW_window *)
#define SEQUENCE_INFO_WIDTH
Definition: ed4_defs.hxx:82
size_t GB_read_string_count(GBDATA *gbd)
Definition: arbdb.cxx:886
GB_ERROR GB_await_error()
Definition: arb_msg.cxx:353
#define AWAR_PV_CURSOR_FS_2
WindowCallback makeHelpCallback(const char *helpfile)
Definition: aw_window.hxx:106
GBDATA * GBT_create_alignment(GBDATA *gbd, const char *name, long len, long aligned, long security, const char *type)
Definition: adali.cxx:387
void append_member(ED4_base *new_member)
AW_window * ED4_CreateProteinViewer_window(AW_root *aw_root)
static void PV_HideAllTerminals()
static void PV_RefreshProtViewDisplay(AW_window *aww)
#define AWAR_PV_MARKED_FS_1
static void PV_WriteTranslatedSequenceToDB(ED4_orf_terminal *aaSeqTerm, const char *spName)
void hide_children()
Definition: ED4_base.cxx:817
#define DB_FIELD_STRAND
#define AWAR_PV_MARKED_FS_3
#define AWAR_PV_MARKED_CS_2
ED4_species_name_terminal * ED4_find_species_name_terminal(const char *species_name)
Definition: ED4_root.cxx:889
#define DB_FIELD_STRANDS
int translate_nuc2aa(int arb_code_nr, char *data, size_t size, size_t pos, bool translate_all, bool create_start_codon, bool append_stop_codon, int *translatedSize)
Definition: Translate.cxx:108
static void PV_CreateAllTerminals(AW_root *root)
ED4_window * first_window
Definition: ed4_class.hxx:1427
#define AWAR_PROTVIEW_DISPLAY_OPTIONS
ED4_terminal * get_next_terminal()
Definition: ED4_base.cxx:452
static void error(const char *msg)
Definition: mkptypes.cxx:96
#define AWAR_PV_SELECTED_FS_3
void PV_AddOrfTerminalsToLoadedSpecies()
#define AWAR_PV_SELECTED_CS_2
void PV_RefreshWindow(AW_root *root)
#define AWAR_PV_SELECTED_CS_3
AW_window * ED4_create_seq_colors_window(AW_root *awr, ED4_seq_colors *sc)
GBDATA * GBT_next_marked_species(GBDATA *gb_species)
Definition: aditem.cxx:116
#define AWAR_PROTVIEW_COMPLEMENTARY_STRAND_2
#define AWAR_PV_CURSOR
ED4_root_group_manager * root_group_man
Definition: ed4_class.hxx:1431
static bool gTerminalsCreated
#define AWAR_SPECIES_NAME
ED4_main_manager * main_manager
Definition: ed4_class.hxx:1428
void PV_CreateAwars(AW_root *root, AW_default aw_def)
#define AWAR_PV_MARKED
#define AWAR_PV_DISPLAY_ALL
AW_awar * awar(const char *awar)
Definition: AW_root.cxx:554
#define AWAR_PV_CURSOR_DB
GBDATA * GBT_find_sequence(GBDATA *gb_species, const char *aliname)
Definition: adali.cxx:670
GB_alignment_type alignment_type
Definition: ed4_class.hxx:1441
static void PV_UnHideTerminal(ED4_orf_terminal *orfTerm)
long GBT_count_marked_species(GBDATA *gb_main)
Definition: aditem.cxx:349
static int PV_AA_Terminals4Species
const char * AWT_get_codon_code_name(int code)
int TERMINAL_HEIGHT
Definition: ED4_main.cxx:51
#define NAME_BUFFERSIZE
Definition: ed4_defs.hxx:113
#define AWAR_PV_SELECTED_DB
static void PV_ManageTerminals(AW_root *root)
void PV_AddCorrespondingOrfTerminals(ED4_species_name_terminal *spNameTerm)
static int gMissingCodonStart
int is_orf_terminal() const
Definition: ed4_class.hxx:1089
GB_ERROR GB_export_errorf(const char *templat,...)
Definition: arb_msg.cxx:264
ED4_base * search_spec_child_rek(ED4_level level)
Definition: ED4_base.cxx:432
ED4_cursor & current_cursor()
Definition: ed4_class.hxx:1405
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:580
#define AWAR_PV_SELECTED
#define AWAR_PROTVIEW_DEFINED_FIELDS
void set_property(ED4_properties prop)
Definition: ed4_class.hxx:980
void SET_aaSeqFlags(int startPos, int strandType)
Definition: ed4_class.hxx:1972
char * GB_read_string(GBDATA *gbd)
Definition: arbdb.cxx:879
const int AWAR_PROTEIN_TYPE_bacterial_code_index
ED4_seq_colors * sequence_colors
Definition: ed4_class.hxx:1443
AW_root * aw_root
Definition: ed4_class.hxx:1424
#define AWAR_PROTEIN_TYPE
static void PV_AddCallBacks(AW_root *awr)
#define AWT_CODON_TABLES
#define AWAR_PV_CURSOR_FS_1
ED4_properties
Definition: ed4_defs.hxx:176
unsigned int hidden
Definition: ed4_class.hxx:932
bool ED4_is_gap_character(char chr)
#define AWAR_PROTVIEW_FORWARD_STRAND_3
void aw_message(const char *msg)
Definition: AW_status.cxx:932
int AWT_default_protein_type(GBDATA *gb_main)
void ED4_popup_gc_window(AW_window *awp, AW_gc_manager *gcman)
Definition: ED4_root.cxx:1255
GBDATA * GB_find_string(GBDATA *gbd, const char *key, const char *str, GB_CASE case_sens, GB_SEARCH_TYPE gbs)
Definition: adquery.cxx:302
AW_root * get_root()
Definition: aw_window.hxx:348
#define AWAR_PV_CURSOR_CS_2
AW_window_simple * win
#define NULp
Definition: cxxforward.h:97
GBDATA * GBT_find_species(GBDATA *gb_main, const char *name)
Definition: aditem.cxx:136
static int giNewAlignments
#define AWAR_PV_MARKED_FS_2
void SET_aaColor(const char *aaSeq)
Definition: ed4_class.hxx:1974
int is_sequence_terminal() const
Definition: ed4_class.hxx:1088
char * GBT_get_default_alignment(GBDATA *gb_main)
Definition: adali.cxx:675
#define AWAR_PV_CURSOR_FS_3
GB_transaction ta(gb_var)
static void PV_AddNewAAseqTerminals(ED4_sequence_terminal *seqTerminal, ED4_species_manager *speciesManager)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
Definition: arbdb.cxx:874
GB_ERROR GBT_check_data(GBDATA *Main, const char *alignment_name)
Definition: adali.cxx:217
GBDATA * GBT_get_presets(GBDATA *gb_main)
Definition: adali.cxx:29
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
Definition: aditem.cxx:437
int is_spacer_terminal() const
Definition: ed4_class.hxx:1095
#define AWAR_PV_CURSOR_CS_1
GB_CB_TYPE
Definition: arbdb_base.h:46
ED4_manager * get_parent(ED4_level lev) const
Definition: ed4_class.hxx:1823
struct ED4_base::@7 flag
#define AWAR_PROTVIEW_COMPLEMENTARY_STRAND_3
GBDATA * GB_entry(GBDATA *father, const char *key)
Definition: adquery.cxx:334
int is_species_name_terminal() const
Definition: ed4_class.hxx:1085
char * GBS_global_string_copy(const char *templat,...)
Definition: arb_msg.cxx:195
NOT4PERL GB_ERROR GBT_determine_T_or_U(GB_alignment_type alignment_type, char *T_or_U, const char *supposed_target)
Definition: adRevCompl.cxx:90
const char * getAminoAcidAbbr(char aa)
ED4_window * get_most_recently_used_window() const
Definition: ed4_class.hxx:1470
GB_write_int const char s
Definition: AW_awar.cxx:156