1 | // =============================================================== // |
---|
2 | // // |
---|
3 | // File : ED4_naligner.cxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Institute of Microbiology (Technical University Munich) // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // =============================================================== // |
---|
10 | |
---|
11 | #include "ed4_naligner.hxx" |
---|
12 | |
---|
13 | #include <aw_window.hxx> |
---|
14 | #include <aw_awars.hxx> |
---|
15 | #include <aw_root.hxx> |
---|
16 | #include <awt_sel_boxes.hxx> |
---|
17 | #include <arbdbt.h> |
---|
18 | #include <arb_strbuf.h> |
---|
19 | |
---|
20 | #include <iostream> |
---|
21 | |
---|
22 | static void aed_start_naligning(AW_window *aw, GBDATA *gb_main) { |
---|
23 | AW_root *root = aw->get_root(); |
---|
24 | char *buffer; |
---|
25 | int i, j; |
---|
26 | |
---|
27 | // @@@ use GB_xcmd (do not fiddle with LD_LIBRARY_PATH here) |
---|
28 | GBS_strstruct *strstruct = GBS_stropen(1000); |
---|
29 | GBS_strcat(strstruct, "xterm -sl 1000 -sb -e sh -c 'LD_LIBRARY_PATH=\""); |
---|
30 | GBS_strcat(strstruct, GB_getenv("LD_LIBRARY_PATH")); |
---|
31 | GBS_strcat(strstruct, "\";export LD_LIBRARY_PATH;for i in "); |
---|
32 | if (root->awar("naligner/what")->read_int()) { |
---|
33 | GB_transaction ta(gb_main); |
---|
34 | |
---|
35 | for (GBDATA *gb_species = GBT_first_marked_species(gb_main); |
---|
36 | gb_species; |
---|
37 | gb_species = GBT_next_marked_species(gb_species)) |
---|
38 | { |
---|
39 | GBS_chrcat(strstruct, '\"'); |
---|
40 | GBS_strcat(strstruct, GBT_get_name_or_description(gb_species)); |
---|
41 | GBS_strcat(strstruct, "\" "); |
---|
42 | } |
---|
43 | } |
---|
44 | else { |
---|
45 | char *species_name = root->awar(AWAR_SPECIES_NAME)->read_string(); |
---|
46 | GBS_strcat(strstruct, "\""); |
---|
47 | GBS_strcat(strstruct, species_name); |
---|
48 | GBS_strcat(strstruct, "\" "); |
---|
49 | delete species_name; |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | GBS_strcat(strstruct, "; do arb_naligner"); |
---|
54 | |
---|
55 | |
---|
56 | if (root->awar("naligner/against")->read_int()) { |
---|
57 | GBS_strcat(strstruct, " -PARB_PT_SERVER"); |
---|
58 | GBS_intcat(strstruct, root->awar("naligner/pt_server")->read_int()); |
---|
59 | } |
---|
60 | else { |
---|
61 | GBS_strcat(strstruct, " \"-f"); |
---|
62 | char *family = root->awar("naligner/sagainst")->read_string(); |
---|
63 | GBS_strcat(strstruct, family); |
---|
64 | delete family; |
---|
65 | GBS_strcat(strstruct, "\""); |
---|
66 | } |
---|
67 | GBS_strcat(strstruct, " \"-s$i\" "); |
---|
68 | |
---|
69 | if (root->awar("naligner/mark_profile")->read_int()) GBS_strcat(strstruct, " -mf"); |
---|
70 | if (root->awar("naligner/unmark_sequence")->read_int()) GBS_strcat(strstruct, " -us"); |
---|
71 | |
---|
72 | GBS_strcat(strstruct, " -minf"); GBS_intcat(strstruct, root->awar("naligner/minf")->read_int()); |
---|
73 | GBS_strcat(strstruct, " -maxf"); GBS_intcat(strstruct, root->awar("naligner/maxf")->read_int()); |
---|
74 | GBS_strcat(strstruct, " -minw"); GBS_floatcat(strstruct, root->awar("naligner/minw")->read_float()); |
---|
75 | GBS_strcat(strstruct, " -maxew"); GBS_floatcat(strstruct, root->awar("naligner/maxew")->read_float()); |
---|
76 | GBS_strcat(strstruct, " -ib"); GBS_intcat(strstruct, root->awar("naligner/det/ib")->read_int()); |
---|
77 | GBS_strcat(strstruct, " -ic"); GBS_intcat(strstruct, root->awar("naligner/det/ic")->read_int()); |
---|
78 | |
---|
79 | GBS_strcat(strstruct, " -cl"); GBS_floatcat(strstruct, root->awar("naligner/det/cl")->read_float()); |
---|
80 | |
---|
81 | |
---|
82 | |
---|
83 | |
---|
84 | GBS_strcat(strstruct, " -cm"); GBS_floatcat(strstruct, root->awar("naligner/det/cm")->read_float()); |
---|
85 | GBS_strcat(strstruct, " -ch"); GBS_floatcat(strstruct, root->awar("naligner/det/ch")->read_float()); |
---|
86 | GBS_strcat(strstruct, " -mgf"); GBS_floatcat(strstruct, root->awar("naligner/igap_panelty")->read_float()); |
---|
87 | GBS_strcat(strstruct, " -mma1"); |
---|
88 | GBS_strcat(strstruct, " -msub"); |
---|
89 | for (i=0; i<5; i++) { |
---|
90 | for (j=0; j<5; j++) { |
---|
91 | if (i==4 || j==4) { // gap panelty |
---|
92 | if (i==4 && j==4) { |
---|
93 | GBS_floatcat(strstruct, 0.0); |
---|
94 | } |
---|
95 | else { |
---|
96 | GBS_floatcat(strstruct, root->awar("naligner/gap_panelty")->read_float()); |
---|
97 | GBS_chrcat(strstruct, ','); |
---|
98 | } |
---|
99 | } |
---|
100 | else { |
---|
101 | char var[100]; |
---|
102 | if (i<j) sprintf(var, "naligner/%c%c", "acgt-"[i], "acgt-"[j]); |
---|
103 | else sprintf(var, "naligner/%c%c", "acgt-"[j], "acgt-"[i]); |
---|
104 | GBS_floatcat(strstruct, root->awar(var)->read_float()); |
---|
105 | if (i<4 || j<4) GBS_chrcat(strstruct, ','); |
---|
106 | } |
---|
107 | } |
---|
108 | } |
---|
109 | GBS_strcat(strstruct, " || echo \"Aligner failed\";done;"); |
---|
110 | |
---|
111 | |
---|
112 | GBS_strcat(strstruct, "echo press \"(return)\" to close window;read a' &"); |
---|
113 | buffer = GBS_strclose(strstruct); |
---|
114 | GB_ERROR error = GBK_system(buffer); |
---|
115 | if (error) fputs(error, stderr); |
---|
116 | free(buffer); |
---|
117 | } |
---|
118 | |
---|
119 | |
---|
120 | void create_naligner_variables(AW_root *root, AW_default db1) { |
---|
121 | root->awar_int("naligner/what", 0, db1); |
---|
122 | |
---|
123 | root->awar_int ("naligner/against", 0, db1); |
---|
124 | root->awar_string("naligner/sagainst", "", db1); |
---|
125 | root->awar_int ("naligner/pt_server", -1, db1); |
---|
126 | |
---|
127 | root->awar_int("naligner/mark_profile", 1, db1); |
---|
128 | root->awar_int("naligner/unmark_sequence", 0, db1); |
---|
129 | |
---|
130 | root->awar_float("naligner/aa", 0.0, db1); |
---|
131 | root->awar_float("naligner/ac", 3.0, db1); |
---|
132 | root->awar_float("naligner/ag", 1.0, db1); |
---|
133 | root->awar_float("naligner/at", 3.0, db1); |
---|
134 | root->awar_float("naligner/cc", 0.0, db1); |
---|
135 | root->awar_float("naligner/cg", 3.0, db1); |
---|
136 | root->awar_float("naligner/ct", 1.0, db1); |
---|
137 | root->awar_float("naligner/gg", 0.0, db1); |
---|
138 | root->awar_float("naligner/gt", 3.0, db1); |
---|
139 | root->awar_float("naligner/tt", 0.0, db1); |
---|
140 | root->awar_float("naligner/gap_panelty", 5.0, db1); |
---|
141 | root->awar_float("naligner/igap_panelty", 0.2, db1); |
---|
142 | root->awar_int ("naligner/minf", 3, db1); |
---|
143 | root->awar_int ("naligner/maxf", 30, db1); |
---|
144 | |
---|
145 | root->awar_float("naligner/minw", .7, db1); |
---|
146 | root->awar_float("naligner/maxew", .2, db1); |
---|
147 | |
---|
148 | root->awar_float("naligner/det/cl", .25, db1); |
---|
149 | root->awar_float("naligner/det/cm", .5, db1); |
---|
150 | root->awar_float("naligner/det/ch", .8, db1); |
---|
151 | root->awar_int ("naligner/det/ib", 5, db1); |
---|
152 | root->awar_int ("naligner/det/ic", 5, db1); |
---|
153 | } |
---|
154 | |
---|
155 | static AW_window *create_expert_naligner_window(AW_root *root) { |
---|
156 | const int mwidth = 5; |
---|
157 | AW_window_simple *aws = new AW_window_simple; |
---|
158 | aws->init(root, "ALIGNER_V2_EXPERT2", "ALIGNER V2.0 EXPERT 2"); |
---|
159 | aws->load_xfig("ed_al_ex.fig"); |
---|
160 | |
---|
161 | aws->at("close"); |
---|
162 | aws->callback(AW_POPDOWN); |
---|
163 | aws->create_button("CLOSE", "CLOSE", "C"); |
---|
164 | |
---|
165 | aws->at("minw"); aws->create_input_field("naligner/minw", mwidth); |
---|
166 | aws->at("maxew"); aws->create_input_field("naligner/maxew", mwidth); |
---|
167 | |
---|
168 | aws->at("ib"); aws->create_input_field("naligner/det/ib", mwidth); |
---|
169 | aws->at("ic"); aws->create_input_field("naligner/det/ic", mwidth); |
---|
170 | aws->at("cl"); aws->create_input_field("naligner/det/cl", mwidth); |
---|
171 | aws->at("cm"); aws->create_input_field("naligner/det/cm", mwidth); |
---|
172 | aws->at("ch"); aws->create_input_field("naligner/det/ch", mwidth); |
---|
173 | |
---|
174 | return aws; |
---|
175 | } |
---|
176 | |
---|
177 | static AW_window *create_special_naligner_window(AW_root *root) { |
---|
178 | AW_window_simple *aws = new AW_window_simple; |
---|
179 | const int mwidth = 3; |
---|
180 | |
---|
181 | aws->init(root, "ALIGNER_V2_EXPERT", "ALIGNER V2.0 EXPERT"); |
---|
182 | aws->load_xfig("ed_al_sp.fig"); |
---|
183 | |
---|
184 | aws->label_length(22); |
---|
185 | |
---|
186 | aws->at("close"); |
---|
187 | aws->callback(AW_POPDOWN); |
---|
188 | aws->create_button("CLOSE", "CLOSE", "C"); |
---|
189 | |
---|
190 | aws->at("minr"); aws->create_input_field("naligner/minf", 6); |
---|
191 | aws->at("maxr"); aws->create_input_field("naligner/maxf", 6); |
---|
192 | |
---|
193 | aws->at("aa"); aws->create_input_field("naligner/aa", mwidth); |
---|
194 | aws->at("ac"); aws->create_input_field("naligner/ac", mwidth); |
---|
195 | aws->at("ag"); aws->create_input_field("naligner/ag", mwidth); |
---|
196 | aws->at("at"); aws->create_input_field("naligner/at", mwidth); |
---|
197 | |
---|
198 | aws->at("ca"); aws->create_input_field("naligner/ac", mwidth); |
---|
199 | aws->at("cc"); aws->create_input_field("naligner/cc", mwidth); |
---|
200 | aws->at("cg"); aws->create_input_field("naligner/cg", mwidth); |
---|
201 | aws->at("ct"); aws->create_input_field("naligner/ct", mwidth); |
---|
202 | |
---|
203 | aws->at("ga"); aws->create_input_field("naligner/ag", mwidth); |
---|
204 | aws->at("gc"); aws->create_input_field("naligner/cg", mwidth); |
---|
205 | aws->at("gg"); aws->create_input_field("naligner/gg", mwidth); |
---|
206 | aws->at("gt"); aws->create_input_field("naligner/gt", mwidth); |
---|
207 | |
---|
208 | aws->at("ta"); aws->create_input_field("naligner/at", mwidth); |
---|
209 | aws->at("tc"); aws->create_input_field("naligner/ct", mwidth); |
---|
210 | aws->at("tg"); aws->create_input_field("naligner/gt", mwidth); |
---|
211 | aws->at("tt"); aws->create_input_field("naligner/tt", mwidth); |
---|
212 | |
---|
213 | aws->at("gap"); aws->create_input_field("naligner/gap_panelty", 4); |
---|
214 | aws->at("igap"); aws->create_input_field("naligner/igap_panelty", 4); |
---|
215 | |
---|
216 | aws->at("expert"); |
---|
217 | aws->callback(create_expert_naligner_window); |
---|
218 | aws->create_button("EXPERT_OPTIONS", "EXPERT2", "E"); |
---|
219 | |
---|
220 | return aws; |
---|
221 | } |
---|
222 | |
---|
223 | AW_window *create_naligner_window(AW_root *root, GBDATA *gb_main) { |
---|
224 | AW_window_simple *aws = new AW_window_simple; |
---|
225 | aws->init(root, "ALIGNER_V2", "ALIGNER V2.0"); |
---|
226 | aws->load_xfig("awt/align.fig"); |
---|
227 | |
---|
228 | aws->label_length(10); |
---|
229 | aws->button_length(10); |
---|
230 | |
---|
231 | aws->at("close"); |
---|
232 | aws->callback(AW_POPDOWN); |
---|
233 | aws->create_button("CLOSE", "CLOSE", "O"); |
---|
234 | |
---|
235 | aws->at("help"); |
---|
236 | aws->callback(makeHelpCallback("ne_align_seq.hlp")); |
---|
237 | aws->create_button("HELP", "HELP"); |
---|
238 | |
---|
239 | aws->at("align"); |
---|
240 | aws->callback(makeWindowCallback(aed_start_naligning, gb_main)); |
---|
241 | aws->highlight(); |
---|
242 | aws->create_button("GO", "GO", "G"); |
---|
243 | |
---|
244 | aws->at("expert"); |
---|
245 | aws->callback(create_special_naligner_window); |
---|
246 | aws->create_button("OPTIONS", "PARAMETERS", "E"); |
---|
247 | |
---|
248 | aws->at("what"); |
---|
249 | aws->create_toggle_field("naligner/what", "Align", "A"); |
---|
250 | aws->insert_toggle("Selected Species:", "S", 0); |
---|
251 | aws->insert_default_toggle("Marked Species", "M", 1); |
---|
252 | aws->update_toggle_field(); |
---|
253 | |
---|
254 | aws->at("swhat"); |
---|
255 | aws->create_input_field(AWAR_SPECIES_NAME, 2); |
---|
256 | |
---|
257 | aws->at("against"); |
---|
258 | aws->create_toggle_field("naligner/against", "Reference", "g"); |
---|
259 | aws->insert_toggle("Species by name", "S", 0); |
---|
260 | aws->insert_default_toggle("Auto search by pt_server", "S", 1); |
---|
261 | aws->update_toggle_field(); |
---|
262 | |
---|
263 | aws->at("sagainst"); |
---|
264 | aws->create_input_field("naligner/sagainst", 2); |
---|
265 | |
---|
266 | aws->label_length(25); |
---|
267 | |
---|
268 | aws->at("pt_server"); |
---|
269 | aws->label("PT_SERVER:"); |
---|
270 | awt_create_PTSERVER_selection_button(aws, "naligner/pt_server"); |
---|
271 | |
---|
272 | aws->at("mark"); |
---|
273 | aws->label_length(40); |
---|
274 | aws->label("Mark sequences found by the pt_server"); |
---|
275 | aws->create_toggle("naligner/mark_profile"); |
---|
276 | |
---|
277 | return aws; |
---|
278 | } |
---|