1 | #include <stdio.h> |
---|
2 | #include <stdlib.h> |
---|
3 | #include <arbdb.h> |
---|
4 | #include <arbdbt.h> |
---|
5 | #include <aw_root.hxx> |
---|
6 | #include <aw_window.hxx> |
---|
7 | #include <aw_awars.hxx> |
---|
8 | #include <awt.hxx> |
---|
9 | #include <awt_tree.hxx> |
---|
10 | #include <awt_csp.hxx> |
---|
11 | #include <awt_item_sel_list.hxx> |
---|
12 | #include <awt_sel_boxes.hxx> |
---|
13 | #include "st_window.hxx" |
---|
14 | #include "st_ml.hxx" |
---|
15 | #include "st_quality.hxx" |
---|
16 | |
---|
17 | void st_ok_cb(AW_window *aww, ST_ML *st_ml) { |
---|
18 | AW_root *root = aww->get_root(); |
---|
19 | char *alignment_name = root->awar_string(AWAR_DEFAULT_ALIGNMENT, "-none-", st_ml->gb_main)->read_string(); |
---|
20 | char *tree_name = root->awar_string(AWAR_TREE, "tree_stat", st_ml->gb_main)->read_string(); |
---|
21 | int marked_only = root->awar_int(ST_ML_AWAR_CQ_MARKED_ONLY)->read_int(); |
---|
22 | |
---|
23 | GB_ERROR error = GB_push_transaction(st_ml->gb_main); |
---|
24 | if (!error) error = st_ml->init(tree_name, alignment_name, (char *) 0, marked_only, (char *) 0, st_ml->awt_csp); |
---|
25 | if (!error && st_ml->refresh_func) st_ml->refresh_func(st_ml->aw_window); |
---|
26 | |
---|
27 | error = GB_end_transaction(st_ml->gb_main, error); |
---|
28 | aww->hide_or_notify(error); |
---|
29 | |
---|
30 | free(tree_name); |
---|
31 | free(alignment_name); |
---|
32 | } |
---|
33 | |
---|
34 | AW_window *st_create_main_window(AW_root * root, ST_ML * st_ml, AW_CB0 refresh_func, AW_window * win) { |
---|
35 | AW_window_simple *aws = new AW_window_simple; |
---|
36 | aws->init(root, "ENABLE_ONLINE_STATISTIC", "ACTIVATE ONLINE STATISTIC"); |
---|
37 | |
---|
38 | aws->load_xfig("stat_main.fig"); |
---|
39 | |
---|
40 | aws->callback(AW_POPDOWN); |
---|
41 | aws->at("close"); |
---|
42 | aws->create_button("CLOSE", "CLOSE", "C"); |
---|
43 | |
---|
44 | aws->callback(AW_POPUP_HELP, (AW_CL) "st_ml.hlp"); |
---|
45 | aws->at("help"); |
---|
46 | aws->create_button("HELP", "HELP", "H"); |
---|
47 | |
---|
48 | root->awar_string(ST_ML_AWAR_CSP, ""); |
---|
49 | root->awar_int(ST_ML_AWAR_CQ_MARKED_ONLY, 1); |
---|
50 | |
---|
51 | root->awar_string(AWAR_DEFAULT_ALIGNMENT, "-none-", st_ml->gb_main); |
---|
52 | root->awar_string(AWAR_TREE, "tree_main", st_ml->gb_main); |
---|
53 | |
---|
54 | root->awar_string(ST_ML_AWAR_ALIGNMENT)->map(AWAR_DEFAULT_ALIGNMENT); |
---|
55 | st_ml->awt_csp = new AWT_csp(st_ml->gb_main, root, ST_ML_AWAR_CSP); |
---|
56 | st_ml->refresh_func = refresh_func; |
---|
57 | st_ml->aw_window = win; |
---|
58 | |
---|
59 | aws->at("GO"); |
---|
60 | aws->callback((AW_CB1) st_ok_cb, (AW_CL) st_ml); |
---|
61 | aws->create_button("GO", "GO", "G"); |
---|
62 | |
---|
63 | aws->at("awt_csp"); |
---|
64 | aws->callback(AW_POPUP, (AW_CL) create_csp_window, |
---|
65 | (AW_CL) st_ml->awt_csp); |
---|
66 | aws->button_length(20); |
---|
67 | aws->create_button("SELECT_CSP", ST_ML_AWAR_CSP); |
---|
68 | |
---|
69 | aws->at("marked"); |
---|
70 | aws->create_toggle_field(ST_ML_AWAR_CQ_MARKED_ONLY, "Calculate for ..", |
---|
71 | ""); |
---|
72 | aws->insert_toggle("All species", "A", 0); |
---|
73 | aws->insert_toggle("Marked species", "M", 1); |
---|
74 | aws->update_toggle_field(); |
---|
75 | |
---|
76 | return aws; |
---|
77 | } |
---|
78 | |
---|
79 | ST_ML *new_ST_ML(GBDATA * gb_main) { |
---|
80 | return new ST_ML(gb_main); |
---|
81 | } |
---|
82 | |
---|
83 | ST_ML_Color *st_ml_get_color_string(ST_ML * st_ml, char *species_name, |
---|
84 | AP_tree * node, int start_ali_pos, int end_ali_pos) { |
---|
85 | return st_ml->get_color_string(species_name, node, start_ali_pos, |
---|
86 | end_ali_pos); |
---|
87 | } |
---|
88 | |
---|
89 | int st_ml_update_ml_likelihood(ST_ML * st_ml, char *result[4], |
---|
90 | int *latest_update, char *species_name, AP_tree * node) { |
---|
91 | return st_ml->update_ml_likelihood(result, latest_update, species_name, |
---|
92 | node); |
---|
93 | } |
---|
94 | |
---|
95 | AP_tree *st_ml_convert_species_name_to_node(ST_ML * st_ml, |
---|
96 | const char *species_name) { |
---|
97 | AP_tree *node; |
---|
98 | if (!st_ml->hash_2_ap_tree) |
---|
99 | return 0; |
---|
100 | node = (AP_tree *) GBS_read_hash(st_ml->hash_2_ap_tree, species_name); |
---|
101 | return node; |
---|
102 | } |
---|
103 | |
---|
104 | int st_is_inited(ST_ML * st_ml) { |
---|
105 | return st_ml->is_inited; |
---|
106 | } |
---|
107 | |
---|
108 | void st_check_cb(AW_window * aww, GBDATA * gb_main, AWT_csp * awt_csp) { |
---|
109 | GB_begin_transaction(gb_main); |
---|
110 | AW_root *r = aww->get_root(); |
---|
111 | char *alignment_name = r->awar(ST_ML_AWAR_ALIGNMENT)->read_string(); |
---|
112 | int bucket_size = r->awar(ST_ML_AWAR_CQ_BUCKET_SIZE)->read_int(); |
---|
113 | char *tree_name = r->awar(AWAR_TREE)->read_string(); |
---|
114 | char *dest_field = r->awar(ST_ML_AWAR_CQ_DEST_FIELD)->read_string(); |
---|
115 | int marked_only = r->awar(ST_ML_AWAR_CQ_MARKED_ONLY)->read_int(); |
---|
116 | char *filter_string = r->awar(ST_ML_AWAR_CQ_FILTER_FILTER)->read_string(); |
---|
117 | st_report_enum report = (st_report_enum) r->awar(ST_ML_AWAR_CQ_REPORT)->read_int(); |
---|
118 | GB_ERROR error = st_ml_check_sequence_quality(gb_main, tree_name, |
---|
119 | alignment_name, awt_csp, bucket_size, marked_only, report, |
---|
120 | filter_string, dest_field); |
---|
121 | free(filter_string); |
---|
122 | free(dest_field); |
---|
123 | free(alignment_name); |
---|
124 | free(tree_name); |
---|
125 | if (error) { |
---|
126 | aw_message(error); |
---|
127 | GB_abort_transaction(gb_main); |
---|
128 | } else { |
---|
129 | GB_commit_transaction(gb_main); |
---|
130 | } |
---|
131 | } |
---|
132 | |
---|
133 | AW_window *st_create_quality_check_window(AW_root * root, GBDATA * gb_main) { |
---|
134 | static AW_window_simple *aws = 0; |
---|
135 | if (aws) |
---|
136 | return aws; |
---|
137 | static AWT_csp *awt_csp; |
---|
138 | aws = new AW_window_simple; |
---|
139 | aws->init(root, "SEQUENCE_QUALITY_CHECK", |
---|
140 | "CHECK QUALITY OF MARKED SEQUENCES"); |
---|
141 | |
---|
142 | aws->load_xfig("check_quality.fig"); |
---|
143 | // aws->load_xfig("stat_main.fig"); |
---|
144 | |
---|
145 | aws->callback(AW_POPDOWN); |
---|
146 | aws->at("close"); |
---|
147 | aws->create_button("CLOSE", "CLOSE", "C"); |
---|
148 | |
---|
149 | aws->callback(AW_POPUP_HELP, (AW_CL) "check_quality.hlp"); |
---|
150 | aws->at("help"); |
---|
151 | aws->create_button("HELP", "HELP", "H"); |
---|
152 | |
---|
153 | root->awar_string(ST_ML_AWAR_CSP, ""); |
---|
154 | root->awar_string(AWAR_DEFAULT_ALIGNMENT, "-none-", gb_main); |
---|
155 | root->awar_int(ST_ML_AWAR_CQ_BUCKET_SIZE, 300); |
---|
156 | root->awar_int(ST_ML_AWAR_CQ_MARKED_ONLY, 0); |
---|
157 | root->awar_string(AWAR_TREE, "tree_main", gb_main); |
---|
158 | root->awar_string(ST_ML_AWAR_CQ_DEST_FIELD, "tmp"); |
---|
159 | root->awar_int(ST_ML_AWAR_CQ_REPORT, 0); |
---|
160 | |
---|
161 | root->awar_string(ST_ML_AWAR_CQ_FILTER_NAME, "ECOLI"); |
---|
162 | root->awar_string(ST_ML_AWAR_CQ_FILTER_ALIGNMENT); |
---|
163 | root->awar_string(ST_ML_AWAR_CQ_FILTER_FILTER); |
---|
164 | |
---|
165 | root->awar_string(ST_ML_AWAR_ALIGNMENT)->map(AWAR_DEFAULT_ALIGNMENT); |
---|
166 | root->awar_string(ST_ML_AWAR_CQ_FILTER_ALIGNMENT)-> |
---|
167 | map(AWAR_DEFAULT_ALIGNMENT); |
---|
168 | |
---|
169 | awt_csp = new AWT_csp(gb_main, root, ST_ML_AWAR_CSP); |
---|
170 | //AW_CL filter_cl = |
---|
171 | awt_create_select_filter(root, gb_main, ST_ML_AWAR_CQ_FILTER_NAME); |
---|
172 | |
---|
173 | aws->at("which"); |
---|
174 | { |
---|
175 | aws->create_option_menu(ST_ML_AWAR_CQ_MARKED_ONLY); |
---|
176 | aws->insert_option("All in tree", "t", 0); |
---|
177 | aws->insert_option("Only marked and in tree", "m", 1); |
---|
178 | aws->update_option_menu(); |
---|
179 | } |
---|
180 | |
---|
181 | aws->at("report"); |
---|
182 | { |
---|
183 | aws->create_option_menu(ST_ML_AWAR_CQ_REPORT); |
---|
184 | aws->insert_option("No report", "N", 0); |
---|
185 | aws->insert_option("R. to temporary sequence", "t", 1); |
---|
186 | aws->insert_option("R. to sequence", "s", 2); |
---|
187 | aws->update_option_menu(); |
---|
188 | } |
---|
189 | |
---|
190 | aws->at("awt_csp"); |
---|
191 | aws->callback(AW_POPUP, (AW_CL) create_csp_window, (AW_CL) awt_csp); |
---|
192 | aws->create_button("SELECT_CSP", ST_ML_AWAR_CSP); |
---|
193 | |
---|
194 | aws->at("sb"); |
---|
195 | aws->create_input_field(ST_ML_AWAR_CQ_BUCKET_SIZE); |
---|
196 | |
---|
197 | awt_create_selection_list_on_scandb(gb_main, aws, |
---|
198 | ST_ML_AWAR_CQ_DEST_FIELD, |
---|
199 | 1 << GB_STRING, |
---|
200 | "dest", |
---|
201 | 0, |
---|
202 | &AWT_species_selector, |
---|
203 | 20, 10); |
---|
204 | |
---|
205 | aws->at("GO"); |
---|
206 | aws->callback((AW_CB) st_check_cb, (AW_CL) gb_main, (AW_CL) awt_csp); |
---|
207 | aws->create_button("GO", "GO", "G"); |
---|
208 | return aws; |
---|
209 | } |
---|