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 static bool gTerminalsCreated = false;
50 static int PV_AA_Terminals4Species = 0;
51 static int gMissingTransTable = 0;
52 static int gMissingCodonStart = 0;
53 static bool gbWritingData = false;
54 static int giNewAlignments = 0;
55 
56 static AW_repeated_question *ASKtoOverWriteData = NULp;
57 
58 static bool PV_LookForNewTerminals(AW_root *root) {
59  bool bTerminalsFound = true;
60 
61  int all = root->awar(AWAR_PV_DISPLAY_ALL)->read_int();
62  int all_f1 = root->awar(AWAR_PROTVIEW_FORWARD_STRAND_1)->read_int();
63  int all_f2 = root->awar(AWAR_PROTVIEW_FORWARD_STRAND_2)->read_int();
64  int all_f3 = root->awar(AWAR_PROTVIEW_FORWARD_STRAND_3)->read_int();
65  int all_c1 = root->awar(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_1)->read_int();
66  int all_c2 = root->awar(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_2)->read_int();
67  int all_c3 = root->awar(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_3)->read_int();
68  int all_db = root->awar(AWAR_PROTVIEW_DEFINED_FIELDS)->read_int();
69 
70  int sel = root->awar(AWAR_PV_SELECTED)->read_int();
71  int sel_db = root->awar(AWAR_PV_SELECTED_DB)->read_int();
72  int sel_f1 = root->awar(AWAR_PV_SELECTED_FS_1)->read_int();
73  int sel_f2 = root->awar(AWAR_PV_SELECTED_FS_2)->read_int();
74  int sel_f3 = root->awar(AWAR_PV_SELECTED_FS_3)->read_int();
75  int sel_c1 = root->awar(AWAR_PV_SELECTED_CS_1)->read_int();
76  int sel_c2 = root->awar(AWAR_PV_SELECTED_CS_2)->read_int();
77  int sel_c3 = root->awar(AWAR_PV_SELECTED_CS_3)->read_int();
78 
79  int mrk = root->awar(AWAR_PV_MARKED)->read_int();
80  int mrk_db = root->awar(AWAR_PV_MARKED_DB)->read_int();
81  int mrk_f1 = root->awar(AWAR_PV_MARKED_FS_1)->read_int();
82  int mrk_f2 = root->awar(AWAR_PV_MARKED_FS_2)->read_int();
83  int mrk_f3 = root->awar(AWAR_PV_MARKED_FS_3)->read_int();
84  int mrk_c1 = root->awar(AWAR_PV_MARKED_CS_1)->read_int();
85  int mrk_c2 = root->awar(AWAR_PV_MARKED_CS_2)->read_int();
86  int mrk_c3 = root->awar(AWAR_PV_MARKED_CS_3)->read_int();
87 
88  int cur = root->awar(AWAR_PV_CURSOR)->read_int();
89  int cur_db = root->awar(AWAR_PV_CURSOR_DB)->read_int();
90  int cur_f1 = root->awar(AWAR_PV_CURSOR_FS_1)->read_int();
91  int cur_f2 = root->awar(AWAR_PV_CURSOR_FS_2)->read_int();
92  int cur_f3 = root->awar(AWAR_PV_CURSOR_FS_3)->read_int();
93  int cur_c1 = root->awar(AWAR_PV_CURSOR_CS_1)->read_int();
94  int cur_c2 = root->awar(AWAR_PV_CURSOR_CS_2)->read_int();
95  int cur_c3 = root->awar(AWAR_PV_CURSOR_CS_3)->read_int();
96 
97  // Test whether any of the options are selected or not?
98  if ((all && (all_f1 || all_f2 || all_f3 || all_c1 || all_c2 || all_c3 || all_db)) ||
99  (sel && (sel_db || sel_f1 || sel_f2 || sel_f3 || sel_c1 || sel_c2 || sel_c3)) ||
100  (mrk && (mrk_db || mrk_f1 || mrk_f2 || mrk_f3 || mrk_c1 || mrk_c2 || mrk_c3)) ||
101  (cur && (cur_db || cur_f1 || cur_f2 || cur_f3 || cur_c1 || cur_c2 || cur_c3)))
102  {
103  // if so, then test whether the terminals are created already or not?
104  if (gTerminalsCreated) {
105  // if yes, then set the flag to true
106  bTerminalsFound = true;
107  }
108  else {
109  // if not, then new terminals has to be created
110  bTerminalsFound = false;
111  }
112  }
113  return bTerminalsFound;
114 }
115 
116 static void PV_HideTerminal(ED4_orf_terminal *orfTerm) {
117  ED4_sequence_manager *seqManager = orfTerm->get_parent(LEV_SEQUENCE)->to_sequence_manager();
118  seqManager->hide_children();
119 }
120 
121 static void PV_UnHideTerminal(ED4_orf_terminal *orfTerm) {
122  ED4_sequence_manager *seqManager = orfTerm->get_parent(LEV_SEQUENCE)->to_sequence_manager();
123  seqManager->unhide_children();
124 }
125 
126 static void PV_HideAllTerminals() {
127  ED4_terminal *terminal = NULp;
128  for (terminal = ED4_ROOT->root_group_man->get_first_terminal();
129  terminal;
130  terminal = terminal->get_next_terminal())
131  {
132  if (terminal->is_orf_terminal()) {
133  ED4_orf_terminal *orfTerm = terminal->to_orf_terminal();
134  PV_HideTerminal(orfTerm);
135  }
136  }
137 }
138 
139 
140 static void PV_ManageTerminalDisplay(AW_root *root, ED4_orf_terminal *orfTerm, long int DispMode) {
141  int all, af_1, af_2, af_3, ac_1, ac_2, ac_3, adb;
142  all = root->awar(AWAR_PV_DISPLAY_ALL)->read_int();
150 
151  int mrk, mf_1, mf_2, mf_3, mc_1, mc_2, mc_3, mdb;
152  mrk = root->awar(AWAR_PV_MARKED)->read_int();
153  mdb = root->awar(AWAR_PV_MARKED_DB)->read_int();
154  mf_1 = root->awar(AWAR_PV_MARKED_FS_1)->read_int();
155  mf_2 = root->awar(AWAR_PV_MARKED_FS_2)->read_int();
156  mf_3 = root->awar(AWAR_PV_MARKED_FS_3)->read_int();
157  mc_1 = root->awar(AWAR_PV_MARKED_CS_1)->read_int();
158  mc_2 = root->awar(AWAR_PV_MARKED_CS_2)->read_int();
159  mc_3 = root->awar(AWAR_PV_MARKED_CS_3)->read_int();
160 
161  int sel, sf_1, sf_2, sf_3, sc_1, sc_2, sc_3, sdb;
162  sel = root->awar(AWAR_PV_SELECTED)->read_int();
163  sdb = root->awar(AWAR_PV_SELECTED_DB)->read_int();
164  sf_1 = root->awar(AWAR_PV_SELECTED_FS_1)->read_int();
165  sf_2 = root->awar(AWAR_PV_SELECTED_FS_2)->read_int();
166  sf_3 = root->awar(AWAR_PV_SELECTED_FS_3)->read_int();
167  sc_1 = root->awar(AWAR_PV_SELECTED_CS_1)->read_int();
168  sc_2 = root->awar(AWAR_PV_SELECTED_CS_2)->read_int();
169  sc_3 = root->awar(AWAR_PV_SELECTED_CS_3)->read_int();
170 
171  int cur, cf_1, cf_2, cf_3, cc_1, cc_2, cc_3, cdb;
172  cur = root->awar(AWAR_PV_CURSOR)->read_int();
173  cdb = root->awar(AWAR_PV_CURSOR_DB)->read_int();
174  cf_1 = root->awar(AWAR_PV_CURSOR_FS_1)->read_int();
175  cf_2 = root->awar(AWAR_PV_CURSOR_FS_2)->read_int();
176  cf_3 = root->awar(AWAR_PV_CURSOR_FS_3)->read_int();
177  cc_1 = root->awar(AWAR_PV_CURSOR_CS_1)->read_int();
178  cc_2 = root->awar(AWAR_PV_CURSOR_CS_2)->read_int();
179  cc_3 = root->awar(AWAR_PV_CURSOR_CS_3)->read_int();
180 
181  // Get the AA sequence flag - says which strand we are in
182  int aaStrandType = int(orfTerm->GET_aaStrandType());
183  // Check the display options and make visible or hide the AA seq terminal
184  switch (aaStrandType) {
185  case FORWARD_STRAND: {
186  int aaStartPos = int(orfTerm->GET_aaStartPos());
187  switch (aaStartPos) {
188  case 1:
189  switch (DispMode) {
190  case PV_ALL: (all && af_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
191  case PV_MARKED: (mrk && mf_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
192  case PV_SELECTED: (sel && sf_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
193  case PV_CURSOR: (cur && cf_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
194  }
195  break;
196  case 2:
197  switch (DispMode) {
198  case PV_ALL: (all && af_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
199  case PV_MARKED: (mrk && mf_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
200  case PV_SELECTED: (sel && sf_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
201  case PV_CURSOR: (cur && cf_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
202  }
203  break;
204  case 3:
205  switch (DispMode) {
206  case PV_ALL: (all && af_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
207  case PV_MARKED: (mrk && mf_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
208  case PV_SELECTED: (sel && sf_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
209  case PV_CURSOR: (cur && cf_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
210  }
211  break;
212  }
213  break;
214  }
215  case COMPLEMENTARY_STRAND: {
216  int aaStartPos = int(orfTerm->GET_aaStartPos());
217  switch (aaStartPos) {
218  case 1:
219  switch (DispMode) {
220  case PV_ALL: (all && ac_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
221  case PV_MARKED: (mrk && mc_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
222  case PV_SELECTED: (sel && sc_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
223  case PV_CURSOR: (cur && cc_1) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
224  }
225  break;
226  case 2:
227  switch (DispMode) {
228  case PV_ALL: (all && ac_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
229  case PV_MARKED: (mrk && mc_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
230  case PV_SELECTED: (sel && sc_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
231  case PV_CURSOR: (cur && cc_2) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
232  }
233  break;
234  case 3:
235  switch (DispMode) {
236  case PV_ALL: (all && ac_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
237  case PV_MARKED: (mrk && mc_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
238  case PV_SELECTED: (sel && sc_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
239  case PV_CURSOR: (cur && cc_3) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
240  }
241  break;
242  }
243  break;
244  }
245  case DB_FIELD_STRAND:
246  switch (DispMode) {
247  case PV_ALL: (all && adb) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
248  case PV_MARKED: (mrk && mdb) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
249  case PV_SELECTED: (sel && sdb) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
250  case PV_CURSOR: (cur && cdb) ? PV_UnHideTerminal(orfTerm) : PV_HideTerminal(orfTerm); break;
251  }
252  break;
253  }
254 }
255 
256 static void PV_ManageTerminals(AW_root *root) {
257 
258  // First Hide all orf Terminals
260 
261  int dispAll = root->awar(AWAR_PV_DISPLAY_ALL)->read_int();
262  if (dispAll) {
264  terminal;
265  terminal = terminal->get_next_terminal())
266  {
267  if (terminal->is_orf_terminal()) {
268  ED4_orf_terminal *orfTerm = terminal->to_orf_terminal();
269  PV_ManageTerminalDisplay(root, orfTerm, PV_ALL);
270  }
271  }
272  }
273 
274  int dispMarked = root->awar(AWAR_PV_MARKED)->read_int();
275  if (dispMarked) {
277  GB_transaction ta(gb_main);
278  int marked = GBT_count_marked_species(gb_main);
279  if (marked) {
280  for (GBDATA *gbSpecies = GBT_first_marked_species(gb_main);
281  gbSpecies;
282  gbSpecies = GBT_next_marked_species(gbSpecies))
283  {
284  ED4_species_name_terminal *spNameTerm = ED4_find_species_name_terminal(GBT_get_name_or_description(gbSpecies));
285  if (spNameTerm) {
286  ED4_terminal *terminal = spNameTerm->corresponding_sequence_terminal();
287  for (int i=0; i<PV_AA_Terminals4Species; i++) {
288  // get the corresponding orf_terminal skipping sequence_info terminal
289  // $$$$$ sequence_terminal->sequence_info_terminal->aa_sequence_terminal $$$$$$
290  terminal = terminal->get_next_terminal()->get_next_terminal();
291  // Make sure it is ORF terminal
292  if (terminal->is_orf_terminal()) {
293  ED4_orf_terminal *orfTerm = terminal->to_orf_terminal();
294  PV_ManageTerminalDisplay(root, orfTerm, PV_MARKED);
295  }
296  }
297  }
298  }
299  }
300  }
301 
302  int dispSelected = root->awar(AWAR_PV_SELECTED)->read_int();
303  if (dispSelected) {
305  terminal;
306  terminal = terminal->get_next_terminal())
307  {
308  if (terminal->is_sequence_terminal()) {
309  ED4_species_manager *speciesManager = terminal->get_parent(LEV_SPECIES)->to_species_manager();
310  if (speciesManager->is_species_seq_terminal()) {
311  // we are in the sequence terminal section of a species
312  // walk through all the corresponding ORF terminals for the species and
313  // hide or unhide the terminals based on the display options set by the user
314  if (speciesManager->is_selected()) {
315  for (int i=0; i<PV_AA_Terminals4Species; i++) {
316  // get the corresponding orf_terminal skipping sequence_info terminal
317  // $$$$$ sequence_terminal->sequence_info_terminal->aa_sequence_terminal $$$$$$
318  terminal = terminal->get_next_terminal()->get_next_terminal();
319  // Make sure it is ORF terminal
320  if (terminal->is_orf_terminal()) {
321  ED4_orf_terminal *orfTerm = terminal->to_orf_terminal();
322  PV_ManageTerminalDisplay(root, orfTerm, PV_SELECTED);
323  }
324  }
325  }
326  }
327  }
328  }
329  }
330 
331  int dispAtCursor = root->awar(AWAR_PV_CURSOR)->read_int();
332  if (dispAtCursor) {
333  // only display terminals for species at cursor
335  ED4_MostRecentWinContext context;
336  ED4_cursor& cursor = current_cursor();
337 
338  if (cursor.owner_of_cursor) {
339  // Get The Cursor Terminal And The Corresponding Aa_Sequence Terminals And Set The Display Options
340  ED4_terminal *cursorTerminal = cursor.owner_of_cursor;
341  if (cursorTerminal->is_species_seq_terminal()) {
342  for (int i=0; i<PV_AA_Terminals4Species; i++) {
343  // get the corresponding orf_terminal skipping sequence_info terminal
344  // $$$$$ sequence_terminal->sequence_info_terminal->aa_sequence_terminal $$$$$$
345  cursorTerminal = cursorTerminal->get_next_terminal()->get_next_terminal();
346  // Make sure it is ORF terminal
347  if (cursorTerminal->is_orf_terminal()) {
348  ED4_orf_terminal *orfTerm = cursorTerminal->to_orf_terminal();
349  PV_ManageTerminalDisplay(root, orfTerm, PV_CURSOR);
350  }
351  }
352  }
353  }
354  }
355  }
356 }
357 
359  // Manage the terminals showing only those selected by the user
360  if (gTerminalsCreated) {
361  PV_ManageTerminals(root);
362  }
363  // Refresh all windows
364  // ED4_ROOT->refresh_all_windows(0);
365 }
366 
367 static GB_ERROR PV_ComplementarySequence(char *sequence) {
368  char T_or_U;
369  GB_ERROR error = GBT_determine_T_or_U(ED4_ROOT->alignment_type, &T_or_U, "complement");
370  if (!error) {
371  int seqLen = strlen(sequence);
372  char *complementarySeq = GBT_complementNucSequence((const char*) sequence, seqLen, T_or_U);
373 
374  strcpy(sequence, complementarySeq);
375  free(complementarySeq);
376  }
377  return error;
378 }
379 
380 static void PV_WriteTranslatedSequenceToDB(ED4_orf_terminal *aaSeqTerm, const char *spName) {
383  GBDATA *gb_species = GBT_find_species(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(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(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(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(gb_main, defaultAlignment);
443  gb_new_alignment = GBT_create_alignment(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(gb_main, NULp);
456  }
457 
458  free(str_SeqData);
459  }
460  }
461  free(defaultAlignment);
462  }
463  }
464  GB_end_transaction_show_error(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;
515  GBDATA *gb_species = GBT_find_species(gb_main, speciesName);
516  if (!gb_species) error = GBS_global_string("Species '%s' does not exist", speciesName);
517  else {
518  char *defaultAlignment = GBT_get_default_alignment(gb_main);
519  if (!defaultAlignment) error = GB_await_error();
520  else {
521  GBDATA *gb_SeqData = GBT_find_sequence(gb_species, defaultAlignment);
522  if (!gb_SeqData) {
523  error = GB_have_error()
524  ? GB_await_error()
525  : GBS_global_string("Species '%s' has no data in alignment '%s'", speciesName, defaultAlignment);
526  }
527  else {
528  e4_assert(startPos4Translation>=0 && startPos4Translation<=2);
529 
530  char *str_SeqData = GB_read_string(gb_SeqData);
531  if (!str_SeqData) error = GB_await_error();
532  else {
533  int len = GB_read_string_count(gb_SeqData);
534  int translationTable = AWT_default_protein_type(gb_main);
535 
536  switch (translationMode) {
537  case FORWARD_STRAND:
538  break;
539 
540  case COMPLEMENTARY_STRAND: {
541  // convert sequence to the complementary sequence
542  GB_ERROR compl_err = PV_ComplementarySequence(str_SeqData);
543  if (compl_err) error = GBS_global_string("Failed to calc complementary strand for '%s' (Reason: %s)", speciesName, compl_err);
544  break;
545  }
546  case DB_FIELD_STRAND: {
547  // for use database field options - fetch codon start and translation table from the respective species data
548  GBDATA *gb_translTable = GB_entry(gb_species, "transl_table");
549  if (gb_translTable) {
550  int sp_embl_table = atoi(GB_read_char_pntr(gb_translTable));
551  translationTable = TTIT_embl2arb(sp_embl_table);
552  }
553  else { // use selected translation table as default (if 'transl_table' field is missing)
554  gMissingTransTable++;
555  }
556  GBDATA *gb_codonStart = GB_entry(gb_species, "codon_start");
557  if (gb_codonStart) {
558  startPos4Translation = atoi(GB_read_char_pntr(gb_codonStart))-1;
559  if (startPos4Translation<0 || startPos4Translation>2) {
560  error = GB_export_errorf("'%s' has invalid codon_start entry %i (allowed: 1..3)", speciesName, startPos4Translation+1);
561  }
562  }
563  else {
564  gMissingCodonStart++;
565  startPos4Translation = 0;
566  }
567  break;
568  }
569  }
570 
571  if (!error) {
572  translate_nuc2aa(translationTable, str_SeqData, len, startPos4Translation, false, true, false, NULp); // translate
573 
574  char *s = new char[len+1];
576  int i, j;
577 
578  if (iDisplayMode == PV_AA_NAME) {
579  char *gc = new char[len+1];
580 
581  for (i=0, j=0; i<len && j<len;) {
582  // start from the start pos of aa sequence
583  for (; i<startPos4Translation; ++i) {
584  s[i] = ' ';
585  gc[i] = ' ';
586  }
587 
588  char base = str_SeqData[j++];
589  const char *AAname = getAminoAcidAbbr(base);
590  if (!AAname) AAname = ED4_is_gap_character(base) ? "---" : "<?>";
591 
592  e4_assert(AAname && strlen(AAname) == 3);
593  for (int n = 0; n<3 && i<len; ++n,++i) {
594  s[i] = AAname[n];
595  gc[i] = base;
596  }
597  }
598 
599  gc[i] = '\0';
600  seqTerm->SET_aaColor(gc);
601  delete [] gc;
602  }
603  else {
604  int k = startPos4Translation+1;
605  for (i=0, j=0; i<len; i++) {
606  if ((k==i) && (j<len)) {
607  s[i] = str_SeqData[j++];
608  k += 3;
609  }
610  else s[i] = ' ';
611  }
612  seqTerm->SET_aaColor(NULp);
613  }
614  s[i] = '\0';
615 
616  seqTerm->SET_aaSequence(s);
617  delete [] s;
618  }
619  free(str_SeqData);
620  }
621  }
622  }
623  free(defaultAlignment);
624  }
625 
626  if (error) aw_message(GBS_global_string("Error: %s", error));
627 }
628 
631  if (gMissingCodonStart>0) {
632  aw_message(GBS_global_string("WARNING: 'codon start' entry not found in %d of %d species! Using 1st base as codon start...",
633  gMissingCodonStart,
634  (int)GBT_count_marked_species(gb_main)));
635  gMissingCodonStart = 0;
636  }
637  if (gMissingTransTable>0) {
638  aw_message(GBS_global_string("WARNING: 'translation table' entry not found in %d of %d species! Using selected translation table as a default table...",
639  gMissingTransTable,
640  (int)GBT_count_marked_species(gb_main)));
641  gMissingTransTable = 0;
642  }
643 }
644 
645 static void PV_DisplayAminoAcidNames(AW_root *root) {
647 
649  terminal;
650  terminal = terminal->get_next_terminal())
651  {
652  if (terminal->is_species_seq_terminal()) {
653  const char *speciesName = terminal->to_sequence_terminal()->species_name;
654 
655  // we are in the sequence terminal section of a species
656  // walk through all the corresponding ORF terminals for the species and
657  // hide or unhide the terminals based on the display options set by the user
658  for (int i=0; i<PV_AA_Terminals4Species; i++) {
659  // get the corresponding orf_terminal skipping sequence_info terminal
660  terminal = terminal->get_next_terminal()->get_next_terminal();
661  // Make sure it is ORF terminal
662  if (terminal->is_orf_terminal()) {
663  ED4_orf_terminal *orfTerm = terminal->to_orf_terminal();
664  // we are in ORF terminal
665  int aaStartPos = int(orfTerm->GET_aaStartPos());
666  int aaStrandType = int(orfTerm->GET_aaStrandType());
667  // retranslate the genesequence and store it to the orf_terminal
668  TranslateGeneToAminoAcidSequence(root, orfTerm, speciesName, aaStartPos-1, aaStrandType);
669  }
670  }
671  }
672  }
673  // Print missing DB entries
675  PV_RefreshWindow(root);
676 }
677 
678 static void PV_RefreshDisplay(AW_root *root) {
680 }
681 
683  if (gTerminalsCreated) {
684  PV_RefreshDisplay(aww->get_root());
685  }
686 }
687 
689  if (gbtype==GB_CB_CHANGED &&
692  !gbWritingData)
693  {
695 
696  for (ED4_window *win = ED4_ROOT->first_window; win; win = win->next) {
697  ED4_cursor& cursor = win->cursor;
698  if (cursor.in_species_seq_terminal()) {
699  ED4_terminal *cursorTerminal = cursor.owner_of_cursor;
700  char *speciesName = cursorTerminal->to_sequence_terminal()->species_name;
701  for (int i=0; i<PV_AA_Terminals4Species; i++) {
702  // get the corresponding orf_terminal skipping sequence_info terminal
703  // $$$$$ sequence_terminal->sequence_info_terminal->aa_sequence_terminal $$$$$$
704  cursorTerminal = cursorTerminal->get_next_terminal()->get_next_terminal();
705  // Make sure it is ORF terminal
706  if (cursorTerminal->is_orf_terminal()) {
707  ED4_orf_terminal *orfTerm = cursorTerminal->to_orf_terminal();
708  // Get the AA sequence flag - says which strand we are in
709  int aaStartPos = int(orfTerm->GET_aaStartPos());
710  int aaStrandType = int(orfTerm->GET_aaStrandType());
711  // retranslate the genesequence and store it to the orf_terminal
712  TranslateGeneToAminoAcidSequence(ED4_ROOT->aw_root, orfTerm, speciesName, aaStartPos-1, aaStrandType);
713  }
714  }
715  // Print missing DB entries
718  }
719  }
720  }
721 }
722 
723 static void PV_AddNewAAseqTerminals(ED4_sequence_terminal *seqTerminal, ED4_species_manager *speciesManager) {
724  int translationMode = 0;
725  char namebuffer[NAME_BUFFERSIZE];
726 
727  for (int i = 0; i<PV_AA_Terminals4Species; i++) {
728  int count = 1;
729  int startPos = 0;
730 
731  sprintf(namebuffer, "Sequence_Manager.%ld.%d", ED4_counter, count++);
732  ED4_multi_sequence_manager *multiSeqManager = speciesManager->search_spec_child_rek(LEV_MULTI_SEQUENCE)->to_multi_sequence_manager();
733  ED4_sequence_manager *new_SeqManager = new ED4_sequence_manager(namebuffer, 0, 0, multiSeqManager);
734  new_SeqManager->set_property(PROP_MOVABLE);
735  multiSeqManager->append_member(new_SeqManager);
736 
737  if (i<FORWARD_STRANDS) sprintf(namebuffer, "F%d ProteinInfo_Term%ld.%d", i+1, ED4_counter, count++);
738  else if ((i-FORWARD_STRANDS)<COMPLEMENTARY_STRANDS) sprintf(namebuffer, "C%dProteinInfo_Term%ld.%d", (i-FORWARD_STRANDS)+1, ED4_counter, count++);
739  else sprintf(namebuffer, "DBProteinInfo_Term%ld.%d", ED4_counter, count++);
740 
741  {
742  ED4_sequence_info_terminal *new_SeqInfoTerminal = new ED4_sequence_info_terminal(namebuffer, SEQUENCE_INFO_WIDTH, TERMINAL_HEIGHT, new_SeqManager);
743  new_SeqInfoTerminal->set_property((ED4_properties) (PROP_SELECTABLE | PROP_DRAGABLE | PROP_IS_HANDLE));
744 
745  ED4_sequence_info_terminal *seqInfoTerminal = speciesManager->search_spec_child_rek(LEV_SEQUENCE_INFO)->to_sequence_info_terminal();
746  new_SeqInfoTerminal->set_both_links(seqInfoTerminal);
747  new_SeqManager->append_member(new_SeqInfoTerminal);
748  }
749 
750  {
751  sprintf(namebuffer, "AA_Sequence_Term%ld.%d", ED4_counter, count++);
752  ED4_orf_terminal *AA_SeqTerminal = new ED4_orf_terminal(namebuffer, 0, TERMINAL_HEIGHT, new_SeqManager);
753  AA_SeqTerminal->set_both_links(seqTerminal);
754 
755  char *speciesName = seqTerminal->species_name;
756  if (i<FORWARD_STRANDS) {
757  startPos = i;
758  translationMode = FORWARD_STRAND;
759  }
760  else if ((i-FORWARD_STRANDS)<COMPLEMENTARY_STRANDS) {
761  startPos = i-FORWARD_STRANDS;
762  translationMode = COMPLEMENTARY_STRAND;
763  }
764  else {
765  startPos = 0;
766  translationMode = DB_FIELD_STRAND;
767  }
768  TranslateGeneToAminoAcidSequence(ED4_ROOT->aw_root, AA_SeqTerminal, speciesName, startPos, translationMode);
769  AA_SeqTerminal->SET_aaSeqFlags(startPos+1, translationMode);
770  new_SeqManager->append_member(AA_SeqTerminal);
771  }
772 
773  ED4_counter++;
774 
775  new_SeqManager->request_resize();
776  }
777 }
778 
779 void PV_AddCorrespondingOrfTerminals(ED4_species_name_terminal *spNameTerm) {
780  if (gTerminalsCreated && spNameTerm) {
781  ED4_sequence_terminal *seqTerminal = spNameTerm->corresponding_sequence_terminal();
782  ED4_species_manager *speciesManager = spNameTerm->get_parent(LEV_SPECIES)->to_species_manager();
783  PV_AddNewAAseqTerminals(seqTerminal, speciesManager);
785  }
786 }
787 
789  if (gTerminalsCreated) {
791  GB_transaction ta(gb_main);
792  int marked = GBT_count_marked_species(gb_main);
793  if (marked) {
794  GBDATA *gbSpecies;
795  for (gbSpecies = GBT_first_marked_species(gb_main);
796  gbSpecies;
797  gbSpecies = GBT_next_marked_species(gbSpecies))
798  {
799  const char *spName = GBT_get_name_or_description(gbSpecies);
800  cout<<marked--<<". "<<spName<<endl;
801  ED4_species_name_terminal *spNameTerm = ED4_find_species_name_terminal(spName);
802  if (spNameTerm) {
803  ED4_terminal *terminal = spNameTerm->corresponding_sequence_terminal();
804  // $$$ If next terminal is species_name terminal => corresponding AA seq terminal doesn't exist ==> create one $$$
805  terminal = terminal->get_next_terminal();
806  if (terminal->is_species_name_terminal() || terminal->is_spacer_terminal()) {
807  ED4_sequence_terminal *seqTerminal = spNameTerm->corresponding_sequence_terminal();
808  ED4_species_manager *speciesManager = spNameTerm->get_parent(LEV_SPECIES)->to_species_manager();
809  PV_AddNewAAseqTerminals(seqTerminal, speciesManager);
810  }
811  }
812  }
814  }
815  }
816 }
817 
818 static void PV_CreateAllTerminals(AW_root *root) {
819  // 1. Get the species terminal pointer
820  // 2. Append the second terminal
821  // 3. resize the multi-species manager
822  // 4. refresh all the terminals including new appended terminals
823 
824  // Look for already created terminals, if found do nothing, otherwise, create
825  // new terminals and set gTerminalsCreated to true
826  bool bTerminalsFound = PV_LookForNewTerminals(root);
827  // if terminals are already created then do nothing exit the function
828  if (bTerminalsFound) return;
829 
831 
832  // Number of ORF terminals to be created = 3 forward strands + 3 complementary strands + 1 DB field strand
833  // totally 7 strands has to be created
834  int aaTerminalsToBeCreated = FORWARD_STRANDS + COMPLEMENTARY_STRANDS + DB_FIELD_STRANDS;
835  PV_AA_Terminals4Species = aaTerminalsToBeCreated;
836 
837  ED4_terminal *terminal = NULp;
838  for (terminal = ED4_ROOT->root_group_man->get_first_terminal();
839  terminal;
840  terminal = terminal->get_next_terminal())
841  {
842  if (terminal->is_sequence_terminal()) {
843  ED4_sequence_terminal *seqTerminal = terminal->to_sequence_terminal();
844  if (seqTerminal->species_name) {
845  ED4_species_manager *speciesManager = terminal->get_parent(LEV_SPECIES)->to_species_manager();
846  if (speciesManager->is_species_seq_manager()) {
847  PV_AddNewAAseqTerminals(seqTerminal, speciesManager);
848  }
849  }
850  }
851  }
852  ED4_ROOT->main_manager->request_resize(); // @@@ instead needs to be called whenever adding or deleting PV-terminals
853 
854  gTerminalsCreated = true;
855 
856  // Print missing DB entries
858 }
859 
861  // Create New Terminals If Aminoacid Sequence Terminals Are Not Created
862  if (!gTerminalsCreated) {
863  // AWAR_PROTEIN_TYPE is not initialized (if called from ED4_main before creating proteinViewer window)
864  // so, initialize it here
866  PV_CreateAllTerminals(root);
867  }
868 
869  PV_RefreshWindow(root);
870 }
871 
872 // --------------------------------------------------------------------------------
873 // Binding callback function to the AWARS
874 
875 static void PV_AddCallBacks(AW_root *awr) {
876 
885 
888 
897 
906 
915 }
916 
917 // --------------------------------------------------------------------------------
918 // Creating AWARS to be used by the PROTVIEW module
919 
920 void PV_CreateAwars(AW_root *root, AW_default aw_def) {
921 
922  root->awar_int(AWAR_PV_DISPLAY_ALL, 0, aw_def);
923 
924  root->awar_int(AWAR_PROTVIEW_FORWARD_STRAND_1, 0, aw_def);
925  root->awar_int(AWAR_PROTVIEW_FORWARD_STRAND_2, 0, aw_def);
926  root->awar_int(AWAR_PROTVIEW_FORWARD_STRAND_3, 0, aw_def);
927 
931 
932  root->awar_int(AWAR_PROTVIEW_DEFINED_FIELDS, 0, aw_def);
933  root->awar_int(AWAR_PROTVIEW_DISPLAY_OPTIONS, 0, aw_def);
934 
935  root->awar_int(AWAR_PV_SELECTED, 0, aw_def);
936  root->awar_int(AWAR_PV_SELECTED_DB, 0, aw_def);
937  root->awar_int(AWAR_PV_SELECTED_FS_1, 0, aw_def);
938  root->awar_int(AWAR_PV_SELECTED_FS_2, 0, aw_def);
939  root->awar_int(AWAR_PV_SELECTED_FS_3, 0, aw_def);
940  root->awar_int(AWAR_PV_SELECTED_CS_1, 0, aw_def);
941  root->awar_int(AWAR_PV_SELECTED_CS_2, 0, aw_def);
942  root->awar_int(AWAR_PV_SELECTED_CS_3, 0, aw_def);
943 
944  root->awar_int(AWAR_PV_MARKED, 0, aw_def);
945  root->awar_int(AWAR_PV_MARKED_DB, 0, aw_def);
946  root->awar_int(AWAR_PV_MARKED_FS_1, 0, aw_def);
947  root->awar_int(AWAR_PV_MARKED_FS_2, 0, aw_def);
948  root->awar_int(AWAR_PV_MARKED_FS_3, 0, aw_def);
949  root->awar_int(AWAR_PV_MARKED_CS_1, 0, aw_def);
950  root->awar_int(AWAR_PV_MARKED_CS_2, 0, aw_def);
951  root->awar_int(AWAR_PV_MARKED_CS_3, 0, aw_def);
952 
953  root->awar_int(AWAR_PV_CURSOR, 0, aw_def);
954  root->awar_int(AWAR_PV_CURSOR_DB, 0, aw_def);
955  root->awar_int(AWAR_PV_CURSOR_FS_1, 0, aw_def);
956  root->awar_int(AWAR_PV_CURSOR_FS_2, 0, aw_def);
957  root->awar_int(AWAR_PV_CURSOR_FS_3, 0, aw_def);
958  root->awar_int(AWAR_PV_CURSOR_CS_1, 0, aw_def);
959  root->awar_int(AWAR_PV_CURSOR_CS_2, 0, aw_def);
960  root->awar_int(AWAR_PV_CURSOR_CS_3, 0, aw_def);
961 }
962 
965  GB_transaction ta(gb_main);
966 
967  static AW_window_simple *aws = NULp;
968  if (aws) return aws;
969 
970  aws = new AW_window_simple;
971 
972  aws->init(aw_root, "PROTEIN_VIEWER", "Protein Viewer");
973  aws->load_xfig("proteinViewer.fig");
974 
975  aws->at("refresh");
976  aws->callback(PV_RefreshProtViewDisplay);
977  aws->button_length(0);
978  aws->create_button("REFRESH", "#refresh_text.xpm");
979 
980  aws->callback(makeHelpCallback("proteinViewer.hlp"));
981  aws->at("help");
982  aws->button_length(0);
983  aws->create_button("HELP", "#help_text.xpm");
984 
985  aws->at("close");
986  aws->callback(AW_POPDOWN);
987  aws->button_length(0);
988  aws->create_button("CLOSE", "#close_text.xpm");
989 
990  {
992  aws->at("table");
993  aws->create_option_menu(AWAR_PROTEIN_TYPE, true);
994  for (int code_nr=0; code_nr<AWT_CODON_TABLES; code_nr++) {
995  aws->insert_option(AWT_get_codon_code_name(code_nr), "", code_nr);
996  }
997  aws->update_option_menu();
998 
999  aws->at("all");
1000  aws->create_toggle(AWAR_PV_DISPLAY_ALL);
1001 
1002  aws->at("f1");
1003  aws->create_toggle(AWAR_PROTVIEW_FORWARD_STRAND_1);
1004 
1005  aws->at("f2");
1006  aws->create_toggle(AWAR_PROTVIEW_FORWARD_STRAND_2);
1007 
1008  aws->at("f3");
1009  aws->create_toggle(AWAR_PROTVIEW_FORWARD_STRAND_3);
1010 
1011  aws->at("c1");
1012  aws->create_toggle(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_1);
1013 
1014  aws->at("c2");
1015  aws->create_toggle(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_2);
1016 
1017  aws->at("c3");
1018  aws->create_toggle(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_3);
1019 
1020  aws->at("defined");
1021  aws->create_toggle(AWAR_PROTVIEW_DEFINED_FIELDS);
1022 
1023  aws->at("dispOption");
1024  aws->create_toggle_field(AWAR_PROTVIEW_DISPLAY_OPTIONS, 0);
1025  aws->insert_toggle("Single Letter Code", "S", 0);
1026  aws->insert_toggle("Triple Letter Code", "T", 1);
1027  aws->insert_toggle("Colored Box", "B", 2);
1028  aws->update_toggle_field();
1029 
1030  aws->at("colMaps");
1031  aws->callback(makeCreateWindowCallback(ED4_create_seq_colors_window, ED4_ROOT->sequence_colors));
1032  aws->button_length(0);
1033  aws->create_button("COLORMAPS", "#colorMaps.xpm");
1034 
1035  aws->at("colors");
1036  aws->callback(makeWindowCallback(ED4_popup_gc_window, ED4_ROOT->gc_manager));
1037  aws->button_length(0);
1038  aws->create_button("COLORS", "#colors.xpm");
1039 
1040  {
1041  aws->at("sel"); aws->create_toggle(AWAR_PV_SELECTED);
1042  aws->at("sf1"); aws->create_toggle(AWAR_PV_SELECTED_FS_1);
1043  aws->at("sf2"); aws->create_toggle(AWAR_PV_SELECTED_FS_2);
1044  aws->at("sf3"); aws->create_toggle(AWAR_PV_SELECTED_FS_3);
1045  aws->at("sc1"); aws->create_toggle(AWAR_PV_SELECTED_CS_1);
1046  aws->at("sc2"); aws->create_toggle(AWAR_PV_SELECTED_CS_2);
1047  aws->at("sc3"); aws->create_toggle(AWAR_PV_SELECTED_CS_3);
1048  aws->at("sdb"); aws->create_toggle(AWAR_PV_SELECTED_DB);
1049 
1050  aws->at("mrk"); aws->create_toggle(AWAR_PV_MARKED);
1051  aws->at("mf1"); aws->create_toggle(AWAR_PV_MARKED_FS_1);
1052  aws->at("mf2"); aws->create_toggle(AWAR_PV_MARKED_FS_2);
1053  aws->at("mf3"); aws->create_toggle(AWAR_PV_MARKED_FS_3);
1054  aws->at("mc1"); aws->create_toggle(AWAR_PV_MARKED_CS_1);
1055  aws->at("mc2"); aws->create_toggle(AWAR_PV_MARKED_CS_2);
1056  aws->at("mc3"); aws->create_toggle(AWAR_PV_MARKED_CS_3);
1057  aws->at("mdb"); aws->create_toggle(AWAR_PV_MARKED_DB);
1058 
1059  aws->at("cur"); aws->create_toggle(AWAR_PV_CURSOR);
1060  aws->at("cf1"); aws->create_toggle(AWAR_PV_CURSOR_FS_1);
1061  aws->at("cf2"); aws->create_toggle(AWAR_PV_CURSOR_FS_2);
1062  aws->at("cf3"); aws->create_toggle(AWAR_PV_CURSOR_FS_3);
1063  aws->at("cc1"); aws->create_toggle(AWAR_PV_CURSOR_CS_1);
1064  aws->at("cc2"); aws->create_toggle(AWAR_PV_CURSOR_CS_2);
1065  aws->at("cc3"); aws->create_toggle(AWAR_PV_CURSOR_CS_3);
1066  aws->at("cdb"); aws->create_toggle(AWAR_PV_CURSOR_DB);
1067  }
1068 
1069  aws->at("save");
1070  aws->callback(PV_SaveData);
1071  aws->button_length(5);
1072  aws->create_button("SAVE", "#save.xpm");
1073  }
1074 
1075  // binding callback function to the AWARS
1076  PV_AddCallBacks(aw_root);
1077 
1078  // Create All Terminals
1079  PV_CreateAllTerminals(aw_root);
1080 
1081  aws->show();
1082 
1083  return aws;
1084 }
1085 
GB_ERROR GB_begin_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2516
static void PV_PrintMissingDBentryInformation()
#define AWAR_PV_MARKED_DB
void set_both_links(ED4_base *ref)
Definition: ed4_class.hxx:971
void PV_SequenceUpdate_CB(GB_CB_TYPE gbtype)
void unhide_children()
Definition: ED4_base.cxx:830
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:1849
#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:1385
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:1851
#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:2186
#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:2572
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:643
void SET_aaSequence(const char *aaSeq)
Definition: ed4_class.hxx:1970
AW_gc_manager * gc_manager
Definition: ed4_class.hxx:1442
long ED4_counter
Definition: ED4_main.cxx:60
#define e4_assert(bed)
Definition: ed4_class.hxx:11
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:81
size_t GB_read_string_count(GBDATA *gbd)
Definition: arbdb.cxx:910
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:819
#define DB_FIELD_STRAND
GBDATA * get_gb_main() const
Definition: ed4_class.hxx:1420
#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:891
#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:1426
#define AWAR_PROTVIEW_DISPLAY_OPTIONS
ED4_terminal * get_next_terminal()
Definition: ED4_base.cxx:454
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:1430
static bool gTerminalsCreated
#define AWAR_SPECIES_NAME
ED4_main_manager * main_manager
Definition: ed4_class.hxx:1427
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:1439
static void PV_UnHideTerminal(ED4_orf_terminal *orfTerm)
long GBT_count_marked_species(GBDATA *gb_main)
Definition: aditem.cxx:353
static int PV_AA_Terminals4Species
const char * AWT_get_codon_code_name(int code)
int TERMINAL_HEIGHT
Definition: ED4_main.cxx:50
#define NAME_BUFFERSIZE
Definition: ed4_defs.hxx:112
#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:1083
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:434
ED4_cursor & current_cursor()
Definition: ed4_class.hxx:1399
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:974
void SET_aaSeqFlags(int startPos, int strandType)
Definition: ed4_class.hxx:1969
char * GB_read_string(GBDATA *gbd)
Definition: arbdb.cxx:903
const int AWAR_PROTEIN_TYPE_bacterial_code_index
ED4_seq_colors * sequence_colors
Definition: ed4_class.hxx:1441
AW_root * aw_root
Definition: ed4_class.hxx:1423
#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:175
unsigned int hidden
Definition: ed4_class.hxx:926
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:1295
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:139
static int giNewAlignments
#define AWAR_PV_MARKED_FS_2
void SET_aaColor(const char *aaSeq)
Definition: ed4_class.hxx:1971
int is_sequence_terminal() const
Definition: ed4_class.hxx:1082
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:898
GBDATA * gb_main
Definition: adname.cxx:33
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:441
int is_spacer_terminal() const
Definition: ed4_class.hxx:1089
#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:1820
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:1079
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:1467
GB_write_int const char s
Definition: AW_awar.cxx:156