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