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_class.hxx" |
---|
15 | |
---|
16 | #include <awt_pro_a_nucs.hxx> |
---|
17 | #include <awt_codon_table.hxx> |
---|
18 | #include <awt_translate.hxx> |
---|
19 | #include <awt_seq_colors.hxx> |
---|
20 | #include <aw_question.hxx> |
---|
21 | #include <aw_preset.hxx> |
---|
22 | #include <aw_awars.hxx> |
---|
23 | #include <arbdbt.h> |
---|
24 | |
---|
25 | #include <iostream> |
---|
26 | |
---|
27 | using namespace std; |
---|
28 | |
---|
29 | // Definitions used |
---|
30 | #define FORWARD_STRAND 1 |
---|
31 | #define COMPLEMENTARY_STRAND 2 |
---|
32 | #define DB_FIELD_STRAND 3 |
---|
33 | |
---|
34 | #define FORWARD_STRANDS 3 |
---|
35 | #define COMPLEMENTARY_STRANDS 3 |
---|
36 | #define DB_FIELD_STRANDS 1 |
---|
37 | |
---|
38 | // typedefs |
---|
39 | typedef enum { |
---|
40 | PV_FAILED = 0, |
---|
41 | PV_SUCCESS |
---|
42 | } PV_ERROR; |
---|
43 | |
---|
44 | enum { |
---|
45 | PV_MARKED = 0, |
---|
46 | PV_SELECTED, |
---|
47 | PV_CURSOR, |
---|
48 | PV_ALL |
---|
49 | }; |
---|
50 | |
---|
51 | #define BUFFERSIZE 1000 |
---|
52 | |
---|
53 | // Global Variables |
---|
54 | extern GBDATA *GLOBAL_gb_main; |
---|
55 | |
---|
56 | static bool gTerminalsCreated = false; |
---|
57 | static int PV_AA_Terminals4Species = 0; |
---|
58 | static int gMissingTransTable = 0; |
---|
59 | static int gMissingCodonStart = 0; |
---|
60 | static bool gbWritingData = false; |
---|
61 | static int giNewAlignments = 0; |
---|
62 | |
---|
63 | static AW_repeated_question *ASKtoOverWriteData = 0; |
---|
64 | |
---|
65 | bool PV_LookForNewTerminals(AW_root *root){ |
---|
66 | bool bTerminalsFound = true; |
---|
67 | |
---|
68 | int all = root->awar(AWAR_PV_DISPLAY_ALL)->read_int(); |
---|
69 | int all_f1 = root->awar(AWAR_PROTVIEW_FORWARD_STRAND_1)->read_int(); |
---|
70 | int all_f2 = root->awar(AWAR_PROTVIEW_FORWARD_STRAND_2)->read_int(); |
---|
71 | int all_f3 = root->awar(AWAR_PROTVIEW_FORWARD_STRAND_3)->read_int(); |
---|
72 | int all_c1 = root->awar(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_1)->read_int(); |
---|
73 | int all_c2 = root->awar(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_2)->read_int(); |
---|
74 | int all_c3 = root->awar(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_3)->read_int(); |
---|
75 | int all_db = root->awar(AWAR_PROTVIEW_DEFINED_FIELDS)->read_int(); |
---|
76 | |
---|
77 | int sel = root->awar(AWAR_PV_SELECTED)->read_int(); |
---|
78 | int sel_db = root->awar(AWAR_PV_SELECTED_DB)->read_int(); |
---|
79 | int sel_f1 = root->awar(AWAR_PV_SELECTED_FS_1)->read_int(); |
---|
80 | int sel_f2 = root->awar(AWAR_PV_SELECTED_FS_2)->read_int(); |
---|
81 | int sel_f3 = root->awar(AWAR_PV_SELECTED_FS_3)->read_int(); |
---|
82 | int sel_c1 = root->awar(AWAR_PV_SELECTED_CS_1)->read_int(); |
---|
83 | int sel_c2 = root->awar(AWAR_PV_SELECTED_CS_2)->read_int(); |
---|
84 | int sel_c3 = root->awar(AWAR_PV_SELECTED_CS_3)->read_int(); |
---|
85 | |
---|
86 | int mrk = root->awar(AWAR_PV_MARKED)->read_int(); |
---|
87 | int mrk_db = root->awar(AWAR_PV_MARKED_DB)->read_int(); |
---|
88 | int mrk_f1 = root->awar(AWAR_PV_MARKED_FS_1)->read_int(); |
---|
89 | int mrk_f2 = root->awar(AWAR_PV_MARKED_FS_2)->read_int(); |
---|
90 | int mrk_f3 = root->awar(AWAR_PV_MARKED_FS_3)->read_int(); |
---|
91 | int mrk_c1 = root->awar(AWAR_PV_MARKED_CS_1)->read_int(); |
---|
92 | int mrk_c2 = root->awar(AWAR_PV_MARKED_CS_2)->read_int(); |
---|
93 | int mrk_c3 = root->awar(AWAR_PV_MARKED_CS_3)->read_int(); |
---|
94 | |
---|
95 | int cur = root->awar(AWAR_PV_CURSOR)->read_int(); |
---|
96 | int cur_db = root->awar(AWAR_PV_CURSOR_DB)->read_int(); |
---|
97 | int cur_f1 = root->awar(AWAR_PV_CURSOR_FS_1)->read_int(); |
---|
98 | int cur_f2 = root->awar(AWAR_PV_CURSOR_FS_2)->read_int(); |
---|
99 | int cur_f3 = root->awar(AWAR_PV_CURSOR_FS_3)->read_int(); |
---|
100 | int cur_c1 = root->awar(AWAR_PV_CURSOR_CS_1)->read_int(); |
---|
101 | int cur_c2 = root->awar(AWAR_PV_CURSOR_CS_2)->read_int(); |
---|
102 | int cur_c3 = root->awar(AWAR_PV_CURSOR_CS_3)->read_int(); |
---|
103 | |
---|
104 | // Test whether any of the options are selected or not? |
---|
105 | if ((all && (all_f1 || all_f2 || all_f3 || all_c1 || all_c2 || all_c3 || all_db)) || |
---|
106 | (sel && (sel_db || sel_f1 || sel_f2 || sel_f3 || sel_c1 || sel_c2 || sel_c3)) || |
---|
107 | (mrk && (mrk_db || mrk_f1 || mrk_f2 || mrk_f3 || mrk_c1 || mrk_c2 || mrk_c3)) || |
---|
108 | (cur && (cur_db || cur_f1 || cur_f2 || cur_f3 || cur_c1 || cur_c2 || cur_c3))) |
---|
109 | { |
---|
110 | // if so, then test whether the terminals are created already or not? |
---|
111 | if(gTerminalsCreated) { |
---|
112 | // if yes, then set the flag to true |
---|
113 | bTerminalsFound = true; |
---|
114 | } |
---|
115 | else { |
---|
116 | //if not, then new terminals has to be created |
---|
117 | bTerminalsFound = false; |
---|
118 | } |
---|
119 | } |
---|
120 | return bTerminalsFound; |
---|
121 | } |
---|
122 | |
---|
123 | void PV_HideTerminal(ED4_AA_sequence_terminal *aaSeqTerminal) { |
---|
124 | ED4_sequence_manager *seqManager = aaSeqTerminal->get_parent(ED4_L_SEQUENCE)->to_sequence_manager(); |
---|
125 | seqManager->hide_children(); |
---|
126 | } |
---|
127 | |
---|
128 | void PV_UnHideTerminal(ED4_AA_sequence_terminal *aaSeqTerminal) { |
---|
129 | ED4_sequence_manager *seqManager = aaSeqTerminal->get_parent(ED4_L_SEQUENCE)->to_sequence_manager(); |
---|
130 | seqManager->make_children_visible(); |
---|
131 | } |
---|
132 | |
---|
133 | void PV_HideAllTerminals(){ |
---|
134 | ED4_terminal *terminal = 0; |
---|
135 | for( terminal = ED4_ROOT->root_group_man->get_first_terminal(); |
---|
136 | terminal; |
---|
137 | terminal = terminal->get_next_terminal()) |
---|
138 | { |
---|
139 | if(terminal->is_sequence_terminal()) { |
---|
140 | ED4_species_manager *speciesManager = terminal->get_parent(ED4_L_SPECIES)->to_species_manager(); |
---|
141 | if (speciesManager && !speciesManager->flag.is_consensus && !speciesManager->flag.is_SAI) { |
---|
142 | // hide all AA_Sequence terminals |
---|
143 | for(int i=0; i<PV_AA_Terminals4Species; i++) { |
---|
144 | // get the corresponding AA_sequence_terminal skipping sequence_info terminal |
---|
145 | // $$$$$ sequence_terminal->sequence_info_terminal->aa_sequence_terminal $$$$$$ |
---|
146 | terminal = terminal->get_next_terminal()->get_next_terminal(); |
---|
147 | // Make sure it is AA sequence terminal |
---|
148 | if (terminal->is_aa_sequence_terminal()) { |
---|
149 | ED4_AA_sequence_terminal *aaSeqTerminal = terminal->to_aa_sequence_terminal(); |
---|
150 | PV_HideTerminal(aaSeqTerminal); |
---|
151 | } |
---|
152 | } |
---|
153 | } |
---|
154 | } |
---|
155 | } |
---|
156 | } |
---|
157 | |
---|
158 | |
---|
159 | void PV_ManageTerminalDisplay(AW_root *root, ED4_AA_sequence_terminal *aaSeqTerminal,long int DispMode){ |
---|
160 | |
---|
161 | int all, af_1,af_2,af_3,ac_1,ac_2,ac_3,adb; |
---|
162 | all = root->awar(AWAR_PV_DISPLAY_ALL)->read_int(); |
---|
163 | adb = root->awar(AWAR_PROTVIEW_DEFINED_FIELDS)->read_int(); |
---|
164 | af_1 = root->awar(AWAR_PROTVIEW_FORWARD_STRAND_1)->read_int(); |
---|
165 | af_2 = root->awar(AWAR_PROTVIEW_FORWARD_STRAND_2)->read_int(); |
---|
166 | af_3 = root->awar(AWAR_PROTVIEW_FORWARD_STRAND_3)->read_int(); |
---|
167 | ac_1 = root->awar(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_1)->read_int(); |
---|
168 | ac_2 = root->awar(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_2)->read_int(); |
---|
169 | ac_3 = root->awar(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_3)->read_int(); |
---|
170 | |
---|
171 | int mrk, mf_1,mf_2,mf_3,mc_1,mc_2,mc_3,mdb; |
---|
172 | mrk = root->awar(AWAR_PV_MARKED)->read_int(); |
---|
173 | mdb = root->awar(AWAR_PV_MARKED_DB)->read_int(); |
---|
174 | mf_1 = root->awar(AWAR_PV_MARKED_FS_1)->read_int(); |
---|
175 | mf_2 = root->awar(AWAR_PV_MARKED_FS_2)->read_int(); |
---|
176 | mf_3 = root->awar(AWAR_PV_MARKED_FS_3)->read_int(); |
---|
177 | mc_1 = root->awar(AWAR_PV_MARKED_CS_1)->read_int(); |
---|
178 | mc_2 = root->awar(AWAR_PV_MARKED_CS_2)->read_int(); |
---|
179 | mc_3 = root->awar(AWAR_PV_MARKED_CS_3)->read_int(); |
---|
180 | |
---|
181 | int sel, sf_1,sf_2,sf_3,sc_1,sc_2,sc_3,sdb; |
---|
182 | sel = root->awar(AWAR_PV_SELECTED)->read_int(); |
---|
183 | sdb = root->awar(AWAR_PV_SELECTED_DB)->read_int(); |
---|
184 | sf_1 = root->awar(AWAR_PV_SELECTED_FS_1)->read_int(); |
---|
185 | sf_2 = root->awar(AWAR_PV_SELECTED_FS_2)->read_int(); |
---|
186 | sf_3 = root->awar(AWAR_PV_SELECTED_FS_3)->read_int(); |
---|
187 | sc_1 = root->awar(AWAR_PV_SELECTED_CS_1)->read_int(); |
---|
188 | sc_2 = root->awar(AWAR_PV_SELECTED_CS_2)->read_int(); |
---|
189 | sc_3 = root->awar(AWAR_PV_SELECTED_CS_3)->read_int(); |
---|
190 | |
---|
191 | int cur, cf_1,cf_2,cf_3,cc_1,cc_2,cc_3,cdb; |
---|
192 | cur = root->awar(AWAR_PV_CURSOR)->read_int(); |
---|
193 | cdb = root->awar(AWAR_PV_CURSOR_DB)->read_int(); |
---|
194 | cf_1 = root->awar(AWAR_PV_CURSOR_FS_1)->read_int(); |
---|
195 | cf_2 = root->awar(AWAR_PV_CURSOR_FS_2)->read_int(); |
---|
196 | cf_3 = root->awar(AWAR_PV_CURSOR_FS_3)->read_int(); |
---|
197 | cc_1 = root->awar(AWAR_PV_CURSOR_CS_1)->read_int(); |
---|
198 | cc_2 = root->awar(AWAR_PV_CURSOR_CS_2)->read_int(); |
---|
199 | cc_3 = root->awar(AWAR_PV_CURSOR_CS_3)->read_int(); |
---|
200 | |
---|
201 | // Get the AA sequence flag - says which strand we are in |
---|
202 | int aaStrandType = int(aaSeqTerminal->GET_aaStrandType()); |
---|
203 | // Check the display options and make visible or hide the AA seq terminal |
---|
204 | switch (aaStrandType) |
---|
205 | { |
---|
206 | case FORWARD_STRAND: |
---|
207 | { |
---|
208 | int aaStartPos = int(aaSeqTerminal->GET_aaStartPos()); |
---|
209 | switch (aaStartPos){ |
---|
210 | case 1: |
---|
211 | switch (DispMode){ |
---|
212 | case PV_ALL: (all && af_1)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
213 | case PV_MARKED: (mrk && mf_1)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
214 | case PV_SELECTED: (sel && sf_1)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
215 | case PV_CURSOR: (cur && cf_1)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
216 | } |
---|
217 | break; |
---|
218 | case 2: |
---|
219 | switch (DispMode){ |
---|
220 | case PV_ALL: (all && af_2)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
221 | case PV_MARKED: (mrk && mf_2)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
222 | case PV_SELECTED: (sel && sf_2)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
223 | case PV_CURSOR: (cur && cf_2)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
224 | } |
---|
225 | break; |
---|
226 | case 3: |
---|
227 | switch (DispMode){ |
---|
228 | case PV_ALL: (all && af_3)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
229 | case PV_MARKED: (mrk && mf_3)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
230 | case PV_SELECTED: (sel && sf_3)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
231 | case PV_CURSOR: (cur && cf_3)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
232 | } |
---|
233 | break; |
---|
234 | } |
---|
235 | } |
---|
236 | break; |
---|
237 | case COMPLEMENTARY_STRAND: |
---|
238 | { |
---|
239 | int aaStartPos = int(aaSeqTerminal->GET_aaStartPos()); |
---|
240 | switch (aaStartPos){ |
---|
241 | case 1: |
---|
242 | switch (DispMode){ |
---|
243 | case PV_ALL: (all && ac_1)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
244 | case PV_MARKED: (mrk && mc_1)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
245 | case PV_SELECTED: (sel && sc_1)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
246 | case PV_CURSOR: (cur && cc_1)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
247 | } |
---|
248 | break; |
---|
249 | case 2: |
---|
250 | switch (DispMode){ |
---|
251 | case PV_ALL: (all && ac_2)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
252 | case PV_MARKED: (mrk && mc_2)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
253 | case PV_SELECTED: (sel && sc_2)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
254 | case PV_CURSOR: (cur && cc_2)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
255 | } |
---|
256 | break; |
---|
257 | case 3: |
---|
258 | switch (DispMode){ |
---|
259 | case PV_ALL: (all && ac_3)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
260 | case PV_MARKED: (mrk && mc_3)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
261 | case PV_SELECTED: (sel && sc_3)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
262 | case PV_CURSOR: (cur && cc_3)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
263 | } |
---|
264 | break; |
---|
265 | } |
---|
266 | } |
---|
267 | break; |
---|
268 | case DB_FIELD_STRAND: |
---|
269 | switch (DispMode){ |
---|
270 | case PV_ALL: (all && adb)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
271 | case PV_MARKED: (mrk && mdb)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
272 | case PV_SELECTED: (sel && sdb)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
273 | case PV_CURSOR: (cur && cdb)? PV_UnHideTerminal(aaSeqTerminal): PV_HideTerminal(aaSeqTerminal); break; |
---|
274 | } |
---|
275 | break; |
---|
276 | } |
---|
277 | } |
---|
278 | |
---|
279 | void PV_ManageTerminals(AW_root *root){ |
---|
280 | |
---|
281 | // First Hide all AA_sequence Terminals |
---|
282 | PV_HideAllTerminals(); |
---|
283 | |
---|
284 | int dispAll = root->awar(AWAR_PV_DISPLAY_ALL)->read_int(); |
---|
285 | if (dispAll) |
---|
286 | { |
---|
287 | ED4_terminal *terminal = 0; |
---|
288 | for( terminal = ED4_ROOT->root_group_man->get_first_terminal(); |
---|
289 | terminal; |
---|
290 | terminal = terminal->get_next_terminal()) |
---|
291 | { |
---|
292 | if(terminal->is_sequence_terminal()) { |
---|
293 | ED4_species_manager *speciesManager = terminal->get_parent(ED4_L_SPECIES)->to_species_manager(); |
---|
294 | if (speciesManager && !speciesManager->flag.is_consensus && !speciesManager->flag.is_SAI) { |
---|
295 | // we are in the sequence terminal section of a species |
---|
296 | // walk through all the corresponding AA sequence terminals for the speecies and |
---|
297 | // hide or unhide the terminals based on the display options set by the user |
---|
298 | for(int i=0; i<PV_AA_Terminals4Species; i++) { |
---|
299 | // get the corresponding AA_sequence_terminal skipping sequence_info terminal |
---|
300 | // $$$$$ sequence_terminal->sequence_info_terminal->aa_sequence_terminal $$$$$$ |
---|
301 | terminal = terminal->get_next_terminal()->get_next_terminal(); |
---|
302 | // Make sure it is AA sequence terminal |
---|
303 | if (terminal->is_aa_sequence_terminal()) { |
---|
304 | ED4_AA_sequence_terminal *aaSeqTerminal = terminal->to_aa_sequence_terminal(); |
---|
305 | PV_ManageTerminalDisplay(root, aaSeqTerminal, PV_ALL); |
---|
306 | } |
---|
307 | } |
---|
308 | } |
---|
309 | } |
---|
310 | } |
---|
311 | } |
---|
312 | |
---|
313 | int dispMarked = root->awar(AWAR_PV_MARKED)->read_int(); |
---|
314 | if (dispMarked) |
---|
315 | { |
---|
316 | GB_transaction dummy(GLOBAL_gb_main); |
---|
317 | int marked = GBT_count_marked_species(GLOBAL_gb_main); |
---|
318 | if (marked) { |
---|
319 | GBDATA *gbSpecies; |
---|
320 | for (gbSpecies = GBT_first_marked_species(GLOBAL_gb_main); |
---|
321 | gbSpecies; |
---|
322 | gbSpecies = GBT_next_marked_species(gbSpecies)) |
---|
323 | { |
---|
324 | ED4_species_name_terminal *spNameTerm = ED4_find_species_name_terminal(GBT_read_name(gbSpecies)); |
---|
325 | if (spNameTerm && spNameTerm->is_species_name_terminal()) |
---|
326 | { |
---|
327 | ED4_terminal *terminal = spNameTerm->corresponding_sequence_terminal(); |
---|
328 | for(int i=0; i<PV_AA_Terminals4Species; i++) { |
---|
329 | // get the corresponding AA_sequence_terminal skipping sequence_info terminal |
---|
330 | // $$$$$ sequence_terminal->sequence_info_terminal->aa_sequence_terminal $$$$$$ |
---|
331 | terminal = terminal->get_next_terminal()->get_next_terminal(); |
---|
332 | // Make sure it is AA sequence terminal |
---|
333 | if (terminal->is_aa_sequence_terminal()) { |
---|
334 | ED4_AA_sequence_terminal *aaSeqTerminal = terminal->to_aa_sequence_terminal(); |
---|
335 | PV_ManageTerminalDisplay(root, aaSeqTerminal, PV_MARKED); |
---|
336 | } |
---|
337 | } |
---|
338 | } |
---|
339 | } |
---|
340 | } |
---|
341 | } |
---|
342 | |
---|
343 | int dispSelected = root->awar(AWAR_PV_SELECTED)->read_int(); |
---|
344 | if (dispSelected) |
---|
345 | { |
---|
346 | ED4_terminal *terminal = 0; |
---|
347 | for( terminal = ED4_ROOT->root_group_man->get_first_terminal(); |
---|
348 | terminal; |
---|
349 | terminal = terminal->get_next_terminal()) |
---|
350 | { |
---|
351 | if(terminal->is_sequence_terminal()) { |
---|
352 | ED4_species_manager *speciesManager = terminal->get_parent(ED4_L_SPECIES)->to_species_manager(); |
---|
353 | if (speciesManager && !speciesManager->flag.is_consensus && !speciesManager->flag.is_SAI) { |
---|
354 | // we are in the sequence terminal section of a species |
---|
355 | // walk through all the corresponding AA sequence terminals for the speecies and |
---|
356 | // hide or unhide the terminals based on the display options set by the user |
---|
357 | ED4_species_name_terminal *speciesNameTerm = speciesManager->search_spec_child_rek(ED4_L_SPECIES_NAME)->to_species_name_terminal(); |
---|
358 | if (speciesNameTerm->flag.selected) { |
---|
359 | for(int i=0; i<PV_AA_Terminals4Species; i++) { |
---|
360 | // get the corresponding AA_sequence_terminal skipping sequence_info terminal |
---|
361 | // $$$$$ sequence_terminal->sequence_info_terminal->aa_sequence_terminal $$$$$$ |
---|
362 | terminal = terminal->get_next_terminal()->get_next_terminal(); |
---|
363 | // Make sure it is AA sequence terminal |
---|
364 | if (terminal->is_aa_sequence_terminal()) { |
---|
365 | ED4_AA_sequence_terminal *aaSeqTerminal = terminal->to_aa_sequence_terminal(); |
---|
366 | PV_ManageTerminalDisplay(root, aaSeqTerminal,PV_SELECTED); |
---|
367 | } |
---|
368 | } |
---|
369 | } |
---|
370 | } |
---|
371 | } |
---|
372 | } |
---|
373 | } |
---|
374 | |
---|
375 | int dispAtCursor = root->awar(AWAR_PV_CURSOR)->read_int(); |
---|
376 | if (dispAtCursor) |
---|
377 | { |
---|
378 | // Display Only Terminals Corresponding To The Cursor Position in the multiple alignment |
---|
379 | ED4_cursor *cursor = &ED4_ROOT->get_ed4w()->cursor; |
---|
380 | if (cursor->owner_of_cursor) { |
---|
381 | // Get The Cursor Terminal And The Corresponding Aa_Sequence Terminals And Set The Display Options |
---|
382 | ED4_terminal *cursorTerminal = cursor->owner_of_cursor->to_terminal(); |
---|
383 | if (!cursorTerminal->parent->parent->flag.is_consensus) { |
---|
384 | for(int i=0; i<PV_AA_Terminals4Species; i++) { |
---|
385 | // get the corresponding AA_sequence_terminal skipping sequence_info terminal |
---|
386 | // $$$$$ sequence_terminal->sequence_info_terminal->aa_sequence_terminal $$$$$$ |
---|
387 | cursorTerminal = cursorTerminal->get_next_terminal()->get_next_terminal(); |
---|
388 | // Make sure it is AA sequence terminal |
---|
389 | if (cursorTerminal->is_aa_sequence_terminal()) { |
---|
390 | ED4_AA_sequence_terminal *aaSeqTerminal = cursorTerminal->to_aa_sequence_terminal(); |
---|
391 | PV_ManageTerminalDisplay(root, aaSeqTerminal, PV_CURSOR); |
---|
392 | } |
---|
393 | } |
---|
394 | } |
---|
395 | } |
---|
396 | } |
---|
397 | } |
---|
398 | |
---|
399 | void PV_RefreshWindow(AW_root *root){ |
---|
400 | // Manage the terminals showing only those selected by the user |
---|
401 | if(gTerminalsCreated) { |
---|
402 | PV_ManageTerminals(root); |
---|
403 | } |
---|
404 | //Refresh all windows |
---|
405 | ED4_refresh_window(0, 0, 0); |
---|
406 | ED4_ROOT->refresh_all_windows(0); |
---|
407 | } |
---|
408 | |
---|
409 | PV_ERROR PV_ComplementarySequence(char *sequence) |
---|
410 | { |
---|
411 | char T_or_U; |
---|
412 | GB_ERROR error = GBT_determine_T_or_U(ED4_ROOT->alignment_type, &T_or_U, "complement"); |
---|
413 | if (error) { |
---|
414 | cout<<error<<endl; |
---|
415 | return PV_FAILED; |
---|
416 | } |
---|
417 | |
---|
418 | int seqLen = strlen(sequence); |
---|
419 | char *complementarySeq = GBT_complementNucSequence((const char*) sequence, seqLen, T_or_U); |
---|
420 | strcpy(sequence, complementarySeq); |
---|
421 | return PV_SUCCESS; |
---|
422 | } |
---|
423 | |
---|
424 | static void PV_WriteTranslatedSequenceToDB(ED4_AA_sequence_terminal *aaSeqTerm, char *spName) { |
---|
425 | GB_begin_transaction(GLOBAL_gb_main); //open database for transaction |
---|
426 | |
---|
427 | GB_ERROR error = 0; |
---|
428 | GBDATA *gb_species = GBT_find_species(GLOBAL_gb_main, spName); |
---|
429 | char *defaultAlignment = GBT_get_default_alignment(GLOBAL_gb_main); |
---|
430 | GBDATA *gb_SeqData = GBT_read_sequence(gb_species, defaultAlignment); |
---|
431 | |
---|
432 | char *str_SeqData = 0; |
---|
433 | int len = 0; |
---|
434 | if (gb_SeqData) { |
---|
435 | str_SeqData = GB_read_string(gb_SeqData); |
---|
436 | len = GB_read_string_count(gb_SeqData); |
---|
437 | } |
---|
438 | else error = "error in reading sequence from database!"; |
---|
439 | |
---|
440 | if (!error) { |
---|
441 | GBDATA *gb_ProSeqData = 0; |
---|
442 | char newAlignmentName[100]; |
---|
443 | int aaStrandType = int(aaSeqTerm->GET_aaStrandType()); |
---|
444 | { // If strandType is complementary strand then Get complementary sequence |
---|
445 | if(aaStrandType == COMPLEMENTARY_STRAND) { |
---|
446 | PV_ERROR pvError = PV_ComplementarySequence(str_SeqData); |
---|
447 | if (pvError == PV_FAILED) { |
---|
448 | error = "Getting complementary strand failed!!"; |
---|
449 | } |
---|
450 | } |
---|
451 | } |
---|
452 | |
---|
453 | if (!error) { |
---|
454 | int aaStartPos = int(aaSeqTerm->GET_aaStartPos()); |
---|
455 | switch (aaStrandType) { |
---|
456 | case FORWARD_STRAND: |
---|
457 | sprintf(newAlignmentName, "ali_pro_ProtView_forward_start_pos_%ld", (long int) aaStartPos); break; |
---|
458 | case COMPLEMENTARY_STRAND: |
---|
459 | sprintf(newAlignmentName, "ali_pro_ProtView_complementary_start_pos_%ld", (long int) aaStartPos); break; |
---|
460 | case DB_FIELD_STRAND: |
---|
461 | sprintf(newAlignmentName, "ali_pro_ProtView_database_field_start_pos_%ld", (long int) aaStartPos); break; |
---|
462 | } |
---|
463 | |
---|
464 | AWT_pro_a_nucs_convert(AWT_default_protein_type(), str_SeqData, len, aaStartPos-1, false, true, false, 0); |
---|
465 | |
---|
466 | // Create alignment data to store the translated sequence |
---|
467 | GBDATA *gb_presets = GB_search(GLOBAL_gb_main, "presets", GB_CREATE_CONTAINER); |
---|
468 | GBDATA *gb_alignment_exists = GB_find_string(gb_presets, "alignment_name", newAlignmentName, GB_IGNORE_CASE, down_2_level); |
---|
469 | GBDATA *gb_new_alignment = 0; |
---|
470 | |
---|
471 | if (gb_alignment_exists) { |
---|
472 | int skip_sp = 0; |
---|
473 | char *question = 0; |
---|
474 | GBDATA *gb_seq_data = GBT_read_sequence(gb_species, newAlignmentName); |
---|
475 | if (gb_seq_data) { |
---|
476 | e4_assert(ASKtoOverWriteData); |
---|
477 | question = GBS_global_string_copy("\"%s\" contain data in the alignment \"%s\"!", spName, newAlignmentName); |
---|
478 | skip_sp = ASKtoOverWriteData->get_answer(question, "Overwrite, Skip Species", "all", false); |
---|
479 | } |
---|
480 | if (skip_sp) { |
---|
481 | error = GBS_global_string_copy("%s You chose to skip this Species!", question); |
---|
482 | } |
---|
483 | else { |
---|
484 | gb_new_alignment = GBT_get_alignment(GLOBAL_gb_main,newAlignmentName); |
---|
485 | if (!gb_new_alignment) error = GB_await_error(); |
---|
486 | } |
---|
487 | free(question); |
---|
488 | } |
---|
489 | else { |
---|
490 | long aliLen = GBT_get_alignment_len(GLOBAL_gb_main,defaultAlignment); |
---|
491 | gb_new_alignment = GBT_create_alignment(GLOBAL_gb_main,newAlignmentName,aliLen/3+1,0,1,"ami"); |
---|
492 | |
---|
493 | if (!gb_new_alignment) error = GB_await_error(); |
---|
494 | else giNewAlignments++; |
---|
495 | } |
---|
496 | |
---|
497 | if (!error) { |
---|
498 | gb_ProSeqData = GBT_add_data(gb_species,newAlignmentName,"data", GB_STRING); |
---|
499 | if (gb_ProSeqData) error = GB_write_string(gb_ProSeqData,str_SeqData); |
---|
500 | else error = GB_await_error(); |
---|
501 | } |
---|
502 | } |
---|
503 | free(str_SeqData); |
---|
504 | } |
---|
505 | |
---|
506 | if (!error) error = GBT_check_data(GLOBAL_gb_main,0); |
---|
507 | |
---|
508 | GB_end_transaction_show_error(GLOBAL_gb_main, error, aw_message); |
---|
509 | } |
---|
510 | |
---|
511 | void PV_SaveData(AW_window *aww){ |
---|
512 | //IDEA: |
---|
513 | //1. walk thru the AA_sequence terminals |
---|
514 | //2. check the visibility status |
---|
515 | //3. select only the visible terminals |
---|
516 | //4. get the corresponding species name |
---|
517 | //5. translate the sequence |
---|
518 | //6. write to the database |
---|
519 | gbWritingData = true; |
---|
520 | if(gTerminalsCreated) { |
---|
521 | ASKtoOverWriteData = new AW_repeated_question(); |
---|
522 | |
---|
523 | ED4_terminal *terminal = 0; |
---|
524 | for( terminal = ED4_ROOT->root_group_man->get_first_terminal(); |
---|
525 | terminal; |
---|
526 | terminal = terminal->get_next_terminal()) |
---|
527 | { |
---|
528 | if(terminal->is_sequence_terminal()) { |
---|
529 | char *speciesName = terminal->to_sequence_terminal()->species_name; |
---|
530 | ED4_species_manager *speciesManager = terminal->get_parent(ED4_L_SPECIES)->to_species_manager(); |
---|
531 | if (speciesManager && !speciesManager->flag.is_consensus && !speciesManager->flag.is_SAI) { |
---|
532 | for(int i=0; i<PV_AA_Terminals4Species; i++) { |
---|
533 | // get the corresponding AA_sequence_terminal skipping sequence_info terminal |
---|
534 | terminal = terminal->get_next_terminal()->get_next_terminal(); |
---|
535 | // Make sure it is AA sequence terminal |
---|
536 | if (terminal->is_aa_sequence_terminal()) { |
---|
537 | ED4_AA_sequence_terminal *aaSeqTerminal = terminal->to_aa_sequence_terminal(); |
---|
538 | ED4_base *base = (ED4_base*)aaSeqTerminal; |
---|
539 | if(!base->flag.hidden) { |
---|
540 | PV_WriteTranslatedSequenceToDB(aaSeqTerminal, speciesName);//, ASKtoOverWriteData); |
---|
541 | } |
---|
542 | } |
---|
543 | } |
---|
544 | } |
---|
545 | } |
---|
546 | } |
---|
547 | if (giNewAlignments>0) { |
---|
548 | 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); |
---|
549 | |
---|
550 | aw_popup_ok(msg, false); |
---|
551 | aw_message(msg); |
---|
552 | |
---|
553 | free(msg); |
---|
554 | |
---|
555 | giNewAlignments = 0; |
---|
556 | } |
---|
557 | } |
---|
558 | gbWritingData = false; |
---|
559 | AWUSE(aww); |
---|
560 | } |
---|
561 | |
---|
562 | // This function translates gene sequence to aminoacid sequence and stores into the respective AA_Sequence_terminal |
---|
563 | static void TranslateGeneToAminoAcidSequence(AW_root */*root*/, ED4_AA_sequence_terminal *seqTerm, char *speciesName, int startPos4Translation, int translationMode){ |
---|
564 | GBDATA *gb_species = GBT_find_species(GLOBAL_gb_main, speciesName); |
---|
565 | char *defaultAlignment = GBT_get_default_alignment(GLOBAL_gb_main); |
---|
566 | GBDATA *gb_SeqData = GBT_read_sequence(gb_species, defaultAlignment); |
---|
567 | |
---|
568 | e4_assert(startPos4Translation>=0 && startPos4Translation<=2); |
---|
569 | |
---|
570 | char *str_SeqData = 0; |
---|
571 | int len = 0; |
---|
572 | if (gb_SeqData) { |
---|
573 | str_SeqData = GB_read_string(gb_SeqData); |
---|
574 | len = GB_read_string_count(gb_SeqData); |
---|
575 | } |
---|
576 | |
---|
577 | GB_ERROR error = 0; |
---|
578 | PV_ERROR pvError; |
---|
579 | |
---|
580 | int translationTable = AWT_default_protein_type(GLOBAL_gb_main); |
---|
581 | |
---|
582 | switch(translationMode) { |
---|
583 | case FORWARD_STRAND: |
---|
584 | break; |
---|
585 | case COMPLEMENTARY_STRAND: |
---|
586 | // for complementary strand - get the complementary sequence and then perform translation |
---|
587 | pvError = PV_ComplementarySequence(str_SeqData); |
---|
588 | if (pvError == PV_FAILED) { |
---|
589 | error = "Could not get complementary strand"; |
---|
590 | } |
---|
591 | break; |
---|
592 | case DB_FIELD_STRAND: |
---|
593 | // for use database field options - fetch codon start and translation table from the respective species data |
---|
594 | GBDATA *gb_translTable = GB_entry(gb_species, "transl_table"); |
---|
595 | if (gb_translTable) { |
---|
596 | int sp_embl_table = atoi(GB_read_char_pntr(gb_translTable)); |
---|
597 | translationTable = AWT_embl_transl_table_2_arb_code_nr(sp_embl_table); |
---|
598 | } |
---|
599 | else { // use selected translation table as default (if 'transl_table' field is missing) |
---|
600 | gMissingTransTable++; |
---|
601 | } |
---|
602 | GBDATA *gb_codonStart = GB_entry(gb_species, "codon_start"); |
---|
603 | if (gb_codonStart) { |
---|
604 | startPos4Translation = atoi(GB_read_char_pntr(gb_codonStart))-1; |
---|
605 | if (startPos4Translation<0 || startPos4Translation>2) { |
---|
606 | error = GB_export_errorf("'%s' has invalid codon_start entry %i (allowed: 1..3)", |
---|
607 | speciesName, startPos4Translation+1); |
---|
608 | break; |
---|
609 | } |
---|
610 | } |
---|
611 | else { |
---|
612 | gMissingCodonStart++; |
---|
613 | startPos4Translation = 0; |
---|
614 | } |
---|
615 | break; |
---|
616 | } |
---|
617 | |
---|
618 | if (!error) { |
---|
619 | // do the translation: |
---|
620 | AWT_pro_a_nucs_convert(translationTable, str_SeqData, len, startPos4Translation, false, true, false, 0); |
---|
621 | |
---|
622 | char *s = new char[len+1]; |
---|
623 | int i,j; |
---|
624 | char spChar = ' '; |
---|
625 | { |
---|
626 | int iDisplayMode = ED4_ROOT->aw_root->awar(AWAR_PROTVIEW_DISPLAY_OPTIONS)->read_int(); |
---|
627 | if (iDisplayMode == PV_AA_NAME) |
---|
628 | { |
---|
629 | for( i=0, j=0; i<len && j<len; ) { |
---|
630 | // start from the start pos of aa sequence |
---|
631 | for (;i<startPos4Translation;) s[i++] = spChar; |
---|
632 | char base = str_SeqData[j++]; |
---|
633 | const char *AAname = 0; |
---|
634 | if(base>='A' && base<='Z') { |
---|
635 | AAname = AWT_get_protein_name(base); |
---|
636 | } |
---|
637 | else if (base=='*') { |
---|
638 | AAname = "End"; |
---|
639 | } |
---|
640 | else { |
---|
641 | for(int m =0;m<3 && i<len ;m++) |
---|
642 | s[i++]=base; |
---|
643 | } |
---|
644 | if (AAname) { |
---|
645 | for(unsigned int n =0; n<strlen(AAname) && i<len ;n++) { |
---|
646 | s[i++]=AAname[n]; |
---|
647 | } |
---|
648 | } |
---|
649 | } |
---|
650 | } |
---|
651 | else |
---|
652 | { |
---|
653 | int k = startPos4Translation+1; |
---|
654 | for(i=0, j=0; i<len; i++) { |
---|
655 | if((k==i) && (j<len)) { |
---|
656 | s[i]=str_SeqData[j++]; |
---|
657 | k+=3; |
---|
658 | } |
---|
659 | else |
---|
660 | s[i] = spChar; |
---|
661 | } |
---|
662 | } |
---|
663 | s[i]='\0'; // close the string |
---|
664 | } |
---|
665 | |
---|
666 | seqTerm->SET_aaSequence_pointer(strdup(s)); |
---|
667 | |
---|
668 | delete s; |
---|
669 | } |
---|
670 | free(str_SeqData); |
---|
671 | |
---|
672 | if (error) aw_message(GBS_global_string("Error: %s", error)); |
---|
673 | } |
---|
674 | |
---|
675 | void PV_PrintMissingDBentryInformation(void){ |
---|
676 | if(gMissingCodonStart>0){ |
---|
677 | aw_message(GBS_global_string("WARNING: 'codon start' entry not found in %d of %d species! Using 1st base as codon start...", |
---|
678 | gMissingCodonStart, |
---|
679 | (int)GBT_count_marked_species(GLOBAL_gb_main))); |
---|
680 | gMissingCodonStart = 0; |
---|
681 | } |
---|
682 | if(gMissingTransTable>0){ |
---|
683 | aw_message(GBS_global_string("WARNING: 'translation table' entry not found in %d of %d species! Using selected translation table as a default table...", |
---|
684 | gMissingTransTable, |
---|
685 | (int)GBT_count_marked_species(GLOBAL_gb_main))); |
---|
686 | gMissingTransTable = 0; |
---|
687 | } |
---|
688 | } |
---|
689 | |
---|
690 | void PV_DisplayAminoAcidNames(AW_root *root) { |
---|
691 | GB_transaction dummy(GLOBAL_gb_main); |
---|
692 | |
---|
693 | ED4_terminal *terminal = 0; |
---|
694 | for( terminal = ED4_ROOT->root_group_man->get_first_terminal(); |
---|
695 | terminal; |
---|
696 | terminal = terminal->get_next_terminal()) |
---|
697 | { |
---|
698 | if(terminal->is_sequence_terminal()) { |
---|
699 | ED4_sequence_terminal *seqTerminal = terminal->to_sequence_terminal(); |
---|
700 | char *speciesName = seqTerminal->species_name; |
---|
701 | |
---|
702 | ED4_species_manager *speciesManager = terminal->get_parent(ED4_L_SPECIES)->to_species_manager(); |
---|
703 | if (speciesManager && !speciesManager->flag.is_consensus && !speciesManager->flag.is_SAI) |
---|
704 | { |
---|
705 | // we are in the sequence terminal section of a species |
---|
706 | // walk through all the corresponding AA sequence terminals for the speecies and |
---|
707 | // hide or unhide the terminals based on the display options set by the user |
---|
708 | for(int i=0; i<PV_AA_Terminals4Species; i++) |
---|
709 | { |
---|
710 | // get the corresponding AA_sequence_terminal skipping sequence_info terminal |
---|
711 | terminal = terminal->get_next_terminal()->get_next_terminal(); |
---|
712 | // Make sure it is AA sequence terminal |
---|
713 | if (terminal->is_aa_sequence_terminal()) { |
---|
714 | ED4_AA_sequence_terminal *aaSeqTerminal = terminal->to_aa_sequence_terminal(); |
---|
715 | // we are in AA sequence terminal |
---|
716 | int aaStartPos = int(aaSeqTerminal->GET_aaStartPos()); |
---|
717 | int aaStrandType = int(aaSeqTerminal->GET_aaStrandType()); |
---|
718 | // retranslate the genesequence and store it to the AA_sequnce_terminal |
---|
719 | TranslateGeneToAminoAcidSequence(root, aaSeqTerminal, speciesName, aaStartPos-1, aaStrandType); |
---|
720 | } |
---|
721 | } |
---|
722 | } |
---|
723 | } |
---|
724 | } |
---|
725 | // Print missing DB entries |
---|
726 | PV_PrintMissingDBentryInformation(); |
---|
727 | PV_RefreshWindow(root); |
---|
728 | } |
---|
729 | |
---|
730 | void PV_RefreshDisplay(AW_root *root) { |
---|
731 | PV_DisplayAminoAcidNames(root); |
---|
732 | } |
---|
733 | |
---|
734 | void PV_RefreshProtViewDisplay(AW_window *aww){ |
---|
735 | if(gTerminalsCreated) { |
---|
736 | PV_RefreshDisplay(aww->get_root()); |
---|
737 | } |
---|
738 | } |
---|
739 | |
---|
740 | void PV_AA_SequenceUpdate_CB(GB_CB_TYPE gbtype) |
---|
741 | { |
---|
742 | if (gbtype==GB_CB_CHANGED && |
---|
743 | gTerminalsCreated && |
---|
744 | (ED4_ROOT->alignment_type == GB_AT_DNA) && |
---|
745 | !gbWritingData) |
---|
746 | { |
---|
747 | GB_transaction dummy(GLOBAL_gb_main); |
---|
748 | |
---|
749 | ED4_cursor *cursor = &ED4_ROOT->get_ed4w()->cursor; |
---|
750 | if (cursor->owner_of_cursor) { |
---|
751 | ED4_terminal *cursorTerminal = cursor->owner_of_cursor->to_terminal(); |
---|
752 | |
---|
753 | if (!cursorTerminal->parent->parent->flag.is_consensus) |
---|
754 | { |
---|
755 | ED4_sequence_terminal *seqTerminal = cursorTerminal->to_sequence_terminal(); |
---|
756 | char *speciesName = seqTerminal->species_name; |
---|
757 | |
---|
758 | for(int i=0; i<PV_AA_Terminals4Species; i++) |
---|
759 | { |
---|
760 | // get the corresponding AA_sequence_terminal skipping sequence_info terminal |
---|
761 | // $$$$$ sequence_terminal->sequence_info_terminal->aa_sequence_terminal $$$$$$ |
---|
762 | cursorTerminal = cursorTerminal->get_next_terminal()->get_next_terminal(); |
---|
763 | // Make sure it is AA sequence terminal |
---|
764 | if (cursorTerminal->is_aa_sequence_terminal()) { |
---|
765 | ED4_AA_sequence_terminal *aaSeqTerminal = cursorTerminal->to_aa_sequence_terminal(); |
---|
766 | // Get the AA sequence flag - says which strand we are in |
---|
767 | int aaStartPos = int(aaSeqTerminal->GET_aaStartPos()); |
---|
768 | int aaStrandType = int(aaSeqTerminal->GET_aaStrandType()); |
---|
769 | // retranslate the genesequence and store it to the AA_sequnce_terminal |
---|
770 | TranslateGeneToAminoAcidSequence(ED4_ROOT->aw_root, aaSeqTerminal, speciesName, aaStartPos-1, aaStrandType); |
---|
771 | } |
---|
772 | } |
---|
773 | // Print missing DB entries |
---|
774 | PV_PrintMissingDBentryInformation(); |
---|
775 | PV_RefreshWindow(ED4_ROOT->aw_root); |
---|
776 | } |
---|
777 | } |
---|
778 | } |
---|
779 | } |
---|
780 | |
---|
781 | void PV_AddNewAAseqTerminals(ED4_sequence_terminal *seqTerminal, ED4_species_manager *speciesManager){ |
---|
782 | int translationMode = 0; |
---|
783 | char namebuffer[BUFFERSIZE]; |
---|
784 | for(int i = 0; i<PV_AA_Terminals4Species; i++) |
---|
785 | { |
---|
786 | int count = 1; |
---|
787 | int startPos = 0; |
---|
788 | |
---|
789 | sprintf( namebuffer, "Sequence_Manager.%ld.%d", ED4_counter, count++); |
---|
790 | ED4_multi_sequence_manager *multiSeqManager = speciesManager->search_spec_child_rek(ED4_L_MULTI_SEQUENCE)->to_multi_sequence_manager(); |
---|
791 | ED4_sequence_manager *new_SeqManager = new ED4_sequence_manager(namebuffer, 0, 0, 0, 0, multiSeqManager); |
---|
792 | new_SeqManager->set_properties(ED4_P_MOVABLE); |
---|
793 | multiSeqManager->children->append_member(new_SeqManager); |
---|
794 | |
---|
795 | ED4_sequence_info_terminal *new_SeqInfoTerminal = 0; |
---|
796 | if (i<FORWARD_STRANDS) |
---|
797 | sprintf(namebuffer, "F%d ProtienInfo_Term%ld.%d",i+1,ED4_counter, count++); |
---|
798 | else if ((i-FORWARD_STRANDS)<COMPLEMENTARY_STRANDS) |
---|
799 | sprintf(namebuffer, "C%dProtienInfo_Term%ld.%d",(i-FORWARD_STRANDS)+1,ED4_counter, count++); |
---|
800 | else |
---|
801 | sprintf(namebuffer, "DBProtienInfo_Term%ld.%d",ED4_counter, count++); |
---|
802 | new_SeqInfoTerminal = new ED4_sequence_info_terminal(namebuffer, 0, 0, SEQUENCEINFOSIZE, TERMINALHEIGHT, new_SeqManager ); |
---|
803 | new_SeqInfoTerminal->set_properties( (ED4_properties) (ED4_P_SELECTABLE | ED4_P_DRAGABLE | ED4_P_IS_HANDLE) ); |
---|
804 | ED4_sequence_info_terminal *seqInfoTerminal = speciesManager->search_spec_child_rek(ED4_L_SEQUENCE_INFO)->to_sequence_info_terminal(); |
---|
805 | new_SeqInfoTerminal->set_links( seqInfoTerminal, seqInfoTerminal ); |
---|
806 | new_SeqManager->children->append_member( new_SeqInfoTerminal ); |
---|
807 | |
---|
808 | ED4_AA_sequence_terminal *AA_SeqTerminal = 0; |
---|
809 | sprintf(namebuffer, "AA_Sequence_Term%ld.%d",ED4_counter, count++); |
---|
810 | AA_SeqTerminal = new ED4_AA_sequence_terminal(namebuffer, SEQUENCEINFOSIZE, 0, 0, TERMINALHEIGHT, new_SeqManager); |
---|
811 | AA_SeqTerminal->set_links( seqTerminal, seqTerminal ); |
---|
812 | |
---|
813 | char *speciesName = seqTerminal->species_name; |
---|
814 | if (i<FORWARD_STRANDS){ |
---|
815 | startPos = i; |
---|
816 | translationMode = FORWARD_STRAND; |
---|
817 | } |
---|
818 | else if ((i-FORWARD_STRANDS)<COMPLEMENTARY_STRANDS){ |
---|
819 | startPos = i-FORWARD_STRANDS; |
---|
820 | translationMode = COMPLEMENTARY_STRAND; |
---|
821 | } |
---|
822 | else { |
---|
823 | startPos = 0; |
---|
824 | translationMode = DB_FIELD_STRAND; |
---|
825 | } |
---|
826 | TranslateGeneToAminoAcidSequence(ED4_ROOT->aw_root, AA_SeqTerminal, speciesName, startPos, translationMode); |
---|
827 | AA_SeqTerminal->SET_aaSeqFlags(startPos+1,translationMode); |
---|
828 | new_SeqManager->children->append_member(AA_SeqTerminal); |
---|
829 | |
---|
830 | ED4_counter++; |
---|
831 | |
---|
832 | new_SeqManager->resize_requested_by_child(); |
---|
833 | } |
---|
834 | } |
---|
835 | |
---|
836 | void PV_AddCorrespondingAAseqTerminals(ED4_species_name_terminal *spNameTerm) { |
---|
837 | if(gTerminalsCreated) { |
---|
838 | if (spNameTerm && spNameTerm->is_species_name_terminal()) |
---|
839 | { |
---|
840 | ED4_sequence_terminal *seqTerminal = spNameTerm->corresponding_sequence_terminal()->to_sequence_terminal(); |
---|
841 | ED4_species_manager *speciesManager = spNameTerm->get_parent(ED4_L_SPECIES)->to_species_manager(); |
---|
842 | PV_AddNewAAseqTerminals(seqTerminal,speciesManager); |
---|
843 | PV_RefreshWindow(ED4_ROOT->aw_root); |
---|
844 | } |
---|
845 | } |
---|
846 | } |
---|
847 | |
---|
848 | void PV_AddAAseqTerminalsToLoadedSpecies() { |
---|
849 | if(gTerminalsCreated) { |
---|
850 | GB_transaction dummy(GLOBAL_gb_main); |
---|
851 | int marked = GBT_count_marked_species(GLOBAL_gb_main); |
---|
852 | if (marked) { |
---|
853 | GBDATA *gbSpecies; |
---|
854 | for(gbSpecies = GBT_first_marked_species(GLOBAL_gb_main); |
---|
855 | gbSpecies; |
---|
856 | gbSpecies = GBT_next_marked_species(gbSpecies)) |
---|
857 | { |
---|
858 | const char *spName = GBT_read_name(gbSpecies); |
---|
859 | cout<<marked--<<". "<<spName<<endl; |
---|
860 | ED4_species_name_terminal *spNameTerm = ED4_find_species_name_terminal(spName); |
---|
861 | if (spNameTerm && spNameTerm->is_species_name_terminal()) |
---|
862 | { |
---|
863 | ED4_terminal *terminal = spNameTerm->corresponding_sequence_terminal(); |
---|
864 | // $$$ If next terminal is species_name terminal => corresponding AA seq terminal doesnt exist ==> create one $$$ |
---|
865 | terminal = terminal->get_next_terminal(); |
---|
866 | if (terminal->is_species_name_terminal() || terminal->is_spacer_terminal()) |
---|
867 | { |
---|
868 | ED4_sequence_terminal *seqTerminal = spNameTerm->corresponding_sequence_terminal()->to_sequence_terminal(); |
---|
869 | ED4_species_manager *speciesManager = spNameTerm->get_parent(ED4_L_SPECIES)->to_species_manager(); |
---|
870 | PV_AddNewAAseqTerminals(seqTerminal,speciesManager); |
---|
871 | } |
---|
872 | } |
---|
873 | } |
---|
874 | PV_RefreshWindow(ED4_ROOT->aw_root); |
---|
875 | } |
---|
876 | } |
---|
877 | } |
---|
878 | |
---|
879 | void PV_CreateAllTerminals(AW_root *root) { |
---|
880 | // 1. Get the species terminal pointer |
---|
881 | // 2. Append the second terminal |
---|
882 | // 3. resize the multi-species manager |
---|
883 | // 4. refresh all the terminals including new appended terminals |
---|
884 | |
---|
885 | // Look for already created terminals, if found do nothing, otherwise, create |
---|
886 | // new terminals and set gTerminalsCreated to true |
---|
887 | bool bTerminalsFound = PV_LookForNewTerminals(root); |
---|
888 | // if terminals are already created then do nothing exit the function |
---|
889 | if(bTerminalsFound) return; |
---|
890 | |
---|
891 | GB_transaction dummy(GLOBAL_gb_main); |
---|
892 | |
---|
893 | // Number of AA sequence terminals to be created = 3 forward strands + 3 complementary strands + 1 DB field strand |
---|
894 | // totally 7 strands has to be created |
---|
895 | int aaTerminalsToBeCreated = FORWARD_STRANDS + COMPLEMENTARY_STRANDS + DB_FIELD_STRANDS; |
---|
896 | PV_AA_Terminals4Species = aaTerminalsToBeCreated; |
---|
897 | |
---|
898 | ED4_terminal *terminal = 0; |
---|
899 | for( terminal = ED4_ROOT->root_group_man->get_first_terminal(); |
---|
900 | terminal; |
---|
901 | terminal = terminal->get_next_terminal()) |
---|
902 | { |
---|
903 | if(terminal->is_sequence_terminal()) { |
---|
904 | ED4_sequence_terminal *seqTerminal = terminal->to_sequence_terminal(); |
---|
905 | if(seqTerminal->species_name) |
---|
906 | { |
---|
907 | ED4_species_manager *speciesManager = terminal->get_parent(ED4_L_SPECIES)->to_species_manager(); |
---|
908 | if (speciesManager && !speciesManager->flag.is_consensus && !speciesManager->flag.is_SAI) |
---|
909 | { |
---|
910 | PV_AddNewAAseqTerminals(seqTerminal,speciesManager); |
---|
911 | } |
---|
912 | } |
---|
913 | } |
---|
914 | } |
---|
915 | ED4_ROOT->main_manager->update_info.set_resize(1); |
---|
916 | ED4_ROOT->main_manager->resize_requested_by_parent(); |
---|
917 | |
---|
918 | gTerminalsCreated = true; |
---|
919 | |
---|
920 | // Print missing DB entries |
---|
921 | PV_PrintMissingDBentryInformation(); |
---|
922 | |
---|
923 | // ED4_ROOT->refresh_all_windows(0); |
---|
924 | } |
---|
925 | |
---|
926 | void PV_CallBackFunction(AW_root *root) { |
---|
927 | // Create New Terminals If Aminoacid Sequence Terminals Are Not Created |
---|
928 | if (!gTerminalsCreated) { |
---|
929 | // AWAR_PROTEIN_TYPE is not initialized (if called from ED4_main before creating proteinViewer window) |
---|
930 | // so, initilize it here |
---|
931 | root->awar_int(AWAR_PROTEIN_TYPE, AWAR_PROTEIN_TYPE_bacterial_code_index, GLOBAL_gb_main); |
---|
932 | PV_CreateAllTerminals(root); |
---|
933 | } |
---|
934 | |
---|
935 | PV_RefreshWindow(root); |
---|
936 | } |
---|
937 | |
---|
938 | // -------------------------------------------------------------------------------- |
---|
939 | // Binding callback function to the AWARS |
---|
940 | // -------------------------------------------------------------------------------- |
---|
941 | void PV_AddCallBacks(AW_root *awr) { |
---|
942 | |
---|
943 | awr->awar(AWAR_PV_DISPLAY_ALL)->add_callback(PV_CallBackFunction); |
---|
944 | awr->awar(AWAR_PROTVIEW_FORWARD_STRAND_1)->add_callback(PV_CallBackFunction); |
---|
945 | awr->awar(AWAR_PROTVIEW_FORWARD_STRAND_2)->add_callback(PV_CallBackFunction); |
---|
946 | awr->awar(AWAR_PROTVIEW_FORWARD_STRAND_3)->add_callback(PV_CallBackFunction); |
---|
947 | awr->awar(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_1)->add_callback(PV_CallBackFunction); |
---|
948 | awr->awar(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_2)->add_callback(PV_CallBackFunction); |
---|
949 | awr->awar(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_3)->add_callback(PV_CallBackFunction); |
---|
950 | awr->awar(AWAR_PROTVIEW_DEFINED_FIELDS)->add_callback(PV_CallBackFunction); |
---|
951 | |
---|
952 | awr->awar(AWAR_PROTVIEW_DISPLAY_OPTIONS)->add_callback(PV_RefreshDisplay); |
---|
953 | awr->awar(AWAR_SPECIES_NAME)->add_callback(PV_CallBackFunction); |
---|
954 | |
---|
955 | awr->awar(AWAR_PV_SELECTED)->add_callback(PV_CallBackFunction); |
---|
956 | awr->awar(AWAR_PV_SELECTED_DB)->add_callback(PV_CallBackFunction); |
---|
957 | awr->awar(AWAR_PV_SELECTED_FS_1)->add_callback(PV_CallBackFunction); |
---|
958 | awr->awar(AWAR_PV_SELECTED_FS_2)->add_callback(PV_CallBackFunction); |
---|
959 | awr->awar(AWAR_PV_SELECTED_FS_3)->add_callback(PV_CallBackFunction); |
---|
960 | awr->awar(AWAR_PV_SELECTED_CS_1)->add_callback(PV_CallBackFunction); |
---|
961 | awr->awar(AWAR_PV_SELECTED_CS_2)->add_callback(PV_CallBackFunction); |
---|
962 | awr->awar(AWAR_PV_SELECTED_CS_3)->add_callback(PV_CallBackFunction); |
---|
963 | |
---|
964 | awr->awar(AWAR_PV_MARKED)->add_callback(PV_CallBackFunction); |
---|
965 | awr->awar(AWAR_PV_MARKED_DB)->add_callback(PV_CallBackFunction); |
---|
966 | awr->awar(AWAR_PV_MARKED_FS_1)->add_callback(PV_CallBackFunction); |
---|
967 | awr->awar(AWAR_PV_MARKED_FS_2)->add_callback(PV_CallBackFunction); |
---|
968 | awr->awar(AWAR_PV_MARKED_FS_3)->add_callback(PV_CallBackFunction); |
---|
969 | awr->awar(AWAR_PV_MARKED_CS_1)->add_callback(PV_CallBackFunction); |
---|
970 | awr->awar(AWAR_PV_MARKED_CS_2)->add_callback(PV_CallBackFunction); |
---|
971 | awr->awar(AWAR_PV_MARKED_CS_3)->add_callback(PV_CallBackFunction); |
---|
972 | |
---|
973 | awr->awar(AWAR_PV_CURSOR)->add_callback(PV_CallBackFunction); |
---|
974 | awr->awar(AWAR_PV_CURSOR_DB)->add_callback(PV_CallBackFunction); |
---|
975 | awr->awar(AWAR_PV_CURSOR_FS_1)->add_callback(PV_CallBackFunction); |
---|
976 | awr->awar(AWAR_PV_CURSOR_FS_2)->add_callback(PV_CallBackFunction); |
---|
977 | awr->awar(AWAR_PV_CURSOR_FS_3)->add_callback(PV_CallBackFunction); |
---|
978 | awr->awar(AWAR_PV_CURSOR_CS_1)->add_callback(PV_CallBackFunction); |
---|
979 | awr->awar(AWAR_PV_CURSOR_CS_2)->add_callback(PV_CallBackFunction); |
---|
980 | awr->awar(AWAR_PV_CURSOR_CS_3)->add_callback(PV_CallBackFunction); |
---|
981 | } |
---|
982 | |
---|
983 | // -------------------------------------------------------------------------------- |
---|
984 | // Creating AWARS to be used by the PROTVIEW module |
---|
985 | // -------------------------------------------------------------------------------- |
---|
986 | void PV_CreateAwars(AW_root *root, AW_default aw_def){ |
---|
987 | |
---|
988 | root->awar_int(AWAR_PV_DISPLAY_ALL, 0, aw_def); |
---|
989 | |
---|
990 | root->awar_int(AWAR_PROTVIEW_FORWARD_STRAND_1, 0, aw_def); |
---|
991 | root->awar_int(AWAR_PROTVIEW_FORWARD_STRAND_2, 0, aw_def); |
---|
992 | root->awar_int(AWAR_PROTVIEW_FORWARD_STRAND_3, 0, aw_def); |
---|
993 | |
---|
994 | root->awar_int(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_1, 0, aw_def); |
---|
995 | root->awar_int(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_2, 0, aw_def); |
---|
996 | root->awar_int(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_3, 0, aw_def); |
---|
997 | |
---|
998 | root->awar_int(AWAR_PROTVIEW_DEFINED_FIELDS, 0, aw_def); |
---|
999 | root->awar_int(AWAR_PROTVIEW_DISPLAY_OPTIONS, 0, aw_def); |
---|
1000 | |
---|
1001 | root->awar_int(AWAR_PV_SELECTED, 0, aw_def); |
---|
1002 | root->awar_int(AWAR_PV_SELECTED_DB, 0, aw_def); |
---|
1003 | root->awar_int(AWAR_PV_SELECTED_FS_1, 0, aw_def); |
---|
1004 | root->awar_int(AWAR_PV_SELECTED_FS_2, 0, aw_def); |
---|
1005 | root->awar_int(AWAR_PV_SELECTED_FS_3, 0, aw_def); |
---|
1006 | root->awar_int(AWAR_PV_SELECTED_CS_1, 0, aw_def); |
---|
1007 | root->awar_int(AWAR_PV_SELECTED_CS_2, 0, aw_def); |
---|
1008 | root->awar_int(AWAR_PV_SELECTED_CS_3, 0, aw_def); |
---|
1009 | |
---|
1010 | root->awar_int(AWAR_PV_MARKED, 0, aw_def); |
---|
1011 | root->awar_int(AWAR_PV_MARKED_DB, 0, aw_def); |
---|
1012 | root->awar_int(AWAR_PV_MARKED_FS_1, 0, aw_def); |
---|
1013 | root->awar_int(AWAR_PV_MARKED_FS_2, 0, aw_def); |
---|
1014 | root->awar_int(AWAR_PV_MARKED_FS_3, 0, aw_def); |
---|
1015 | root->awar_int(AWAR_PV_MARKED_CS_1, 0, aw_def); |
---|
1016 | root->awar_int(AWAR_PV_MARKED_CS_2, 0, aw_def); |
---|
1017 | root->awar_int(AWAR_PV_MARKED_CS_3, 0, aw_def); |
---|
1018 | |
---|
1019 | root->awar_int(AWAR_PV_CURSOR, 0, aw_def); |
---|
1020 | root->awar_int(AWAR_PV_CURSOR_DB, 0, aw_def); |
---|
1021 | root->awar_int(AWAR_PV_CURSOR_FS_1, 0, aw_def); |
---|
1022 | root->awar_int(AWAR_PV_CURSOR_FS_2, 0, aw_def); |
---|
1023 | root->awar_int(AWAR_PV_CURSOR_FS_3, 0, aw_def); |
---|
1024 | root->awar_int(AWAR_PV_CURSOR_CS_1, 0, aw_def); |
---|
1025 | root->awar_int(AWAR_PV_CURSOR_CS_2, 0, aw_def); |
---|
1026 | root->awar_int(AWAR_PV_CURSOR_CS_3, 0, aw_def); |
---|
1027 | } |
---|
1028 | |
---|
1029 | AW_window *ED4_CreateProteinViewer_window(AW_root *aw_root) { |
---|
1030 | GB_transaction dummy(GLOBAL_gb_main); |
---|
1031 | |
---|
1032 | static AW_window_simple *aws = 0; |
---|
1033 | if (aws) return aws; |
---|
1034 | |
---|
1035 | aws = new AW_window_simple; |
---|
1036 | |
---|
1037 | aws->init( aw_root, "PROTEIN_VIEWER", "Protein Viewer"); |
---|
1038 | aws->load_xfig("proteinViewer.fig"); |
---|
1039 | |
---|
1040 | aws->at("refresh"); |
---|
1041 | aws->callback(PV_RefreshProtViewDisplay); |
---|
1042 | aws->button_length(0); |
---|
1043 | aws->create_button("REFRESH","#refresh_text.xpm"); |
---|
1044 | |
---|
1045 | aws->callback( AW_POPUP_HELP,(AW_CL)"proteinViewer.hlp"); |
---|
1046 | aws->at("help"); |
---|
1047 | aws->button_length(0); |
---|
1048 | aws->create_button("HELP","#help_text.xpm"); |
---|
1049 | |
---|
1050 | aws->at("close"); |
---|
1051 | aws->callback((AW_CB0)AW_POPDOWN); |
---|
1052 | aws->button_length(0); |
---|
1053 | aws->create_button("CLOSE","#close_text.xpm"); |
---|
1054 | |
---|
1055 | { |
---|
1056 | aw_root->awar_int(AWAR_PROTEIN_TYPE, AWAR_PROTEIN_TYPE_bacterial_code_index, GLOBAL_gb_main); |
---|
1057 | aws->at("table"); |
---|
1058 | aws->create_option_menu(AWAR_PROTEIN_TYPE); |
---|
1059 | for (int code_nr=0; code_nr<AWT_CODON_TABLES; code_nr++) { |
---|
1060 | aws->insert_option(AWT_get_codon_code_name(code_nr), "", code_nr); |
---|
1061 | } |
---|
1062 | aws->update_option_menu(); |
---|
1063 | |
---|
1064 | aws->at("all"); |
---|
1065 | aws->create_toggle(AWAR_PV_DISPLAY_ALL); |
---|
1066 | |
---|
1067 | aws->at("f1"); |
---|
1068 | aws->create_toggle(AWAR_PROTVIEW_FORWARD_STRAND_1); |
---|
1069 | |
---|
1070 | aws->at("f2"); |
---|
1071 | aws->create_toggle(AWAR_PROTVIEW_FORWARD_STRAND_2); |
---|
1072 | |
---|
1073 | aws->at("f3"); |
---|
1074 | aws->create_toggle(AWAR_PROTVIEW_FORWARD_STRAND_3); |
---|
1075 | |
---|
1076 | aws->at("c1"); |
---|
1077 | aws->create_toggle(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_1); |
---|
1078 | |
---|
1079 | aws->at("c2"); |
---|
1080 | aws->create_toggle(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_2); |
---|
1081 | |
---|
1082 | aws->at("c3"); |
---|
1083 | aws->create_toggle(AWAR_PROTVIEW_COMPLEMENTARY_STRAND_3); |
---|
1084 | |
---|
1085 | aws->at("defined"); |
---|
1086 | aws->create_toggle(AWAR_PROTVIEW_DEFINED_FIELDS); |
---|
1087 | |
---|
1088 | aws->at("dispOption"); |
---|
1089 | aws->create_toggle_field(AWAR_PROTVIEW_DISPLAY_OPTIONS,0); |
---|
1090 | aws->insert_toggle("Single Letter Code", "S", 0); |
---|
1091 | aws->insert_toggle("Triple Letter Code", "T", 1); |
---|
1092 | aws->insert_toggle("Colored Box", "B", 2); |
---|
1093 | aws->update_toggle_field(); |
---|
1094 | |
---|
1095 | aws->at("colMaps"); |
---|
1096 | aws->callback(AW_POPUP,(AW_CL)create_seq_colors_window, (AW_CL)ED4_ROOT->sequence_colors); |
---|
1097 | aws->button_length(0); |
---|
1098 | aws->create_button("COLORMAPS","#colorMaps.xpm"); |
---|
1099 | |
---|
1100 | aws->at("colors"); |
---|
1101 | aws->callback(AW_POPUP,(AW_CL)AW_create_gc_window, (AW_CL)ED4_ROOT->aw_gc_manager); |
---|
1102 | aws->button_length(0); |
---|
1103 | aws->create_button("COLORS","#colors.xpm"); |
---|
1104 | |
---|
1105 | { |
---|
1106 | aws->at("sel"); aws->create_toggle(AWAR_PV_SELECTED); |
---|
1107 | aws->at("sf1"); aws->create_toggle(AWAR_PV_SELECTED_FS_1); |
---|
1108 | aws->at("sf2"); aws->create_toggle(AWAR_PV_SELECTED_FS_2); |
---|
1109 | aws->at("sf3"); aws->create_toggle(AWAR_PV_SELECTED_FS_3); |
---|
1110 | aws->at("sc1"); aws->create_toggle(AWAR_PV_SELECTED_CS_1); |
---|
1111 | aws->at("sc2"); aws->create_toggle(AWAR_PV_SELECTED_CS_2); |
---|
1112 | aws->at("sc3"); aws->create_toggle(AWAR_PV_SELECTED_CS_3); |
---|
1113 | aws->at("sdb"); aws->create_toggle(AWAR_PV_SELECTED_DB); |
---|
1114 | |
---|
1115 | aws->at("mrk"); aws->create_toggle(AWAR_PV_MARKED); |
---|
1116 | aws->at("mf1"); aws->create_toggle(AWAR_PV_MARKED_FS_1); |
---|
1117 | aws->at("mf2"); aws->create_toggle(AWAR_PV_MARKED_FS_2); |
---|
1118 | aws->at("mf3"); aws->create_toggle(AWAR_PV_MARKED_FS_3); |
---|
1119 | aws->at("mc1"); aws->create_toggle(AWAR_PV_MARKED_CS_1); |
---|
1120 | aws->at("mc2"); aws->create_toggle(AWAR_PV_MARKED_CS_2); |
---|
1121 | aws->at("mc3"); aws->create_toggle(AWAR_PV_MARKED_CS_3); |
---|
1122 | aws->at("mdb"); aws->create_toggle(AWAR_PV_MARKED_DB); |
---|
1123 | |
---|
1124 | aws->at("cur"); aws->create_toggle(AWAR_PV_CURSOR); |
---|
1125 | aws->at("cf1"); aws->create_toggle(AWAR_PV_CURSOR_FS_1); |
---|
1126 | aws->at("cf2"); aws->create_toggle(AWAR_PV_CURSOR_FS_2); |
---|
1127 | aws->at("cf3"); aws->create_toggle(AWAR_PV_CURSOR_FS_3); |
---|
1128 | aws->at("cc1"); aws->create_toggle(AWAR_PV_CURSOR_CS_1); |
---|
1129 | aws->at("cc2"); aws->create_toggle(AWAR_PV_CURSOR_CS_2); |
---|
1130 | aws->at("cc3"); aws->create_toggle(AWAR_PV_CURSOR_CS_3); |
---|
1131 | aws->at("cdb"); aws->create_toggle(AWAR_PV_CURSOR_DB); |
---|
1132 | } |
---|
1133 | |
---|
1134 | aws->at("save"); |
---|
1135 | aws->callback(PV_SaveData); |
---|
1136 | aws->button_length(5); |
---|
1137 | aws->create_button("SAVE","#save.xpm"); |
---|
1138 | } |
---|
1139 | |
---|
1140 | // binding callback function to the AWARS |
---|
1141 | PV_AddCallBacks(aw_root); |
---|
1142 | |
---|
1143 | // Create All Terminals |
---|
1144 | PV_CreateAllTerminals(aw_root); |
---|
1145 | |
---|
1146 | aws->show(); |
---|
1147 | |
---|
1148 | return (AW_window *)aws; |
---|
1149 | } |
---|
1150 | |
---|
1151 | #undef BUFFERSIZE |
---|