ARB
graph_aligner_gui.cxx
Go to the documentation of this file.
1 // =============================================================== //
2 // //
3 // File : graph_aligner_gui.cxx //
4 // Purpose : //
5 // //
6 // Coded by Elmar Pruesse in October 2008 //
7 // Institute of Microbiology (Technical University Munich) //
8 // http://www.arb-home.de/ //
9 // //
10 // =============================================================== //
11 
12 #include "graph_aligner_gui.hxx"
13 
14 #include "ed4_defs.hxx"
15 
16 // need to use AlignDataAccess defined here to get selected species
17 #include <fast_aligner.hxx>
18 
19 #include <aw_awars.hxx>
20 #include <aw_msg.hxx>
21 #include <aw_root.hxx>
22 #include <awt_sel_boxes.hxx>
23 #include <awt_config_manager.hxx>
24 #include <servercntrl.h>
25 #include <PT_com.h>
26 #include <client.h>
27 #include <arbdbt.h>
28 #include <arb_strbuf.h>
29 #include <arb_misc.h>
30 
31 #include <sys/types.h>
32 #include <sys/wait.h>
33 
34 #include <unistd.h>
35 
36 #include <string>
37 #include <sstream>
38 #include <iostream>
39 #include <vector>
40 
41 using std::cerr;
42 using std::cout;
43 using std::endl;
44 
45 #define GA_AWAR_ROOT "sina/"
46 
47 #define GA_AWAR_CMD GA_AWAR_ROOT "command"
48 #define GA_AWAR_TGT GA_AWAR_ROOT "target"
49 #define GA_AWAR_SAI GA_AWAR_ROOT "sai"
50 #define GA_AWAR_ALIGNMENT GA_AWAR_ROOT "alignment"
51 #define GA_AWAR_PROTECTION GA_AWAR_ROOT "protection"
52 #define GA_AWAR_TURN_CHECK GA_AWAR_ROOT "turncheck"
53 #define GA_AWAR_REALIGN GA_AWAR_ROOT "realign"
54 #define GA_AWAR_COPYMARKREF GA_AWAR_ROOT "copymarkref"
55 #define GA_AWAR_MATCH_SCORE GA_AWAR_ROOT "match_score"
56 #define GA_AWAR_MISMATCH_SCORE GA_AWAR_ROOT "mismatch_score"
57 #define GA_AWAR_GAP_PEN GA_AWAR_ROOT "gap_pen"
58 #define GA_AWAR_GAP_EXT GA_AWAR_ROOT "gap_ext"
59 #define GA_AWAR_ADVANCED GA_AWAR_ROOT "advanced"
60 #define GA_AWAR_FS_MIN GA_AWAR_ROOT "fs_min"
61 #define GA_AWAR_FS_MAX GA_AWAR_ROOT "fs_max"
62 #define GA_AWAR_FS_MSC GA_AWAR_ROOT "fs_msc"
63 #define GA_AWAR_MIN_FULL GA_AWAR_ROOT "min_full"
64 #define GA_AWAR_FULL_MINLEN GA_AWAR_ROOT "full_minlen"
65 #define GA_AWAR_OVERHANG GA_AWAR_ROOT "overhang"
66 #define GA_AWAR_THREADS GA_AWAR_ROOT "threads"
67 #define GA_AWAR_QSIZE GA_AWAR_ROOT "qsize"
68 #define GA_AWAR_KMER_LEN GA_AWAR_ROOT "kmer_len"
69 #define GA_AWAR_KMER_MM GA_AWAR_ROOT "kmer_mm"
70 #define GA_AWAR_MIN_LEN GA_AWAR_ROOT "min_len"
71 #define GA_AWAR_WEIGHT GA_AWAR_ROOT "weight"
72 #define GA_AWAR_INSERT GA_AWAR_ROOT "insert"
73 #define GA_AWAR_LOWERCASE GA_AWAR_ROOT "lowercase"
74 #define GA_AWAR_AUTOFILTER GA_AWAR_ROOT "autofilter"
75 #define GA_AWAR_KMER_NOREL GA_AWAR_ROOT "kmer_norel"
76 #define GA_AWAR_KMER_NOFAST GA_AWAR_ROOT "kmer_nofast"
77 #define GA_AWAR_SHOW_DIST GA_AWAR_ROOT "show_dist"
78 #define GA_AWAR_SHOW_DIFF GA_AWAR_ROOT "show_diff"
79 #define GA_AWAR_COLOR GA_AWAR_ROOT "color"
80 #define GA_AWAR_GENE_START GA_AWAR_ROOT "gene_start"
81 #define GA_AWAR_GENE_END GA_AWAR_ROOT "gene_end"
82 #define GA_AWAR_FS_COVER_GENE GA_AWAR_ROOT "fs_cover_gene"
83 
85  root->awar_string(GA_AWAR_CMD, "sina", db1);
86  root->awar_int (GA_AWAR_TGT, 2, db1);
87  root->awar_int (AWAR_PT_SERVER, 0, db1);
88  root->awar_string(GA_AWAR_SAI, "", db1);
89  root->awar_int (GA_AWAR_PROTECTION, 0, db1);
90  root->awar_int (GA_AWAR_TURN_CHECK, 1, db1);
91  root->awar_int (GA_AWAR_REALIGN, 1, db1);
92  root->awar_int (GA_AWAR_COPYMARKREF, 0, db1);
93  root->awar_float (GA_AWAR_GAP_PEN, 5.0, db1);
94  root->awar_float (GA_AWAR_GAP_EXT, 2.0, db1);
95  root->awar_float (GA_AWAR_MATCH_SCORE, 2.0, db1);
96  root->awar_float (GA_AWAR_MISMATCH_SCORE, -1.0, db1);
97  root->awar_int (GA_AWAR_ADVANCED, 0, db1);
98  root->awar_int (GA_AWAR_FS_MIN, 40, db1);
99  root->awar_int (GA_AWAR_FS_MAX, 40, db1);
100  root->awar_float (GA_AWAR_FS_MSC, .7, db1);
101  root->awar_int (GA_AWAR_MIN_FULL, 1, db1);
102  root->awar_int (GA_AWAR_FULL_MINLEN, 1400, db1);
103  root->awar_string(GA_AWAR_OVERHANG, "attach", db1);
104  root->awar_int (GA_AWAR_THREADS, 1, db1);
105  root->awar_int (GA_AWAR_QSIZE, 1, db1);
106  root->awar_int (GA_AWAR_KMER_LEN, 10, db1);
107  root->awar_int (GA_AWAR_KMER_MM, 0, db1);
108  root->awar_int (GA_AWAR_MIN_LEN, 150, db1);
109  root->awar_float (GA_AWAR_WEIGHT, 1, db1);
110  root->awar_string(GA_AWAR_INSERT, "shift", db1);
111  root->awar_string(GA_AWAR_LOWERCASE, "none", db1);
112  root->awar_string(GA_AWAR_AUTOFILTER, "none", db1);
113  root->awar_int (GA_AWAR_KMER_NOREL, 0, db1);
114  root->awar_int (GA_AWAR_KMER_NOFAST, 0, db1);
115  root->awar_int (GA_AWAR_SHOW_DIST, 0, db1);
116  root->awar_int (GA_AWAR_SHOW_DIFF, 0, db1);
117  root->awar_int (GA_AWAR_COLOR, 1, db1);
118  root->awar_int (GA_AWAR_GENE_START, 0, db1);
119  root->awar_int (GA_AWAR_GENE_END, 0, db1);
120  root->awar_int (GA_AWAR_FS_COVER_GENE, 1, db1);
121 }
122 
124  const char *sinaName = root->awar(GA_AWAR_CMD)->read_char_pntr();
125  char *sina = ARB_executable(sinaName, GB_getenv("PATH"));
126  const char *fail_reason = NULp;
127 
128  if (sina) {
129  int exitstatus = system(GBS_global_string("%s --has-cli-vers ARB5.99", sina));
130  exitstatus = WEXITSTATUS(exitstatus);
131 
132  switch (exitstatus) {
133  case EXIT_SUCCESS:
134  break;
135 
136  case EXIT_FAILURE:
137  fail_reason = "Incompatible SINA and ARB versions";
138  break;
139 
140  case 127: // libs missing
141  default: // unexpected
142  fail_reason = GBS_global_string("Could execute SINA binary '%s' (exitstatus was %i)",
143  sinaName, exitstatus);
144  break;
145  }
146  free(sina);
147  }
148  else {
149  fail_reason = GBS_global_string("%s not found", sinaName);
150  }
151 
152  if (fail_reason) {
153  fprintf(stderr,
154  "Note: SINA (SILVA Aligner) disabled (Reason: %s)\n",
155  fail_reason);
156  }
157 
158  return fail_reason ? AWM_DISABLED : AWM_ALL;
159 }
160 
161 inline const char *stream2static(const std::stringstream& str) {
162  return GBS_static_string(str.str().c_str());
163 }
164 
165 inline const char *empty_as_none(const char *sainame) {
166  // see http://bugs.arb-home.de/ticket/519
167  if (sainame && !sainame[0]) sainame = "none";
168  return sainame;
169 }
170 
171 static void sina_start(AW_window *window, const AlignDataAccess *data_access) {
172  cerr << "Starting SINA..." << endl;
173 
174  // make string from pt server selection
175  AW_root *root = window->get_root();
176  int pt = root->awar(AWAR_PT_SERVER)->read_int();
177 
178  std::stringstream ptnam;
179  ptnam << "ARB_PT_SERVER" << pt;
180 
181  const char *pt_server = GBS_read_arb_tcp(ptnam.str().c_str());
182  GB_ERROR gb_error = NULp;
183 
184  if (!pt_server) {
185  gb_error = GBS_global_string("Unable to find definition for chosen PT-server\n(Reason: %s)", GB_await_error());
186  }
187  else {
188  const char *pt_db = pt_server + strlen(pt_server) + 1;
189  pt_db += strlen(pt_db)+3;
190 
191  // start pt server if necessary
192  gb_error = arb_look_and_start_server(AISC_MAGIC_NUMBER, ptnam.str().c_str());
193  if (gb_error) {
194  std::stringstream tmp;
195  tmp << "Cannot contact PT server. Aborting" << endl
196  << " ID: \"" << tmp.str().c_str()
197  << "\" PORT: \"" << pt_server
198  << "\" DB: \"" << pt_db << endl
199  << "\" GBERROR: \"" << gb_error << "\"" << endl;
200  gb_error = stream2static(tmp);
201  }
202  else {
203  // create temporary file
204  char* tmpfile;
205  FILE* tmpfile_F;
206  {
207  char* tmpfile_tpl = GB_unique_filename("sina_select", "tmp");
208  tmpfile_F = GB_fopen_tempfile(tmpfile_tpl, "w", &tmpfile);
209  free(tmpfile_tpl);
210  }
211 
212  if (!tmpfile_F) {
213  std::stringstream tmp;
214  tmp << "Error: Unable to create temporary file \"" << tmpfile << "\"!";
215  gb_error = stream2static(tmp);
216  }
217  else {
218  GB_remove_on_exit(tmpfile);
219  GBDATA *gb_main = data_access->gb_main;
220 
221  std::vector<std::string> spec_names;
222  switch (root->awar(GA_AWAR_TGT)->read_int()) {
223  case 0: { // current
224  char *spec_name = root->awar(AWAR_SPECIES_NAME)->read_string();
225  if (spec_name) {
226  fwrite(spec_name, strlen(spec_name), 1, tmpfile_F);
227  fwrite("\n", 1, 1, tmpfile_F);
228  }
229  else {
230  gb_error = "Unable to get name of currently active species";
231  }
232  free(spec_name);
233  break;
234  }
235  case 1: { // selected
236  GB_begin_transaction(gb_main);
237  int num_selected = 0;
238  for (GBDATA *gb_spec = data_access->get_first_selected_species(&num_selected);
239  gb_spec;
240  gb_spec = data_access->get_next_selected_species())
241  {
242  GBDATA *gbd_name = GB_find(gb_spec, "name", SEARCH_CHILD);
243  if (gbd_name) {
244  const char *str = GB_read_char_pntr(gbd_name);
245  fwrite(str, strlen(str), 1, tmpfile_F);
246  fwrite("\n", 1, 1, tmpfile_F);
247  }
248  }
249  GB_commit_transaction(gb_main);
250  break;
251  }
252  case 2: { // marked
253  GB_begin_transaction(gb_main);
254  for (GBDATA *gb_spec = GBT_first_marked_species(gb_main);
255  gb_spec; gb_spec = GBT_next_marked_species(gb_spec)) {
256  GBDATA *gbd_name = GB_find(gb_spec, "name", SEARCH_CHILD);
257  if (gbd_name) {
258  const char *str = GB_read_char_pntr(gbd_name);
259  fwrite(str, strlen(str), 1, tmpfile_F);
260  fwrite("\n", 1, 1, tmpfile_F);
261  }
262  }
263  GB_commit_transaction(gb_main);
264  break;
265  }
266  }
267  fclose(tmpfile_F);
268 
269  if (!gb_error) {
270  // build command line
271  GBS_strstruct *cl = GBS_stropen(2000);
272 
273  GBS_strcat(cl, root->awar(GA_AWAR_CMD)->read_char_pntr());
274  GBS_strcat(cl, " -i :");
275  GBS_strcat(cl, " --ptdb :");
276  GBS_strcat(cl, " --ptport "); GBS_strcat(cl, pt_server);
277  GBS_strcat(cl, " --turn "); GBS_strcat(cl, root->awar(GA_AWAR_TURN_CHECK)->read_int() ? "all" : "none");
278  GBS_strcat(cl, " --overhang "); GBS_strcat(cl, root->awar(GA_AWAR_OVERHANG)->read_char_pntr());
279  GBS_strcat(cl, " --filter "); GBS_strcat(cl, empty_as_none(root->awar(GA_AWAR_SAI)->read_char_pntr()));
280  GBS_strcat(cl, " --fs-min "); GBS_intcat(cl, root->awar(GA_AWAR_FS_MIN)->read_int());
281  GBS_strcat(cl, " --fs-msc "); GBS_floatcat(cl, root->awar(GA_AWAR_FS_MSC)->read_float());
282  GBS_strcat(cl, " --fs-max "); GBS_intcat(cl, root->awar(GA_AWAR_FS_MAX)->read_int());
283  GBS_strcat(cl, " --fs-req 1");
284  GBS_strcat(cl, " --fs-req-full "); GBS_intcat(cl, root->awar(GA_AWAR_MIN_FULL)->read_int());
285  GBS_strcat(cl, " --fs-full-len "); GBS_intcat(cl, root->awar(GA_AWAR_FULL_MINLEN)->read_int());
286  GBS_strcat(cl, " --fs-kmer-len "); GBS_intcat(cl, root->awar(GA_AWAR_KMER_LEN)->read_int());
287  GBS_strcat(cl, " --fs-kmer-mm "); GBS_intcat(cl, root->awar(GA_AWAR_KMER_MM)->read_int());
288  GBS_strcat(cl, " --fs-min-len "); GBS_intcat(cl, root->awar(GA_AWAR_MIN_LEN)->read_int());
289  GBS_strcat(cl, " --fs-weight "); GBS_intcat(cl, root->awar(GA_AWAR_WEIGHT)->read_float()); // @@@ possible type conflict?
290  GBS_strcat(cl, " --pen-gap "); GBS_floatcat(cl, root->awar(GA_AWAR_GAP_PEN)->read_float());
291  GBS_strcat(cl, " --pen-gapext "); GBS_floatcat(cl, root->awar(GA_AWAR_GAP_EXT)->read_float());
292  GBS_strcat(cl, " --match-score "); GBS_floatcat(cl, root->awar(GA_AWAR_MATCH_SCORE)->read_float());
293  GBS_strcat(cl, " --mismatch-score "); GBS_floatcat(cl, root->awar(GA_AWAR_MISMATCH_SCORE)->read_float());
294  GBS_strcat(cl, " --prot-level "); GBS_intcat(cl, root->awar(GA_AWAR_PROTECTION)->read_int());
295  GBS_strcat(cl, " --select-file "); GBS_strcat(cl, tmpfile);
296  GBS_strcat(cl, " --insertion "); GBS_strcat(cl, root->awar(GA_AWAR_INSERT)->read_char_pntr());
297  GBS_strcat(cl, " --lowercase "); GBS_strcat(cl, root->awar(GA_AWAR_LOWERCASE)->read_char_pntr());
298  GBS_strcat(cl, " --auto-filter-field "); GBS_strcat(cl, root->awar(GA_AWAR_AUTOFILTER)->read_char_pntr());
299  GBS_strcat(cl, " --gene-start "); GBS_intcat(cl, root->awar(GA_AWAR_GENE_START)->read_int());
300  GBS_strcat(cl, " --gene-end "); GBS_intcat(cl, root->awar(GA_AWAR_GENE_END)->read_int());
301  GBS_strcat(cl, " --fs-cover-gene ");GBS_intcat(cl, root->awar(GA_AWAR_FS_COVER_GENE)->read_int());
302 
303 
304  if (root->awar(GA_AWAR_KMER_NOREL)->read_int()) GBS_strcat(cl, " --fs-kmer-norel ");
305  if (root->awar(GA_AWAR_KMER_NOFAST)->read_int()) GBS_strcat(cl, " --fs-kmer-no-fast ");
306  if (root->awar(GA_AWAR_SHOW_DIST)->read_int()) GBS_strcat(cl, " --show-dist ");
307  if (root->awar(GA_AWAR_SHOW_DIFF)->read_int()) GBS_strcat(cl, " --show-diff ");
308  if (root->awar(GA_AWAR_COLOR)->read_int()) GBS_strcat(cl, " --color");
309  if (root->awar(GA_AWAR_REALIGN)->read_int()) GBS_strcat(cl, " --realign");
310 
311  gb_error = GB_xcmd(GBS_mempntr(cl), XCMD_ASYNC_WAITKEY);
312  GBS_strforget(cl);
313  }
314 
315  if (!gb_error) aw_message("SINA finished aligning.");
316  }
317  free(tmpfile);
318  }
319  }
320 
321  aw_message_if(gb_error);
322 }
323 
324 
325 
326 static char* filter_posvar_SAI_for_ali(GBDATA *gb_extended, const char *ali_name) {
327  char *result = NULp;
328  char *typePath = GBS_global_string_copy("%s/_TYPE", ali_name);
329  GBDATA *gbd = GB_search(gb_extended, typePath, GB_FIND);
330  if (gbd) {
331  const char* type = GB_read_char_pntr(gbd);
332  if (type && strncmp("PV", type, 2) == 0) {
333  gbd = GB_find(gb_extended, "name", SEARCH_CHILD);
334  result = GB_read_string(gbd);
335  }
336  }
337  free(typePath);
338  return result;
339 }
340 
342  // both
343  { GA_AWAR_TGT, "target" },
344  { GA_AWAR_OVERHANG, "overhang" },
345  { GA_AWAR_INSERT, "insertions" },
346  { GA_AWAR_LOWERCASE, "lowercase" },
347  { GA_AWAR_WEIGHT, "weight" },
348  { GA_AWAR_FULL_MINLEN, "fullminlen" },
349 
350  // advanced only
351  { GA_AWAR_SAI, "sai" },
352  { GA_AWAR_AUTOFILTER, "autofilter" },
353  { GA_AWAR_TURN_CHECK, "turncheck" },
354  { GA_AWAR_REALIGN, "realign" },
355  { GA_AWAR_GAP_PEN, "gappen" },
356  { GA_AWAR_GAP_EXT, "gapext" },
357  { GA_AWAR_MATCH_SCORE, "matchscore" },
358  { GA_AWAR_MISMATCH_SCORE, "mismatchscore" },
359  { GA_AWAR_FS_MIN, "fs_min" },
360  { GA_AWAR_FS_MSC, "fs_minscore" },
361  { GA_AWAR_FS_MAX, "fs_min" },
362  { GA_AWAR_MIN_FULL, "minfull" },
363  { GA_AWAR_KMER_LEN, "kmerlen" },
364  { GA_AWAR_KMER_MM, "kmermm" },
365  { GA_AWAR_MIN_LEN, "refminlen" },
366  { GA_AWAR_GENE_START, "genestart" },
367  { GA_AWAR_GENE_END, "geneend" },
368  { GA_AWAR_FS_COVER_GENE, "fs_covergene" },
369  { GA_AWAR_KMER_NOFAST, "kmernofast" },
370  { GA_AWAR_KMER_NOREL, "kmernorel" },
371 
372  // both
373  { GA_AWAR_SHOW_DIFF, "showdiff" },
374  { GA_AWAR_COLOR, "color" },
375  { GA_AWAR_SHOW_DIST, "showdist" },
376 
377  { NULp, NULp }
378 };
379 
380 static AW_window_simple* new_sina_simple(AW_root *root, const AlignDataAccess *alignData, bool adv) {
381  int closex, closey, startx, starty, winx, winy;
382  const int hgap = 10;
383  AW_window_simple *aws = new AW_window_simple;
384 
385  aws->init(root, adv ? "XSINA" : "SINA", "SINA (SILVA Incremental Aligner)");
386 
387  aws->button_length(12);
388  aws->at(10, 10);
389  aws->auto_space(5, 5);
390 
391  aws->callback(AW_POPDOWN);
392  aws->create_button("CLOSE", "CLOSE", "O");
393  aws->get_at_position(&closex, &closey);
394 
395  aws->at_shift(10, 0);
396  aws->label_length(0);
397  aws->label("Show advanced options");
398  aws->create_toggle(GA_AWAR_ADVANCED);
399 
400  bool cbInstalled = false;
401  if (!cbInstalled) {
402  root->awar(GA_AWAR_ADVANCED)->add_callback(makeRootCallback(show_sina_window, alignData));
403  cbInstalled = true;
404  }
405 
406  aws->at_newline();
407  aws->at_shift(0, hgap);
408  aws->label_length(15);
409  aws->create_toggle_field(GA_AWAR_TGT, "Align what?", "A");
410  aws->insert_toggle("Current Species:", "C", 0);
411  aws->insert_toggle("Selected Species", "S", 1);
412  aws->insert_default_toggle("Marked Species", "M", 2);
413  aws->update_toggle_field();
414 
415  aws->at_shift(0, 3);
416  aws->create_input_field(AWAR_SPECIES_NAME, 20);
417 
418  aws->at_newline();
419  aws->at_shift(0, hgap);
420  aws->button_length(24);
421  aws->label("PT Server:");
423 
424  aws->at_newline();
425  aws->label_length(0);
426  aws->label("Overhang placement");
427  aws->create_option_menu(GA_AWAR_OVERHANG, true);
428  aws->insert_option("keep attached", NULp, "attach");
429  aws->insert_option("move to edge", NULp, "edge");
430  aws->insert_option("remove", NULp, "remove");
431  aws->update_option_menu();
432 
433  aws->at_newline();
434  aws->label("Handling of unmappable insertions");
435  aws->create_option_menu(GA_AWAR_INSERT, true);
436  aws->insert_option("Shift surrounding bases", NULp, "shift");
437  aws->insert_option("Forbid during DP alignment", NULp, "forbid");
438  aws->insert_option("Delete bases", NULp, "remove");
439  aws->update_option_menu();
440 
441  aws->at_newline();
442  aws->label("Character Case");
443  aws->create_option_menu(GA_AWAR_LOWERCASE, true);
444  aws->insert_option("Do not modify", NULp, "original");
445  aws->insert_option("Show unaligned bases as lower case", NULp, "unaligned");
446  aws->insert_option("Uppercase all", NULp, "none");
447  aws->update_option_menu();
448 
449  aws->at_newline();
450  aws->label("Family conservation weight (0-1)");
451  aws->create_input_field(GA_AWAR_WEIGHT, 3);
452 
453  aws->at_newline();
454  aws->label("Size of full-length sequences");
455  aws->create_input_field(GA_AWAR_FULL_MINLEN, 5);
456 
457  if (adv) {
458  aws->at_newline();
459  aws->at_shift(0, hgap);
460 
461  aws->at_newline();
462 
463  aws->label("Pos. Var.:");
464  awt_create_SAI_selection_button(alignData->gb_main, aws, GA_AWAR_SAI, makeSaiSelectionlistFilterCallback(filter_posvar_SAI_for_ali, alignData->alignment_name.c_str()));
465 
466  aws->at_newline();
467  aws->label("Field used for automatic filter selection");
468  aws->create_input_field(GA_AWAR_AUTOFILTER, 20);
469 
470  aws->label("Turn check");
471  aws->create_toggle(GA_AWAR_TURN_CHECK);
472 
473  aws->at_newline();
474  aws->label("Realign");
475  aws->create_toggle(GA_AWAR_REALIGN);
476 
477  /*
478  aws->at_newline();
479  aws->label("(Copy and) mark sequences used as reference");
480  aws->create_toggle(GA_AWAR_COPYMARKREF);
481  */
482 
483  aws->at_newline();
484  aws->at_shift(0, hgap);
485  aws->label_length(0);
486 
487  aws->label("Gap insertion/extension penalties");
488  aws->create_input_field(GA_AWAR_GAP_PEN, 5);
489  aws->create_input_field(GA_AWAR_GAP_EXT, 5);
490 
491  aws->at_newline();
492  aws->label("Match score");
493  aws->create_input_field(GA_AWAR_MATCH_SCORE, 3);
494  aws->label("Mismatch score");
495  aws->create_input_field(GA_AWAR_MISMATCH_SCORE, 3);
496 
497  aws->at_newline();
498  aws->label("Family search min/min_score/max");
499  aws->create_input_field(GA_AWAR_FS_MIN, 3);
500  aws->create_input_field(GA_AWAR_FS_MSC, 3);
501  aws->create_input_field(GA_AWAR_FS_MAX, 3);
502 
503  aws->at_newline();
504  aws->label("Minimal number of full length sequences");
505  aws->create_input_field(GA_AWAR_MIN_FULL, 3);
506 
507  aws->at_newline();
508  aws->label("Family search oligo length / mismatches");
509  aws->create_input_field(GA_AWAR_KMER_LEN, 3);
510  aws->create_input_field(GA_AWAR_KMER_MM, 3);
511 
512  aws->at_newline();
513  aws->label("Minimal reference sequence length");
514  aws->create_input_field(GA_AWAR_MIN_LEN, 5);
515 
516  aws->at_newline();
517  aws->label("Alignment bounds: start");
518  aws->create_input_field(GA_AWAR_GENE_START, 6);
519  aws->label("end");
520  aws->create_input_field(GA_AWAR_GENE_END, 6);
521 
522  aws->at_newline();
523  aws->label("Number of references required to touch bounds");
524  aws->create_input_field(GA_AWAR_FS_COVER_GENE, 3);
525 
526  aws->at_newline();
527  aws->label("Disable fast search");
528  aws->create_toggle(GA_AWAR_KMER_NOFAST);
529 
530  aws->at_newline();
531  aws->label("Score search results by absolute oligo match count");
532  aws->create_toggle(GA_AWAR_KMER_NOREL);
533 
534  aws->at_newline();
535  aws->label("SINA command");
536  aws->create_input_field(GA_AWAR_CMD, 20);
537 
538  aws->at_shift(0, hgap);
539  }
540 
541  aws->at_newline();
542  aws->at_shift(0, hgap);
543 
544  aws->label_length(17);
545  aws->label("Protection Level");
546  aws->create_option_menu(GA_AWAR_PROTECTION, true);
547  aws->insert_option("0", NULp, 0);
548  aws->insert_option("1", NULp, 1);
549  aws->insert_option("2", NULp, 2);
550  aws->insert_option("3", NULp, 3);
551  aws->insert_option("4", NULp, 4);
552  aws->insert_option("5", NULp, 5);
553  aws->insert_option("6", NULp, 6);
554  aws->update_option_menu();
555 
556  aws->at_newline();
557  aws->label("Show changed sections of alignment");
558  aws->create_toggle(GA_AWAR_SHOW_DIFF);
559  aws->label("color bases");
560  aws->create_toggle(GA_AWAR_COLOR);
561 
562  aws->at_newline();
563  aws->label("Show statistics");
564  aws->create_toggle(GA_AWAR_SHOW_DIST);
565 
566  aws->get_window_size(winx, winy);
567  aws->get_at_position(&startx, &starty);
568 
569  aws->button_length(12);
570 
571  aws->at(winx-closex+5, closey);
572  aws->callback(makeHelpCallback("sina_main.hlp"));
573  aws->create_button("HELP", "HELP");
574 
575  aws->at(winx-closex+5, starty);
576  aws->callback(makeWindowCallback(sina_start, alignData));
577  aws->highlight();
578  aws->create_button("Start", "Start", "S");
579 
580  aws->at(winx-50, starty-50);
581  AWT_insert_config_manager(aws, AW_ROOT_DEFAULT, "sina", sina_config_mapping);
582 
583  return aws;
584 }
585 
586 void show_sina_window(UNFIXED, const AlignDataAccess *alignData) {
587  AW_root *root = AW_root::SINGLETON;
588 
589  static AW_window_simple *ga_aws = new_sina_simple(root, alignData, false);
590  static AW_window_simple *ga_aws_adv = new_sina_simple(root, alignData, true);
591 
592  if (root->awar(GA_AWAR_ADVANCED)->read_int()) {
593  ga_aws_adv->show();
594  ga_aws->hide();
595  }
596  else {
597  ga_aws->show();
598  ga_aws_adv->hide();
599  }
600 }
601 
GB_ERROR GB_begin_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2516
#define GA_AWAR_GENE_START
const char * stream2static(const std::stringstream &str)
AW_bitset AW_active
Definition: aw_base.hxx:45
string result
GB_TYPES type
#define GA_AWAR_FS_MAX
GB_ERROR GB_commit_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2539
void GB_remove_on_exit(const char *filename)
Definition: adsocket.cxx:1203
GBDATA * GBT_first_marked_species(GBDATA *gb_main)
Definition: aditem.cxx:113
static char * filter_posvar_SAI_for_ali(GBDATA *gb_extended, const char *ali_name)
#define GA_AWAR_SHOW_DIST
#define GA_AWAR_COLOR
#define GA_AWAR_OVERHANG
GBDATA * GB_find(GBDATA *gbd, const char *key, GB_SEARCH_TYPE gbs)
Definition: adquery.cxx:295
Aligner_get_first_selected_species get_first_selected_species
#define GA_AWAR_LOWERCASE
#define GA_AWAR_TURN_CHECK
void GBS_intcat(GBS_strstruct *strstr, long val)
Definition: arb_strbuf.cxx:127
void AWT_insert_config_manager(AW_window *aww, AW_default default_file_, const char *id, const StoreConfigCallback &store_cb, const RestoreConfigCallback &load_or_reset_cb, const char *macro_id, const AWT_predefined_config *predef)
GB_ERROR arb_look_and_start_server(long magic_number, const char *arb_tcp_env)
long read_int() const
Definition: AW_awar.cxx:187
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:204
#define GA_AWAR_FS_MSC
void AW_POPDOWN(AW_window *window)
Definition: AW_window.cxx:52
#define GA_AWAR_WEIGHT
std::string alignment_name
#define GA_AWAR_CMD
static AW_window_simple * new_sina_simple(AW_root *root, const AlignDataAccess *alignData, bool adv)
#define EXIT_SUCCESS
Definition: arb_a2ps.c:154
Aligner_get_next_selected_species get_next_selected_species
void awt_create_SAI_selection_button(GBDATA *gb_main, AW_window *aws, const char *varname, const SaiSelectionlistFilterCallback &fcb)
#define GA_AWAR_MIN_FULL
#define GA_AWAR_REALIGN
#define GA_AWAR_SHOW_DIFF
#define GA_AWAR_MISMATCH_SCORE
AW_awar * add_callback(const RootCallback &cb)
Definition: AW_awar.cxx:234
struct Unfixed_cb_parameter * UNFIXED
Definition: cb_base.h:15
#define GA_AWAR_KMER_MM
const char * empty_as_none(const char *sainame)
const char * read_char_pntr() const
Definition: AW_awar.cxx:171
char * ARB_executable(const char *exe_name, const char *path)
Definition: arb_misc.cxx:107
GBS_strstruct * GBS_stropen(long init_size)
Definition: arb_strbuf.cxx:39
GB_ERROR GB_await_error()
Definition: arb_msg.cxx:353
static AW_root * SINGLETON
Definition: aw_root.hxx:102
WindowCallback makeHelpCallback(const char *helpfile)
Definition: aw_window.hxx:106
#define AWAR_PT_SERVER
#define GA_AWAR_COPYMARKREF
const char * GBS_read_arb_tcp(const char *env)
Definition: adtcp.cxx:325
#define GA_AWAR_KMER_NOFAST
#define GA_AWAR_INSERT
#define GA_AWAR_FULL_MINLEN
void show_sina_window(UNFIXED, const AlignDataAccess *alignData)
AW_awar * awar_float(const char *var_name, float default_value=0.0, AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:560
void GBS_strcat(GBS_strstruct *strstr, const char *ptr)
Definition: arb_strbuf.cxx:108
FILE * GB_fopen_tempfile(const char *filename, const char *fmode, char **res_fullname)
Definition: adsocket.cxx:1121
#define GA_AWAR_GAP_EXT
GBDATA * GBT_next_marked_species(GBDATA *gb_species)
Definition: aditem.cxx:116
#define GA_AWAR_ADVANCED
#define AWAR_SPECIES_NAME
#define GA_AWAR_KMER_NOREL
static AWT_config_mapping_def sina_config_mapping[]
NOT4PERL GB_ERROR GB_xcmd(const char *cmd, XCMD_TYPE exectype) __ATTR__USERESULT_TODO
Definition: adsocket.cxx:853
char * read_string() const
Definition: AW_awar.cxx:201
AW_awar * awar(const char *awar)
Definition: AW_root.cxx:554
void GBS_strforget(GBS_strstruct *strstr)
Definition: arb_strbuf.cxx:76
Definition: arbdb.h:86
#define GA_AWAR_THREADS
#define GA_AWAR_FS_MIN
#define EXIT_FAILURE
Definition: arb_a2ps.c:157
void awt_create_PTSERVER_selection_button(AW_window *aws, const char *varname)
float read_float() const
Definition: AW_awar.cxx:180
GB_CSTR GB_getenv(const char *env)
Definition: adsocket.cxx:656
#define AISC_MAGIC_NUMBER
Definition: client_privat.h:51
char * GB_unique_filename(const char *name_prefix, const char *suffix)
Definition: adsocket.cxx:1178
#define GA_AWAR_PROTECTION
#define GA_AWAR_QSIZE
AW_active sina_mask(AW_root *root)
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:580
char * GBS_mempntr(GBS_strstruct *strstr)
Definition: arb_strbuf.cxx:86
char * GB_read_string(GBDATA *gbd)
Definition: arbdb.cxx:903
const char * GBS_static_string(const char *str)
Definition: arb_msg.cxx:213
#define GA_AWAR_KMER_LEN
void aw_message(const char *msg)
Definition: AW_status.cxx:932
AW_root * get_root()
Definition: aw_window.hxx:348
#define GA_AWAR_GAP_PEN
#define NULp
Definition: cxxforward.h:97
void GBS_floatcat(GBS_strstruct *strstr, double val)
Definition: arb_strbuf.cxx:133
#define GA_AWAR_AUTOFILTER
#define GA_AWAR_TGT
#define GA_AWAR_SAI
#define GA_AWAR_GENE_END
#define GA_AWAR_MATCH_SCORE
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
Definition: arbdb.cxx:898
GBDATA * gb_main
Definition: adname.cxx:33
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:570
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
Definition: adquery.cxx:531
void create_sina_variables(AW_root *root, AW_default db1)
#define GA_AWAR_MIN_LEN
#define AW_ROOT_DEFAULT
Definition: aw_base.hxx:106
void aw_message_if(GB_ERROR error)
Definition: aw_msg.hxx:21
char * GBS_global_string_copy(const char *templat,...)
Definition: arb_msg.cxx:195
#define GA_AWAR_FS_COVER_GENE
static void sina_start(AW_window *window, const AlignDataAccess *data_access)