1 | #include <stdio.h> |
---|
2 | #include <stdlib.h> |
---|
3 | #include <memory.h> |
---|
4 | #include <malloc.h> |
---|
5 | #include <string.h> |
---|
6 | |
---|
7 | #include <aw_root.hxx> |
---|
8 | #include <aw_device.hxx> |
---|
9 | #include <aw_window.hxx> |
---|
10 | |
---|
11 | #include <arbdb.h> |
---|
12 | #include <arbdbt.h> |
---|
13 | #include <awt.hxx> |
---|
14 | extern GBDATA *gb_main; |
---|
15 | |
---|
16 | |
---|
17 | void alignment_vars_callback(AW_root *aw_root) |
---|
18 | { |
---|
19 | GB_push_transaction(gb_main); |
---|
20 | char *use = aw_root->awar("presets/use")->read_string(); |
---|
21 | GBDATA *ali_cont = GBT_get_alignment(gb_main,use); |
---|
22 | if (!ali_cont) { |
---|
23 | aw_root->awar("presets/alignment_name")->unmap(); |
---|
24 | aw_root->awar("presets/alignment_type")->unmap(); |
---|
25 | aw_root->awar("presets/alignment_len")->unmap(); |
---|
26 | aw_root->awar("presets/alignment_rem")->unmap(); |
---|
27 | aw_root->awar("presets/aligned")->unmap(); |
---|
28 | aw_root->awar("presets/security")->unmap(); |
---|
29 | }else{ |
---|
30 | |
---|
31 | GBDATA *ali_name = GB_search(ali_cont,"alignment_name", GB_STRING); |
---|
32 | GBDATA *ali_len = GB_search(ali_cont,"alignment_len", GB_INT); |
---|
33 | GBDATA *ali_aligned = GB_search(ali_cont,"aligned", GB_INT); |
---|
34 | GBDATA *ali_type = GB_search(ali_cont,"alignment_type", GB_STRING); |
---|
35 | GBDATA *ali_security = GB_search(ali_cont,"alignment_write_security",GB_INT); |
---|
36 | GBDATA *ali_rem = GB_search(ali_cont,"alignment_rem", GB_STRING); |
---|
37 | |
---|
38 | aw_root->awar("presets/alignment_name")->map((void*)ali_name); |
---|
39 | aw_root->awar("presets/alignment_type")->map((void*)ali_type); |
---|
40 | aw_root->awar("presets/alignment_len")->map((void*)ali_len); |
---|
41 | aw_root->awar("presets/alignment_rem")->map((void*)ali_rem); |
---|
42 | aw_root->awar("presets/aligned")->map((void*)ali_aligned); |
---|
43 | aw_root->awar("presets/security")->map((void*)ali_security); |
---|
44 | } |
---|
45 | GB_pop_transaction(gb_main); |
---|
46 | free(use); |
---|
47 | } |
---|
48 | |
---|
49 | void create_alignment_vars(AW_root *aw_root,AW_default aw_def) |
---|
50 | { |
---|
51 | aw_root->awar_string( "presets/use", "" , aw_def); |
---|
52 | GB_push_transaction(gb_main); |
---|
53 | GBDATA *use = GB_search(gb_main,"presets/use",GB_STRING); |
---|
54 | aw_root->awar("presets/use")->map( use); |
---|
55 | |
---|
56 | aw_root->awar_string( "presets/alignment_name", "" , aw_def) |
---|
57 | ->set_srt( GBT_ALI_AWAR_SRT); |
---|
58 | |
---|
59 | aw_root->awar_string( "presets/alignment_dest", "" , aw_def) |
---|
60 | ->set_srt( GBT_ALI_AWAR_SRT); |
---|
61 | aw_root->awar_string( "presets/alignment_type", "" , aw_def); |
---|
62 | aw_root->awar_string( "presets/alignment_rem" ); |
---|
63 | aw_root->awar_int( "presets/alignment_len", 0 , aw_def); |
---|
64 | aw_root->awar_int( "presets/aligned", 0 , aw_def); |
---|
65 | aw_root->awar_int( "presets/security", 0 , aw_def); |
---|
66 | |
---|
67 | aw_root->awar("presets/use")->add_callback( alignment_vars_callback); |
---|
68 | alignment_vars_callback(aw_root); |
---|
69 | GB_pop_transaction(gb_main); |
---|
70 | } |
---|
71 | |
---|
72 | void ad_al_delete_cb(AW_window *aww) |
---|
73 | { |
---|
74 | if (aw_message("Are you sure to delete all data belonging to this alignment","OK,CANCEL"))return; |
---|
75 | |
---|
76 | GB_ERROR error = 0; |
---|
77 | char *source = aww->get_root()->awar("presets/use")->read_string(); |
---|
78 | |
---|
79 | GB_begin_transaction(gb_main); |
---|
80 | |
---|
81 | error = GBT_rename_alignment(gb_main,source,0,0,1); |
---|
82 | |
---|
83 | if (!error) GB_commit_transaction(gb_main); |
---|
84 | else GB_abort_transaction(gb_main); |
---|
85 | |
---|
86 | if (error) aw_message(error); |
---|
87 | delete source; |
---|
88 | } |
---|
89 | |
---|
90 | |
---|
91 | void ed_al_check_len_cb(AW_window *aww) |
---|
92 | { |
---|
93 | char *error = 0; |
---|
94 | char *use = aww->get_root()->awar("presets/use")->read_string(); |
---|
95 | GB_begin_transaction(gb_main); |
---|
96 | if (!error) error = (char *)GBT_check_data(gb_main,use); |
---|
97 | GB_commit_transaction(gb_main); |
---|
98 | if (error) aw_message(error); |
---|
99 | delete use; |
---|
100 | } |
---|
101 | void ed_al_export_sec_cb(AW_window *aww) |
---|
102 | { |
---|
103 | aw_message("This Function is not implemented,\nPlease press 'CHECK' to do this"); |
---|
104 | AWUSE(aww); |
---|
105 | } |
---|
106 | void ed_al_align_cb(AW_window *aww) |
---|
107 | { |
---|
108 | char *error = 0; |
---|
109 | char *use = aww->get_root()->awar("presets/use")->read_string(); |
---|
110 | GB_begin_transaction(gb_main); |
---|
111 | if (!error) error = (char *)GBT_check_data(gb_main,use); |
---|
112 | if (!error) error = (char *)GBT_check_lengths(gb_main,use); |
---|
113 | if (!error) error = (char *)GBT_check_data(gb_main,use); |
---|
114 | GB_commit_transaction(gb_main); |
---|
115 | if (error) aw_message(error); |
---|
116 | delete use; |
---|
117 | } |
---|
118 | |
---|
119 | void aa_copy_delete_rename(AW_window *aww,AW_CL copy, AW_CL dele) |
---|
120 | { |
---|
121 | GB_ERROR error = 0; |
---|
122 | char *source = aww->get_root()->awar("presets/use")->read_string(); |
---|
123 | char *dest = aww->get_root()->awar("presets/alignment_dest")->read_string(); |
---|
124 | |
---|
125 | GB_begin_transaction(gb_main); |
---|
126 | |
---|
127 | error = GBT_rename_alignment(gb_main,source,dest,(int)copy,(int)dele); |
---|
128 | |
---|
129 | if (!error){ |
---|
130 | char *nfield = strdup(GBS_global_string("%s/data",dest)); |
---|
131 | awt_add_new_changekey( gb_main,nfield,GB_STRING); |
---|
132 | delete nfield; |
---|
133 | GB_commit_transaction(gb_main); |
---|
134 | }else{ |
---|
135 | GB_abort_transaction(gb_main); |
---|
136 | } |
---|
137 | if (error) aw_message(error); |
---|
138 | delete source; |
---|
139 | delete dest; |
---|
140 | aww->hide(); |
---|
141 | } |
---|
142 | |
---|
143 | AW_window *create_alignment_copy_window(AW_root *root) |
---|
144 | { |
---|
145 | AW_window_simple *aws = new AW_window_simple; |
---|
146 | aws->init( root, "COPY_ALIGNMENT", "ALIGNMENT COPY", 100, 100 ); |
---|
147 | aws->load_xfig("ad_al_si.fig"); |
---|
148 | |
---|
149 | aws->callback( (AW_CB0)AW_POPDOWN); |
---|
150 | aws->at("close"); |
---|
151 | aws->create_button("CLOSE","CLOSE","C"); |
---|
152 | |
---|
153 | aws->at("label"); |
---|
154 | aws->create_button(0,"Please enter the new name\nof the alignment"); |
---|
155 | |
---|
156 | aws->at("input"); |
---|
157 | aws->create_input_field("presets/alignment_dest",15); |
---|
158 | |
---|
159 | aws->at("ok"); |
---|
160 | aws->callback(aa_copy_delete_rename,1,0); |
---|
161 | aws->create_button("GO","GO","G"); |
---|
162 | |
---|
163 | return (AW_window *)aws; |
---|
164 | } |
---|
165 | AW_window *create_alignment_rename_window(AW_root *root) |
---|
166 | { |
---|
167 | AW_window_simple *aws = new AW_window_simple; |
---|
168 | aws->init( root, "RENAME_ALIGNMENT", "ALIGNMENT RENAME", 100, 100 ); |
---|
169 | aws->load_xfig("ad_al_si.fig"); |
---|
170 | |
---|
171 | aws->callback( (AW_CB0)AW_POPDOWN); |
---|
172 | aws->at("close"); |
---|
173 | aws->create_button("CLOSE","CLOSE","C"); |
---|
174 | |
---|
175 | aws->at("label"); |
---|
176 | aws->create_button(0,"Please enter the name\nof the new alignment"); |
---|
177 | |
---|
178 | aws->at("input"); |
---|
179 | aws->create_input_field("presets/alignment_dest",15); |
---|
180 | |
---|
181 | aws->at("ok"); |
---|
182 | aws->callback(aa_copy_delete_rename,1,1); |
---|
183 | aws->create_button("GO","GO","G"); |
---|
184 | |
---|
185 | return (AW_window *)aws; |
---|
186 | } |
---|
187 | |
---|
188 | void aa_create_alignment(AW_window *aww) |
---|
189 | { |
---|
190 | GB_ERROR error = 0; |
---|
191 | GBDATA *gb_alignment; |
---|
192 | char *name = aww->get_root()->awar("presets/alignment_dest")->read_string(); |
---|
193 | GB_begin_transaction(gb_main); |
---|
194 | |
---|
195 | gb_alignment = GBT_create_alignment(gb_main,name,0,0,0,"dna"); |
---|
196 | if (!gb_alignment) error = GB_get_error(); |
---|
197 | |
---|
198 | if (!error){ |
---|
199 | char *nfield = strdup(GBS_global_string("%s/data",name)); |
---|
200 | awt_add_new_changekey( gb_main,nfield,GB_STRING); |
---|
201 | delete nfield; |
---|
202 | GB_commit_transaction(gb_main); |
---|
203 | }else{ |
---|
204 | GB_abort_transaction(gb_main); |
---|
205 | } |
---|
206 | if (error) aw_message(error); |
---|
207 | delete name; |
---|
208 | } |
---|
209 | |
---|
210 | AW_window *create_alignment_create_window(AW_root *root) |
---|
211 | { |
---|
212 | AW_window_simple *aws = new AW_window_simple; |
---|
213 | aws->init( root, "CREATE_ALIGNMENT", "ALIGNMENT CREATE", 100, 100 ); |
---|
214 | aws->load_xfig("ad_al_si.fig"); |
---|
215 | |
---|
216 | aws->callback( (AW_CB0)AW_POPDOWN); |
---|
217 | aws->at("close"); |
---|
218 | aws->create_button("CLOSE","CLOSE","C"); |
---|
219 | |
---|
220 | aws->at("label"); |
---|
221 | aws->create_button(0,"Please enter the new name\nof the alignment"); |
---|
222 | |
---|
223 | aws->at("input"); |
---|
224 | aws->create_input_field("presets/alignment_dest",15); |
---|
225 | |
---|
226 | aws->at("ok"); |
---|
227 | aws->callback(aa_create_alignment); |
---|
228 | aws->create_button("GO","GO","G"); |
---|
229 | |
---|
230 | return (AW_window *)aws; |
---|
231 | } |
---|
232 | |
---|
233 | AW_window *create_alignment_window(AW_root *root,AW_default aw_def) |
---|
234 | { |
---|
235 | AWUSE(aw_def); |
---|
236 | AW_window_simple *aws = new AW_window_simple; |
---|
237 | aws->init( root, "INFO_OF_ALIGNMENT", "ALIGNMENT INFORMATION", 100, 0 ); |
---|
238 | aws->load_xfig("ad_align.fig"); |
---|
239 | |
---|
240 | aws->callback( (AW_CB0)AW_POPDOWN); |
---|
241 | aws->at("close"); |
---|
242 | aws->create_button("CLOSE","CLOSE","C"); |
---|
243 | |
---|
244 | aws->callback( AW_POPUP_HELP,(AW_CL)"ad_align.hlp"); |
---|
245 | aws->at("help"); |
---|
246 | aws->create_button("HELP","HELP","H"); |
---|
247 | |
---|
248 | aws->button_length(13); |
---|
249 | |
---|
250 | aws->at("delete"); |
---|
251 | aws->callback(ad_al_delete_cb); |
---|
252 | aws->create_button("DELETE","DELETE","D"); |
---|
253 | |
---|
254 | aws->at("rename"); |
---|
255 | aws->callback(AW_POPUP,(AW_CL)create_alignment_rename_window,0); |
---|
256 | aws->create_button("RENAME","RENAME","R"); |
---|
257 | |
---|
258 | aws->at("create"); |
---|
259 | aws->callback(AW_POPUP,(AW_CL)create_alignment_create_window,0); |
---|
260 | aws->create_button("CREATE","CREATE","N"); |
---|
261 | |
---|
262 | aws->at("copy"); |
---|
263 | aws->callback(AW_POPUP,(AW_CL)create_alignment_copy_window,0); |
---|
264 | aws->create_button("COPY","COPY","C"); |
---|
265 | |
---|
266 | aws->at("check_len"); |
---|
267 | aws->callback(ed_al_check_len_cb); |
---|
268 | aws->create_button("CHECK_LEN","CHECK LEN","L"); |
---|
269 | |
---|
270 | aws->at("align"); |
---|
271 | aws->callback(ed_al_align_cb); |
---|
272 | aws->create_button("FORMAT","FORMAT","F"); |
---|
273 | |
---|
274 | aws->at("list"); |
---|
275 | awt_create_selection_list_on_ad(gb_main,(AW_window *)aws,"presets/use","*="); |
---|
276 | |
---|
277 | aws->at("aligned"); |
---|
278 | aws->create_option_menu("presets/aligned"); |
---|
279 | aws->callback(ed_al_check_len_cb); |
---|
280 | aws->insert_default_option("not formatted","n",0); |
---|
281 | aws->callback(ed_al_align_cb); |
---|
282 | aws->insert_option("formatted","j",1); |
---|
283 | aws->update_option_menu(); |
---|
284 | |
---|
285 | aws->at("len"); |
---|
286 | aws->create_input_field("presets/alignment_len",5); |
---|
287 | |
---|
288 | aws->at("type"); |
---|
289 | aws->create_option_menu("presets/alignment_type"); |
---|
290 | aws->insert_option("dna","d","dna"); |
---|
291 | aws->insert_option("rna","r","rna"); |
---|
292 | aws->insert_option("pro","p","ami"); |
---|
293 | aws->insert_default_option("???","?","usr"); |
---|
294 | aws->update_option_menu(); |
---|
295 | |
---|
296 | aws->at("security"); |
---|
297 | aws->create_option_menu("presets/security"); |
---|
298 | aws->callback(ed_al_check_len_cb); |
---|
299 | aws->insert_option("0","0",0); |
---|
300 | aws->callback(ed_al_check_len_cb); |
---|
301 | aws->insert_option("1","1",1); |
---|
302 | aws->callback(ed_al_check_len_cb); |
---|
303 | aws->insert_option("2","2",2); |
---|
304 | aws->callback(ed_al_check_len_cb); |
---|
305 | aws->insert_option("3","3",3); |
---|
306 | aws->callback(ed_al_check_len_cb); |
---|
307 | aws->insert_option("4","4",4); |
---|
308 | aws->callback(ed_al_check_len_cb); |
---|
309 | aws->insert_option("5","5",5); |
---|
310 | aws->callback(ed_al_check_len_cb); |
---|
311 | aws->insert_default_option("6","6",6); |
---|
312 | aws->update_option_menu(); |
---|
313 | |
---|
314 | aws->at("rem"); |
---|
315 | aws->create_text_field("presets/alignment_rem"); |
---|
316 | |
---|
317 | |
---|
318 | return (AW_window *)aws; |
---|
319 | } |
---|