ARB
GEN_interface.cxx
Go to the documentation of this file.
1 // ============================================================= //
2 // //
3 // File : GEN_interface.cxx //
4 // Purpose : //
5 // //
6 // Coded by Ralf Westram (coder@reallysoft.de) in February 2001 //
7 // Institute of Microbiology (Technical University Munich) //
8 // http://www.arb-home.de/ //
9 // //
10 // ============================================================== //
11 
12 #include "GEN_local.hxx"
13 
14 #include <db_scanner.hxx>
15 #include <db_query.h>
16 #include <dbui.h>
17 #include <item_sel_list.h>
18 #include <info_window.h>
19 
20 #include <awt_sel_boxes.hxx>
21 #include <awt_prompt.hxx>
22 
23 #include <aw_awar_defs.hxx>
24 #include <aw_root.hxx>
25 #include <aw_msg.hxx>
26 #include <aw_question.hxx>
27 
28 #include <adGene.h>
29 #include <Location.h>
30 
31 #include <arb_strarray.h>
32 #include <arb_strbuf.h>
33 
34 using namespace std;
35 
36 // --------------------------------------------------------------------------------
37 
38 #define AWAR_GENE_DEST "tmp/gene/dest"
39 
40 // --------------------------------------------------------------------------------
41 
42 #define AD_F_ALL AWM_ALL // @@@ replace all occurrences of AD_F_ALL by AWM_ALL
43 
44 // --------------------------------------------------------------------------------
45 
46 static void GEN_select_gene(GBDATA* /* gb_main */, AW_root *aw_root, const char *item_name) {
47  char *organism = ARB_strdup(item_name);
48  char *gene = strchr(organism, '/');
49 
50  if (gene) {
51  *gene++ = 0;
52  aw_root->awar(AWAR_ORGANISM_NAME)->write_string(organism);
53  aw_root->awar(AWAR_GENE_NAME)->write_string(gene);
54  }
55  else if (!item_name[0]) { // accept empty input -> deselect gene/organism
56  aw_root->awar(AWAR_GENE_NAME)->write_string("");
57  aw_root->awar(AWAR_ORGANISM_NAME)->write_string("");
58  }
59  else {
60  aw_message(GBS_global_string("Illegal item_name '%s' in GEN_select_gene()", item_name));
61  }
62  free(organism);
63 }
64 
65 static char *gen_get_gene_id(GBDATA * /* gb_main */, GBDATA *gb_gene) {
66  GBDATA *gb_species = GB_get_grandfather(gb_gene);
68 }
69 
70 static GBDATA *gen_find_gene_by_id(GBDATA *gb_main, const char *id) {
71  char *organism = ARB_strdup(id);
72  char *gene = strchr(organism, '/');
73  GBDATA *result = NULp;
74 
75  if (gene) {
76  *gene++ = 0;
77  GBDATA *gb_organism = GEN_find_organism(gb_main, organism);
78  if (gb_organism) {
79  result = GEN_find_gene(gb_organism, gene);
80  }
81  }
82 
83  free(organism);
84  return result;
85 }
86 
87 
88 GB_ERROR GEN_mark_organism_or_corresponding_organism(GBDATA *gb_species, int */*client_data*/) {
90 
91  if (GEN_is_pseudo_gene_species(gb_species)) {
92  GBDATA *gb_organism = GEN_find_origin_organism(gb_species, NULp);
93  if (gb_organism) {
94  GB_write_flag(gb_organism, 1);
95  }
96  else {
97  error = GEN_organism_not_found(gb_species);
98  }
99  }
100  else if (GEN_is_organism(gb_species)) {
101  GB_write_flag(gb_species, 1);
102  }
103 
104  return error;
105 }
106 
107 static char *old_species_marks = NULp; // configuration storing marked species
108 
110  if (old_species_marks) {
111  GBT_restore_marked_species(gb_main, old_species_marks);
112  freenull(old_species_marks);
113  }
114 }
115 
117  GBDATA *gb_organism = NULp;
118  GB_ERROR error = NULp;
119 
121 
122  switch (range) {
123  case QUERY_CURRENT_ITEM: {
124  char *species_name = aw_root->awar(AWAR_ORGANISM_NAME)->read_string();
125  gb_organism = GEN_find_organism(gb_main, species_name);
126  free(species_name);
127  break;
128  }
129  case QUERY_MARKED_ITEMS: {
130  gb_organism = GEN_first_marked_organism(gb_main);
131  GBDATA *gb_pseudo = GEN_first_marked_pseudo_species(gb_main);
132 
133  if (gb_pseudo) { // there are marked pseudo-species..
134  old_species_marks = GBT_store_marked_species(gb_main, true); // store and unmark marked species
135 
136  error = GBT_with_stored_species(gb_main, old_species_marks, GEN_mark_organism_or_corresponding_organism, NULp); // mark organisms related with stored
137  if (!error) gb_organism = GEN_first_marked_organism(gb_main);
138  }
139 
140  break;
141  }
142  case QUERY_ALL_ITEMS: {
143  gb_organism = GEN_first_organism(gb_main);
144  break;
145  }
146  default: {
147  gen_assert(0);
148  break;
149  }
150  }
151 
152  if (error) GB_export_error(error);
153  return gb_organism ? GEN_expect_gene_data(gb_organism) : NULp;
154 }
155 
156 static GBDATA *GEN_get_next_gene_data(GBDATA *gb_gene_data, QUERY_RANGE range) {
157  GBDATA *gb_organism = NULp;
158  switch (range) {
159  case QUERY_CURRENT_ITEM: {
160  break;
161  }
162  case QUERY_MARKED_ITEMS: {
163  GBDATA *gb_last_organism = GB_get_father(gb_gene_data);
164  gb_organism = GEN_next_marked_organism(gb_last_organism);
165 
166  if (!gb_organism) gen_restore_old_species_marks(GB_get_root(gb_last_organism)); // got all -> clean up
167 
168  break;
169  }
170  case QUERY_ALL_ITEMS: {
171  GBDATA *gb_last_organism = GB_get_father(gb_gene_data);
172  gb_organism = GEN_next_organism(gb_last_organism);
173  break;
174  }
175  default: {
176  gen_assert(0);
177  break;
178  }
179  }
180 
181  return gb_organism ? GEN_expect_gene_data(gb_organism) : NULp;
182 }
183 
185  GBDATA *gb_species = GEN_get_current_organism(gb_main);
186  GBDATA *gb_gene = NULp;
187 
188  if (gb_species) {
189  char *gene_name = aw_root->awar(AWAR_GENE_NAME)->read_string();
190  gb_gene = GEN_find_gene(gb_species, gene_name);
191  free(gene_name);
192  }
193 
194  return gb_gene;
195 }
196 
197 static void add_selected_gene_changed_cb(AW_root *aw_root, const RootCallback& cb) {
198  aw_root->awar(AWAR_GENE_NAME)->add_callback(cb);
200 }
201 
202 static GBDATA *first_gene_in_range(GBDATA *gb_gene_data, QUERY_RANGE range) {
203  GBDATA *gb_first = NULp;
204  switch (range) {
205  case QUERY_ALL_ITEMS: gb_first = GEN_first_gene_rel_gene_data(gb_gene_data); break;
206  case QUERY_MARKED_ITEMS: gb_first = GB_first_marked(gb_gene_data, "gene"); break;
207  case QUERY_CURRENT_ITEM: gb_first = GEN_get_current_gene(GB_get_root(gb_gene_data), AW_root::SINGLETON); break;
208  }
209  return gb_first;
210 }
211 static GBDATA *next_gene_in_range(GBDATA *gb_prev, QUERY_RANGE range) {
212  GBDATA *gb_next = NULp;
213  switch (range) {
214  case QUERY_ALL_ITEMS: gb_next = GEN_next_gene(gb_prev); break;
215  case QUERY_MARKED_ITEMS: gb_next = GEN_next_marked_gene(gb_prev); break;
216  case QUERY_CURRENT_ITEM: gb_next = NULp; break;
217  }
218  return gb_next;
219 }
220 
221 
222 static void refresh_displayed_genes() {
224 }
225 
226 static struct MutableItemSelector GEN_item_selector = { // @@@ move GEN_item_selector to SL/ITEMS
232  -1, // unknown
234  "gene",
235  "genes",
236  "name",
245 };
246 
248 
250  char *species_name = awr->awar(AWAR_SPECIES_NAME)->read_string();
251  GB_transaction ta(gb_main);
252  GBDATA *gb_species = GBT_find_species(gb_main, species_name);
253 
254  if (gb_species) {
255  if (GEN_is_pseudo_gene_species(gb_species)) {
257  awr->awar(AWAR_GENE_NAME)->write_string(GEN_origin_gene(gb_species));
258  }
259  else {
260  awr->awar(AWAR_ORGANISM_NAME)->write_string(species_name);
261  }
262  }
263  free(species_name);
264 }
265 
266 static void auto_select_pseudo_species(AW_root *awr, GBDATA *gb_main, const char *organism, const char *gene) {
267  GB_transaction ta(gb_main);
268  GBDATA *gb_pseudo = GEN_find_pseudo_species(gb_main, organism, gene, NULp); // search for pseudo species..
269 
270  awr->awar(AWAR_SPECIES_NAME)->write_string(gb_pseudo
271  ? GBT_get_name_or_description(gb_pseudo) // .. if found select
272  : organism); // otherwise select organism
273 }
274 
276  GB_transaction ta(gb_main);
277  GBDATA *gb_gene = GEN_get_current_gene(gb_main, awr);
278  bool clear = true;
279  AW_awar *awar_content = awr->awar(AWAR_GENE_CONTENT);
280 
281  if (gb_gene) {
282  // ignore complement here (to highlight gene in ARB_EDIT4);
283  // separate multiple parts by \n
284  char *gene_content = GBT_read_gene_sequence(gb_gene, false, '\n');
285  if (gene_content) {
286  awar_content->write_string(gene_content);
287  clear = false;
288  free(gene_content);
289  }
290  else {
291  awar_content->write_string(GB_await_error());
292  }
293  }
294  else {
295  char *gene_name = awr->awar(AWAR_GENE_NAME)->read_string();
296  const int prefix_len = 10;
297 
298  if (strncmp(gene_name, "intergene_", prefix_len) == 0) { // special case (non-gene result from gene pt server)
299  char *start_pos_ptr = gene_name+prefix_len;
300  char *end_pos_ptr = strchr(start_pos_ptr, '_');
301 
302  gen_assert(end_pos_ptr);
303  if (end_pos_ptr) {
304  *end_pos_ptr++ = 0;
305  long start_pos = atol(start_pos_ptr);
306  long end_pos = atol(end_pos_ptr);
307 
308  gen_assert(end_pos >= start_pos);
309 
310  GBDATA *gb_organism = GEN_get_current_organism(gb_main);
311  if (gb_organism) {
312  GBDATA *gb_seq = GBT_find_sequence(gb_organism, GENOM_ALIGNMENT);
313  const char *seq_data = GB_read_char_pntr(gb_seq);
314 
315  long len = end_pos-start_pos+1;
316  char *buffer = ARB_strndup(seq_data+start_pos, len);
317 
318  awar_content->write_string(buffer);
319  clear = false;
320 
321  free(buffer);
322  }
323  }
324  }
325  free(gene_name);
326  }
327 
328  if (clear) {
329  awar_content->write_string(""); // if we did not detect any gene sequence -> clear
330  }
331 }
332 
334  char *organism = awr->awar(AWAR_ORGANISM_NAME)->read_string();
335  char *gene = awr->awar(AWAR_GENE_NAME)->read_string();
336  char *old_combined = awr->awar(AWAR_COMBINED_GENE_NAME)->read_string();
337  const char *combined = GBS_global_string("%s/%s", organism, gene);
338 
339  if (strcmp(combined, old_combined) != 0) {
340  awr->awar(AWAR_COMBINED_GENE_NAME)->write_string(combined);
341  auto_select_pseudo_species(awr, gb_main, organism, gene);
342  GEN_update_GENE_CONTENT(gb_main, awr);
343  }
344 
345  free(old_combined);
346  free(gene);
347  free(organism);
348 }
349 
351  aw_root->awar_string(AWAR_COMBINED_GENE_NAME, "", gb_main);
352  aw_root->awar_string(AWAR_GENE_CONTENT, NULp, gb_main);
353 
354  RootCallback update_combined_cb = makeRootCallback(GEN_update_combined_cb, gb_main);
355 
356  aw_root->awar_string(AWAR_GENE_NAME, "", gb_main)->add_callback(update_combined_cb);
357  aw_root->awar_string(AWAR_ORGANISM_NAME, "", gb_main)->add_callback(update_combined_cb);
358  aw_root->awar_string(AWAR_SPECIES_NAME, "", gb_main)->add_callback(makeRootCallback(GEN_species_name_changed_cb, gb_main));
359 
360  aw_root->awar_string(AWAR_GENE_DEST, "", aw_def);
361 }
362 
364  char *species_name = AW_root::SINGLETON->awar(AWAR_ORGANISM_NAME)->read_string();
365  GBDATA *gb_species = GBT_find_species(gb_main, species_name);
366  free(species_name);
367  return gb_species;
368 }
369 
371  GBDATA *gb_species = GEN_get_current_organism(gb_main);
372  GBDATA *gb_gene_data = NULp;
373 
374  if (gb_species) gb_gene_data = GEN_expect_gene_data(gb_species);
375 
376  return gb_gene_data;
377 }
378 
380 
381 static GB_ERROR gene_rename_handler(const char *dest, GBDATA *gb_main) {
382  AW_root *aw_root = AW_root::SINGLETON;
383  const char *source = aw_root->awar(AWAR_GENE_NAME)->read_char_pntr();
384  GB_ERROR error = NULp;
385 
386  if (strcmp(source, dest) != 0) {
387  error = GB_begin_transaction(gb_main);
388 
389  if (!error) {
390  GBDATA *gb_gene_data = get_current_gene_data(gb_main);
391 
392  if (!gb_gene_data) error = "Please select an organism";
393  else if (!dest[0]) error = "empty name not possible";
394  else {
395  GBDATA *gb_source = GEN_find_gene_rel_gene_data(gb_gene_data, source);
396  GBDATA *gb_dest = GEN_find_gene_rel_gene_data(gb_gene_data, dest);
397 
398  if (!gb_source) error = "Please select a gene";
399  else if (gb_dest) error = GBS_global_string("Gene '%s' already exists", dest);
400  else {
401  GBDATA *gb_name = GB_search(gb_source, "name", GB_STRING);
402 
403  if (!gb_name) error = GB_await_error();
404  else {
405  error = GB_write_string(gb_name, dest);
406  if (!error) aw_root->awar(AWAR_GENE_NAME)->write_string(dest);
407  }
408  }
409  }
410  }
411 
412  error = GB_end_transaction(gb_main, error);
413  }
414  return error;
415 }
416 
417 static GB_ERROR gene_copy_handler(const char *dest, GBDATA *gb_main) {
418  AW_root *aw_root = AW_root::SINGLETON;
419  const char *source = aw_root->awar(AWAR_GENE_NAME)->read_char_pntr();
421 
422  if (!error) {
423  GBDATA *gb_gene_data = get_current_gene_data(gb_main);
424 
425  if (!gb_gene_data) error = "Please select an organism";
426  else if (!dest[0]) error = "empty name not possible";
427  else {
428  GBDATA *gb_source = GEN_find_gene_rel_gene_data(gb_gene_data, source);
429  GBDATA *gb_dest = GEN_find_gene_rel_gene_data(gb_gene_data, dest);
430 
431  if (!gb_source) error = "Please select a gene";
432  else if (gb_dest) error = GBS_global_string("Gene '%s' already exists", dest);
433  else {
434  gb_dest = GB_create_container(gb_gene_data, "gene");
435  if (!gb_dest) error = GB_await_error();
436  else error = GB_copy_dropProtectMarksAndTempstate(gb_dest, gb_source);
437 
438  if (!error) error = GBT_write_string(gb_dest, "name", dest);
439  if (!error) aw_root->awar(AWAR_GENE_NAME)->write_string(dest);
440  }
441  }
442  }
443 
444  error = GB_end_transaction(gb_main, error);
445 
446  return error;
447 }
448 
449 static void gene_rename_cb(AW_window *aww, GBDATA *gb_main) {
450  AW_root *aw_root = aww->get_root();
451  const char *source = aw_root->awar(AWAR_GENE_NAME)->read_char_pntr();
452  AWT_activate_prompt("Rename gene", "Enter new name of gene:", source, "Rename", makeResultHandler(gene_rename_handler, gb_main));
453 }
454 static void gene_copy_cb(AW_window *aww, GBDATA *gb_main) {
455  AW_root *aw_root = aww->get_root();
456  const char *source = aw_root->awar(AWAR_GENE_NAME)->read_char_pntr();
457  AWT_activate_prompt("Copy gene", "Enter name of new gene:", source, "Copy", makeResultHandler(gene_copy_handler, gb_main));
458 }
459 
460 // -----------------------
461 // LocationEditor
462 
463 const int NAME_WIDTH = 33;
464 const int POS_WIDTH = NAME_WIDTH;
465 const int CER_WIDTH = POS_WIDTH/2;
466 const int LOC_WIDTH = 53;
467 
468 #define GLE_POS1 "pos1"
469 #define GLE_POS2 "pos2"
470 #define GLE_CERT1 "cert1"
471 #define GLE_CERT2 "cert2"
472 #define GLE_COMPLEMENT "complement"
473 #define GLE_JOINABLE "joinable"
474 #define GLE_READABLE "location"
475 #define GLE_STATUS "status"
476 
477 class LocationEditor : virtual Noncopyable { // GLE
478  typedef void (*PosChanged_cb)(AW_root *aw_root, LocationEditor *loced);
479 
480  char *tag;
481  AW_root *aw_root;
482  GBDATA *gb_main;
483  char *status;
484  GEN_position *pos;
485  PosChanged_cb pos_changed_cb;
486 
487  void createAwars();
488 
489  void createInputField(AW_window *aws, const char *at, const char *aname, int width) const {
490  aws->at(at);
491  aws->create_input_field(loc_awar_name(aname), width);
492  }
493 
494 public:
495  LocationEditor(AW_root *aw_root_, GBDATA *gb_main_, const char *tag_) :
496  tag(ARB_strdup(tag_)),
497  aw_root(aw_root_),
498  gb_main(gb_main_),
499  status(NULp),
500  pos(NULp),
501  pos_changed_cb(NULp)
502  {
503  createAwars();
504  set_status(NULp);
505  }
507  free(tag);
508  free(status);
509  GEN_free_position(pos);
510  }
511 
512  GBDATA *get_gb_main() const { return gb_main; }
513 
514  void add_pos_changed_cb(PosChanged_cb cb) { pos_changed_cb = cb; }
515 
516  const GEN_position *get_pos() const { return pos; }
517  void set_pos(GEN_position*& pos_) {
518  GEN_free_position(pos);
519  pos = pos_;
520  pos_ = NULp; // take ownership
521  set_status(status);
522 
523  if (pos && pos_changed_cb) {
524  pos_changed_cb(aw_root, this);
525  }
526  }
527  void set_status(const char *status_) {
528  if (status != status_) freedup(status, status_);
529  loc_awar(GLE_STATUS)->write_string(status ? status : (pos ? "Ok" : "No data"));
530  }
531 
532  const char *loc_awar_name(const char *aname) const {
533  const int BUFSIZE = 100;
534  static char buf[BUFSIZE];
535 
536  IF_ASSERTION_USED(int printed =) sprintf(buf, "tmp/loc/%s/%s", tag, aname);
537  gen_assert(printed<BUFSIZE);
538 
539  return buf;
540  }
541  AW_awar *loc_awar(const char *aname) const { return aw_root->awar(loc_awar_name(aname)); }
542  const char *awar_charp_value(const char *aname) const { return loc_awar(aname)->read_char_pntr(); }
543 
544  void createEditFields(AW_window *aws);
545 
546  GEN_position *create_GEN_position_from_fields(GB_ERROR& error);
547  void revcomp() {
548  loc_awar(GLE_READABLE)->write_string(GBS_global_string("complement(%s)", awar_charp_value(GLE_READABLE)));
549  }
550 };
551 
552 inline const char *elemOr(ConstStrArray& a, size_t i, const char *Default) {
553  return i<a.size() ? a[i] : Default;
554 }
555 inline char elemOr(const char *a, size_t len, size_t i, char Default) {
556  return i<len ? a[i] : Default;
557 }
558 
560  const char *ipos1 = awar_charp_value(GLE_POS1);
561  const char *ipos2 = awar_charp_value(GLE_POS2);
562  const char *icert1 = awar_charp_value(GLE_CERT1);
563  const char *icert2 = awar_charp_value(GLE_CERT2);
564  const char *icomp = awar_charp_value(GLE_COMPLEMENT);
565 
566  const char *sep = ",; ";
567 
569  GBT_split_string(pos1, ipos1, sep, SPLIT_DROPEMPTY);
570  GBT_split_string(pos2, ipos2, sep, SPLIT_DROPEMPTY);
571 
572  size_t clen1 = strlen(icert1);
573  size_t clen2 = strlen(icert2);
574  size_t clen = strlen(icomp);
575 
576  size_t max_size = pos1.size();
577  bool joinable = loc_awar(GLE_JOINABLE)->read_int();
578 
579  GEN_position *gp = NULp;
580  if (max_size>0) {
581  gp = GEN_new_position(max_size, joinable);
583 
584  for (size_t i = 0; i<max_size; ++i) {
585  const char *p1c = elemOr(pos1, i, "1");
586  size_t p1 = atoi(p1c);
587  size_t p2 = atoi(elemOr(pos2, i, p1c));
588 
589  char c = elemOr(icomp, clen, i, '0');
590  char c1 = elemOr(icert1, clen1, i, '=');
591  char c2 = elemOr(icert2, clen2, i, '=');
592 
593  gen_assert(c1 && c2);
594 
595  gp->start_pos[i] = p1;
596  gp->stop_pos[i] = p2;
597  gp->complement[i] = !!(c-'0');
598  gp->start_uncertain[i] = c1;
599  gp->stop_uncertain[i] = c2;
600  }
601  }
602  else {
603  error = "No data";
604  }
605 
606  return gp;
607 }
608 
609 static int loc_update_running = 0;
610 
612  GB_ERROR error = NULp;
613  if (gp) {
614  try {
615  LocationPtr loc = to_Location(gp);
616  loced->loc_awar(GLE_READABLE)->write_string(loc->as_string().c_str());
617  }
618  catch (const char *& err) { error = GBS_static_string(err); }
619  catch (string& err) { error = GBS_static_string(err.c_str()); }
620  catch (...) { gen_assert(0); }
621  }
622  return error;
623 }
624 
625 
627  // update location according to other fields
628  if (!loc_update_running) {
629  loc_update_running++;
630 
631  GB_ERROR error = NULp;
632  GEN_position *gp = loced->create_GEN_position_from_fields(error);
633 
634  if (!error) {
635  error = update_location_from_GEN_position(loced, gp);
636  }
637 
638  loced->set_pos(gp);
639  loced->set_status(error);
640 
641  loc_update_running--;
642  }
643 }
644 
645 
646 static SmartCharPtr sizetarray2string(const size_t *array, int size) {
647  GBS_strstruct out(size*5);
648  for (int i = 0; i<size; ++i) {
649  out.putlong(array[i]);
650  out.put(' ');
651  }
652  out.cut_tail(1);
653  return out.release();
654 }
655 inline SmartCharPtr dupSizedPart(const unsigned char *in, int size) {
656  const char *in2 = reinterpret_cast<const char*>(in);
657  return ARB_strpartdup(in2, in2+size-1);
658 }
659 inline SmartCharPtr dupComplement(const unsigned char *in, int size) {
660  char *dup = ARB_alloc<char>(size+1);
661  for (int i = 0; i<size; ++i) { // LOOP_VECTORIZED // tested down to gcc 5.5.0 (may fail on older gcc versions)
662  dup[i] = in[i] ? '1' : '0';
663  }
664  dup[size] = 0;
665  return dup;
666 }
667 
669  // update other fields according to location
670  if (!loc_update_running) {
671  loc_update_running++;
672 
673  GB_ERROR error = NULp;
674  const char *locstr = loced->awar_charp_value(GLE_READABLE);
675  GEN_position *gp = NULp;
676 
677  try {
678  LocationPtr loc = parseLocation(locstr);
679  gp = loc->create_GEN_position();
680  }
681  catch (const char *& err) { error = GBS_static_string(err); }
682  catch (string& err) { error = GBS_static_string(err.c_str()); }
683  catch (...) { gen_assert(0); }
684 
685  if (!error) {
688 
692 
693  loced->loc_awar(GLE_JOINABLE)->write_int(gp->parts>1 ? gp->joinable : 1);
694  }
695 
696  loced->set_pos(gp);
697  loced->set_status(error);
698 
699  loc_update_running--;
700  }
701 }
702 
703 static void GLE_revcomp_cb(AW_window*, LocationEditor *loced) {
704  loced->revcomp();
705 }
706 
707 void LocationEditor::createAwars() {
708  RootCallback update_from_detail = makeRootCallback(GLE_update_from_detailFields, this);
709 
710  aw_root->awar_string(loc_awar_name(GLE_POS1), "", gb_main)->add_callback(update_from_detail);
711  aw_root->awar_string(loc_awar_name(GLE_POS2), "", gb_main)->add_callback(update_from_detail);
712  aw_root->awar_string(loc_awar_name(GLE_CERT1), "", gb_main)->add_callback(update_from_detail);
713  aw_root->awar_string(loc_awar_name(GLE_CERT2), "", gb_main)->add_callback(update_from_detail);
714  aw_root->awar_string(loc_awar_name(GLE_COMPLEMENT), "", gb_main)->add_callback(update_from_detail);
715  aw_root->awar_int (loc_awar_name(GLE_JOINABLE), 1, gb_main)->add_callback(update_from_detail);
716  aw_root->awar_string(loc_awar_name(GLE_READABLE), "", gb_main)->add_callback(makeRootCallback(GLE_update_from_location, this));
717  aw_root->awar_string(loc_awar_name(GLE_STATUS), "", gb_main);
718 }
719 
721  createInputField(aws, "pos1", GLE_POS1, POS_WIDTH);
722  createInputField(aws, "cert1", GLE_CERT1, CER_WIDTH);
723  createInputField(aws, "pos2", GLE_POS2, POS_WIDTH);
724  createInputField(aws, "cert2", GLE_CERT2, CER_WIDTH);
725  createInputField(aws, "comp", GLE_COMPLEMENT, CER_WIDTH);
726  createInputField(aws, "loc", GLE_READABLE, LOC_WIDTH);
727  createInputField(aws, "status", GLE_STATUS, LOC_WIDTH);
728 
729  aws->at("rev");
730  aws->callback(makeWindowCallback(GLE_revcomp_cb, this));
731  aws->button_length(8);
732  aws->create_button("REV", "RevComp");
733 
734  aws->at("join");
735  aws->create_toggle(loc_awar_name(GLE_JOINABLE));
736 }
737 
738 static void gene_changed_cb(AW_root *aw_root, LocationEditor *loced) {
739  GBDATA *gb_gene = GEN_get_current_gene(loced->get_gb_main(), aw_root);
740  GEN_position *pos = gb_gene ? GEN_read_position(gb_gene) : NULp;
741 
742  GB_ERROR error = NULp;
743  if (pos) {
745  error = update_location_from_GEN_position(loced, pos);
746  }
747  loced->set_pos(pos);
748  loced->set_status(error);
749 }
750 
751 static void boundloc_changed_cb(AW_root *aw_root, LocationEditor *loced) {
752  GBDATA* gb_main = loced->get_gb_main();
753  const GEN_position *pos = loced->get_pos();
754  gen_assert(pos);
755 
756  GB_push_transaction(gb_main);
757  GBDATA *gb_gene = GEN_get_current_gene(gb_main, aw_root);
758  GB_ERROR error;
759  if (gb_gene) {
760  error = GEN_write_position(gb_gene, pos, 0);
761  }
762  else {
763  error = "That had no effect (no gene is selected)";
764  }
765  GB_end_transaction_show_error(gb_main, error, aw_message);
766 
767  if (error) {
768  gene_changed_cb(aw_root, loced);
769  }
770 }
771 
772 static void gene_create_cb(AW_window *aww, GBDATA *gb_main, LocationEditor *loced) {
774 
775  if (!error) {
776  AW_root *aw_root = aww->get_root();
777  GBDATA *gb_gene_data = get_current_gene_data(gb_main);
778 
779  if (!gb_gene_data) error = "Please select an organism";
780  else {
781  char *dest = aw_root->awar(AWAR_GENE_DEST)->read_string();
782  GBDATA *gb_dest = GEN_find_gene_rel_gene_data(gb_gene_data, dest);
783 
784  if (gb_dest) error = GBS_global_string("Gene '%s' already exists", dest);
785  else {
786  const GEN_position *pos = loced->get_pos();
787 
788  if (!pos) error = "Won't create a gene with invalid position";
789  else {
790  gb_dest = GEN_find_or_create_gene_rel_gene_data(gb_gene_data, dest);
791  if (!gb_dest) error = GB_await_error();
792  else error = GEN_write_position(gb_dest, pos, 0);
793 
794  if (!error) {
795  aw_root->awar(AWAR_GENE_NAME)->write_string(dest);
796  aww->hide();
797  }
798  }
799  }
800 
801  free(dest);
802  }
803  }
804  GB_end_transaction_show_error(gb_main, error, aw_message);
805 
807 }
808 
810  static AW_window_simple *awa[2] = { NULp, NULp};
811  static LocationEditor *le[2] = { NULp, NULp};
812 
813  AW_window_simple*& aws = awa[createGene];
814  LocationEditor*& loced = le[createGene];
815 
816  if (!aws) {
817  gen_assert(gb_main);
818 
819  aws = new AW_window_simple;
820  loced = new LocationEditor(root, gb_main, createGene ? "create" : "edit");
821 
822  if (createGene) aws->init(root, "CREATE_GENE", "GENE CREATE");
823  else aws->init(root, "EDIT_LOCATION", "EDIT LOCATION");
824 
825  aws->load_xfig("ad_gen_create.fig");
826 
827  aws->at("close");
828  aws->callback(AW_POPDOWN);
829  aws->create_button("CLOSE", "Close", "C");
830 
831  aws->at("help");
832  aws->callback(makeHelpCallback("gen_create.hlp"));
833  aws->create_button("HELP", "Help", "H");
834 
835  aws->button_length(NAME_WIDTH);
836 
837  aws->at("organism");
838  aws->create_button(NULp, AWAR_ORGANISM_NAME, NULp, "+");
839 
840  aws->at("gene");
841  if (createGene) {
842  aws->create_input_field(AWAR_GENE_DEST, NAME_WIDTH);
843  }
844  else {
845  aws->create_button(NULp, AWAR_GENE_NAME, NULp, "+");
846  AW_awar *awar_cgene = aws->get_root()->awar(AWAR_COMBINED_GENE_NAME);
847  awar_cgene->add_callback(makeRootCallback(gene_changed_cb, loced));
848  awar_cgene->touch();
849 
851  }
852  aws->button_length(0);
853 
854  loced->createEditFields(aws);
855 
856  if (createGene) {
857  aws->at_shift(0, 30);
858  aws->callback(makeWindowCallback(gene_create_cb, gb_main, loced));
859  aws->create_autosize_button("CREATE", "Create gene", "G");
860  }
861  }
862  return aws;
863 }
866  aws->activate();
867 }
869  return get_gene_create_or_locationEdit_window(root, true, gb_main);
870 }
871 
872 static void gene_delete_cb(AW_window *aww, GBDATA *gb_main) {
873  if (aw_ask_sure("gene_delete", "Are you sure to delete the gene?")) {
874  GB_transaction ta(gb_main);
875  GBDATA *gb_gene = GEN_get_current_gene(gb_main, aww->get_root());
876 
877  GB_ERROR error = gb_gene ? GB_delete(gb_gene) : "Please select a gene first";
878  if (error) {
879  error = ta.close(error);
880  aw_message(error);
881  }
882  }
883 }
884 
886  static BoundItemSel *bis = new BoundItemSel(gb_main, GEN_get_selector());
887  gen_assert(bis->gb_main == gb_main);
888 
889  aws->insert_menu_topic(aws->local_id("gen_reorder_fields"), "Reorder fields ...", "R", "spaf_reorder.hlp", AD_F_ALL, makeCreateWindowCallback(DBUI::create_fields_reorder_window, bis));
890  aws->insert_menu_topic(aws->local_id("gen_delete_field"), "Delete/Hide field ...", "D", "spaf_delete.hlp", AD_F_ALL, makeCreateWindowCallback(DBUI::create_field_delete_window, bis));
891  aws->insert_menu_topic(aws->local_id("gen_create_field"), "Create fields ...", "C", "spaf_create.hlp", AD_F_ALL, makeCreateWindowCallback(DBUI::create_field_create_window, bis));
892  aws->sep______________();
893  aws->insert_menu_topic("gen_unhide_fields", "Show all hidden fields", "S", "scandb.hlp", AD_F_ALL, makeWindowCallback(gene_field_selection_list_unhide_all_cb, gb_main));
894  aws->insert_menu_topic("gen_refresh_fields", "Refresh fields", "f", "scandb.hlp", AD_F_ALL, makeWindowCallback(gene_field_selection_list_update_cb, gb_main));
895 }
896 
897 static AW_window *popup_new_gene_window(AW_root *aw_root, GBDATA *gb_main, int detach_id);
898 
899 static void popup_detached_gene_window(AW_window *aw_parent, const InfoWindow *infoWin) {
901  if (reusable) {
902  reusable->reuse();
903  }
904  else { // create a new window if none is reusable
905  popup_new_gene_window(aw_parent->get_root(),
906  infoWin->get_gbmain(),
908  }
909 }
910 
911 static AW_window *popup_new_gene_window(AW_root *aw_root, GBDATA *gb_main, int detach_id) { // INFO_WINDOW_CREATOR
913  const ItemSelector& itemType = GEN_get_selector();
914 
915  DBUI::init_info_window(aw_root, aws, itemType, detach_id);
916  aws->load_xfig("ad_spec.fig");
917 
918  aws->button_length(8);
919 
920  aws->at("close");
921  aws->callback(AW_POPDOWN);
922  aws->create_button("CLOSE", "CLOSE", "C");
923 
924  aws->at("search");
925  aws->callback(makeCreateWindowCallback(GEN_create_gene_query_window, gb_main));
926  aws->create_button("SEARCH", "SEARCH", "S", "+");
927 
928  aws->at("help");
929  aws->callback(makeHelpCallback("gene_info.hlp"));
930  aws->create_button("HELP", "HELP", "H");
931 
932  DbScanner *scanner = DbScanner::create(gb_main,
933  InfoWindowRegistry::localize_scanner_id("gene", detach_id),
934  aws, "box", "field", "enable", DB_KEYVIEWER, "mark", itemType);
935 
936  const InfoWindow& infoWin = InfoWindowRegistry::infowin.registerInfoWindow(aws, scanner, detach_id);
937 
938  if (infoWin.is_maininfo()) {
939  aws->create_menu("GENE", "G", AD_F_ALL);
940  aws->insert_menu_topic("gene_delete", "Delete", "D", "spa_delete.hlp", AD_F_ALL, makeWindowCallback (gene_delete_cb, gb_main));
941  aws->insert_menu_topic("gene_rename", "Rename ...", "R", "spa_rename.hlp", AD_F_ALL, makeWindowCallback (gene_rename_cb, gb_main));
942  aws->insert_menu_topic("gene_copy", "Copy ...", "y", "spa_copy.hlp", AD_F_ALL, makeWindowCallback (gene_copy_cb, gb_main));
943  aws->insert_menu_topic("gene_create", "Create ...", "C", "gen_create.hlp", AD_F_ALL, makeCreateWindowCallback(create_gene_create_window, gb_main));
944  aws->sep______________();
945  aws->insert_menu_topic("gen_edit_loc", "Edit gene location", "l", "gen_create.hlp", AD_F_ALL, makeWindowCallback (popup_gene_location_editor, gb_main));
946  }
947 
948  aws->create_menu("FIELDS", "F", AD_F_ALL);
949  GEN_create_field_items(aws, gb_main);
950 
951  aws->at("detach");
953 
954  aws->show();
955  infoWin.attach_selected_item();
956 
957  return aws;
958 }
959 
960 void GEN_popup_gene_infowindow(AW_root *aw_root, GBDATA *gb_main) { // @@@ move to SL/DB_UI
961  static AW_window *aws = NULp;
962  if (!aws) {
963  aws = popup_new_gene_window(aw_root, gb_main, InfoWindow::MAIN_WINDOW);
964  }
965  else {
967  }
968 }
969 
970 AW_window *GEN_create_gene_query_window(AW_root *aw_root, GBDATA *gb_main) { // @@@ move to SL/DB_UI
971  static AW_window_simple_menu *aws = NULp;
972 
973  if (!aws) {
974  aws = new AW_window_simple_menu;
975  aws->init(aw_root, "GEN_QUERY", "Gene SEARCH and QUERY");
976  aws->create_menu("More functions", "f");
977  aws->load_xfig("ad_query.fig");
978 
980 
981  awtqs.gb_main = gb_main;
983  awtqs.tree_name = AWAR_TREE;
985  awtqs.use_menu = 1;
986  awtqs.ere_pos_fig = "ere3";
987  awtqs.where_pos_fig = "where3";
988  awtqs.by_pos_fig = "by3";
989  awtqs.qbox_pos_fig = "qbox";
990  awtqs.key_pos_fig = NULp;
991  awtqs.query_pos_fig = "content";
992  awtqs.result_pos_fig = "result";
993  awtqs.count_pos_fig = "count";
994  awtqs.do_query_pos_fig = "doquery";
995  awtqs.config_pos_fig = "doconfig";
996  awtqs.do_mark_pos_fig = "domark";
997  awtqs.do_unmark_pos_fig = "dounmark";
998  awtqs.do_delete_pos_fig = "dodelete";
999  awtqs.do_set_pos_fig = "doset";
1000  awtqs.do_refresh_pos_fig = "dorefresh";
1001  awtqs.open_parser_pos_fig = "openparser";
1003 
1004  QUERY::DbQuery *query = create_query_box(aws, &awtqs, "gen");
1005  GLOBAL_gene_query = query;
1006 
1007  aws->create_menu("More search", "s");
1008  aws->insert_menu_topic("gen_search_equal_fields_within_db", "Search For Equal Fields and Mark Duplicates", "E", "search_duplicates.hlp", AWM_ALL, makeWindowCallback(QUERY::search_duplicated_field_content, query, false));
1009  aws->insert_menu_topic("gen_search_equal_words_within_db", "Search For Equal Words Between Fields and Mark Duplicates", "W", "search_duplicates.hlp", AWM_ALL, makeWindowCallback(QUERY::search_duplicated_field_content, query, true));
1010 
1011  aws->button_length(7);
1012 
1013  aws->at("close");
1014  aws->callback(AW_POPDOWN);
1015  aws->create_button("CLOSE", "CLOSE", "C");
1016 
1017  aws->at("help");
1018  aws->callback(makeHelpCallback("gene_search.hlp"));
1019  aws->create_button("HELP", "HELP", "H");
1020  }
1021 
1022  return aws;
1023 }
GB_ERROR GB_begin_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2528
GB_ERROR GB_copy_dropProtectMarksAndTempstate(GBDATA *dest, GBDATA *source)
Definition: arbdb.cxx:2152
const char * GB_ERROR
Definition: arb_core.h:25
const InfoWindow * find_reusable_of_same_type_as(const InfoWindow &other)
Definition: info_window.h:172
string result
void cut_tail(size_t byte_count)
Definition: arb_strbuf.h:145
static AW_window * get_gene_create_or_locationEdit_window(AW_root *root, bool createGene, GBDATA *gb_main)
unsigned char * complement
Definition: adGene.h:41
void button_length(int length)
Definition: AW_at.cxx:288
GBDATA * GEN_next_gene(GBDATA *gb_gene)
Definition: adGene.cxx:138
size_t size() const
Definition: arb_strarray.h:85
bool GEN_is_organism(GBDATA *gb_species)
Definition: adGene.cxx:721
static void popup_detached_gene_window(AW_window *aw_parent, const InfoWindow *infoWin)
GBDATA * GEN_find_gene_rel_gene_data(GBDATA *gb_gene_data, const char *name)
Definition: adGene.cxx:60
const char * elemOr(ConstStrArray &a, size_t i, const char *Default)
const char * GEN_origin_gene(GBDATA *gb_pseudo)
Definition: adGene.cxx:553
const char * config_pos_fig
Definition: db_query.h:61
AwarName species_name
Definition: db_query.h:42
void insert_menu_topic(const char *id, const char *name, const char *mnemonic, const char *help_text_, AW_active mask, const WindowCallback &wcb)
Definition: AW_window.cxx:595
static void GEN_update_combined_cb(AW_root *awr, GBDATA *gb_main)
GB_ERROR GBT_restore_marked_species(GBDATA *gb_main, const char *stored_marked)
Definition: aditem.cxx:446
GB_ERROR GB_write_string(GBDATA *gbd, const char *s)
Definition: arbdb.cxx:1387
void load_xfig(const char *file, bool resize=true)
Definition: AW_window.cxx:720
void GEN_free_position(GEN_position *pos)
Definition: adGene.cxx:195
void GEN_refresh_all_windows()
Definition: GEN_map.cxx:379
GBDATA * GEN_find_gene(GBDATA *gb_species, const char *name)
Definition: adGene.cxx:64
ItemSelector & ORGANISM_get_selector()
Definition: species.cxx:140
const char * key_pos_fig
Definition: db_query.h:53
static GBDATA * gen_find_gene_by_id(GBDATA *gb_main, const char *id)
static const int MAIN_WINDOW
Definition: info_window.h:67
#define AWAR_ORGANISM_NAME
int allocate_detach_id(const InfoWindow &other)
Definition: info_window.h:160
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
Definition: arbdb.cxx:2561
void at(int x, int y)
Definition: AW_at.cxx:93
#define AWAR_GENE_DEST
const char * ere_pos_fig
Definition: db_query.h:48
const int LOC_WIDTH
NOT4PERL GB_ERROR GBT_with_stored_species(GBDATA *gb_main, const char *stored, species_callback doit, int *clientdata)
Definition: aditem.cxx:404
static GBDATA * first_gene_in_range(GBDATA *gb_gene_data, QUERY_RANGE range)
static int pos1
Definition: ClustalV.cxx:58
static void popup_gene_location_editor(AW_window *aww, GBDATA *gb_main)
int parts
Definition: adGene.h:37
void(* add_selection_changed_cb)(AW_root *aw_root, const RootCallback &cb)
Definition: items.h:77
const char * where_pos_fig
Definition: db_query.h:49
char * ARB_strdup(const char *str)
Definition: arb_string.h:27
void GB_end_transaction_show_error(GBDATA *gbd, GB_ERROR error, void(*error_handler)(GB_ERROR))
Definition: arbdb.cxx:2584
const char * loc_awar_name(const char *aname) const
void gene_field_selection_list_unhide_all_cb(AW_window *, GBDATA *gb_main)
Definition: changekey.cxx:191
DbQuery * create_query_box(AW_window *aws, query_spec *awtqs, const char *query_id)
Definition: db_query.cxx:2354
static QUERY::DbQuery * GLOBAL_gene_query
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:203
const char * result_pos_fig
Definition: db_query.h:57
bool GB_have_error()
Definition: arb_msg.cxx:338
STL namespace.
LocationPtr parseLocation(const string &source)
Definition: Location.cxx:243
void AW_POPDOWN(AW_window *window)
Definition: AW_window.cxx:52
char * release()
Definition: arb_strbuf.h:129
GBDATA * GEN_find_organism(GBDATA *gb_main, const char *name)
Definition: adGene.cxx:728
GBDATA * GEN_expect_gene_data(GBDATA *gb_species)
Definition: adGene.cxx:54
void createEditFields(AW_window *aws)
void GEN_use_uncertainties(GEN_position *pos)
Definition: adGene.cxx:184
char * ARB_strpartdup(const char *start, const char *end)
Definition: arb_string.h:51
const char * open_parser_pos_fig
Definition: db_query.h:66
GBDATA * GB_get_grandfather(GBDATA *gbd)
Definition: arbdb.cxx:1728
static void GLE_update_from_detailFields(AW_root *, LocationEditor *loced)
char buffer[MESSAGE_BUFFERSIZE]
Definition: seq_search.cxx:34
GBDATA * GB_get_father(GBDATA *gbd)
Definition: arbdb.cxx:1722
#define GLE_STATUS
GB_ERROR GB_push_transaction(GBDATA *gbd)
Definition: arbdb.cxx:2494
void activate()
Definition: aw_window.hxx:365
GB_ERROR update_location_from_GEN_position(LocationEditor *loced, const GEN_position *gp)
#define cb(action)
#define GLE_JOINABLE
#define gen_assert(bed)
Definition: GEN_local.hxx:19
AW_awar * add_callback(const RootCallback &cb)
Definition: AW_awar.cxx:231
GB_ERROR GB_delete(GBDATA *&source)
Definition: arbdb.cxx:1916
void gen_restore_old_species_marks(GBDATA *gb_main)
static void auto_select_pseudo_species(AW_root *awr, GBDATA *gb_main, const char *organism, const char *gene)
static AW_window * create_gene_create_window(AW_root *root, GBDATA *gb_main)
GEN_position * create_GEN_position_from_fields(GB_ERROR &error)
static GBDATA * GEN_get_first_gene_data(GBDATA *gb_main, AW_root *aw_root, QUERY_RANGE range)
#define GLE_CERT2
const char * read_char_pntr() const
Definition: AW_awar.cxx:168
void putlong(long l)
Definition: arb_strbuf.h:240
GB_ERROR GB_export_error(const char *error)
Definition: arb_msg.cxx:257
static AW_window * popup_new_gene_window(AW_root *aw_root, GBDATA *gb_main, int detach_id)
#define GLE_COMPLEMENT
void GEN_create_awars(AW_root *aw_root, AW_default aw_def, GBDATA *gb_main)
GB_ERROR GB_await_error()
Definition: arb_msg.cxx:342
GBDATA * get_gb_main() const
static AW_root * SINGLETON
Definition: aw_root.hxx:102
void show()
Definition: AW_window.cxx:1683
static void add_selected_gene_changed_cb(AW_root *aw_root, const RootCallback &cb)
GBDATA * GB_create_container(GBDATA *father, const char *key)
Definition: arbdb.cxx:1829
WindowCallback makeHelpCallback(const char *helpfile)
Definition: aw_window.hxx:106
static GBDATA * next_gene_in_range(GBDATA *gb_prev, QUERY_RANGE range)
SmartCharPtr dupComplement(const unsigned char *in, int size)
void add_pos_changed_cb(PosChanged_cb cb)
void reuse() const
Definition: info_window.h:114
GBDATA * GEN_find_or_create_gene_rel_gene_data(GBDATA *gb_gene_data, const char *name)
Definition: adGene.cxx:100
#define GLE_CERT1
const char * awar_charp_value(const char *aname) const
unsigned char * start_uncertain
Definition: adGene.h:53
virtual std::string as_string() const =0
LocationPtr to_Location(const GEN_position *gp)
Definition: Location.cxx:333
static GB_ERROR gene_copy_handler(const char *dest, GBDATA *gb_main)
static void GEN_species_name_changed_cb(AW_root *awr, GBDATA *gb_main)
static GBDATA * get_current_gene_data(GBDATA *gb_main)
GBDATA * get_gbmain() const
Definition: info_window.h:85
void create_menu(const char *name, const char *mnemonic, AW_active mask=AWM_ALL)
Definition: AW_window.cxx:472
const char * qbox_pos_fig
Definition: db_query.h:52
size_t * stop_pos
Definition: adGene.h:40
const int CER_WIDTH
void init_info_window(AW_root *aw_root, AW_window_simple_menu *aws, const ItemSelector &itemType, int detach_id)
Definition: info_window.cxx:36
void touch()
Definition: AW_awar.cxx:207
GBDATA * GEN_next_marked_organism(GBDATA *gb_organism)
Definition: adGene.cxx:773
static void error(const char *msg)
Definition: mkptypes.cxx:96
GBDATA * GB_get_root(GBDATA *gbd)
Definition: arbdb.cxx:1740
#define AWAR_TREE
AW_window * GEN_create_gene_query_window(AW_root *aw_root, GBDATA *gb_main)
static void GEN_create_field_items(AW_window *aws, GBDATA *gb_main)
static InfoWindowRegistry infowin
Definition: info_window.h:187
const char * GEN_origin_organism(GBDATA *gb_pseudo)
Definition: adGene.cxx:549
static void reactivate(AW_window *aww)
Definition: info_window.h:189
#define AWAR_SPECIES_NAME
const char * count_pos_fig
Definition: db_query.h:58
GBDATA * GEN_next_organism(GBDATA *gb_organism)
Definition: adGene.cxx:745
void attach_selected_item() const
Definition: info_window.h:110
GB_ERROR GEN_write_position(GBDATA *gb_gene, const GEN_position *pos, long seqLength)
Definition: adGene.cxx:325
bool is_maininfo() const
Definition: info_window.h:82
GEN_position * create_GEN_position() const
Definition: Location.cxx:309
static DbScanner * create(GBDATA *gb_main, const char *scanner_id, AW_window *aws, const char *box_pos_fig, const char *edit_pos_fig, const char *edit_enable_pos_fig, DB_SCANNERMODE scannermode, const char *mark_pos_fig, ItemSelector &selector)
Definition: db_scanner.cxx:227
const char * by_pos_fig
Definition: db_query.h:50
LocationEditor(AW_root *aw_root_, GBDATA *gb_main_, const char *tag_)
char * read_string() const
Definition: AW_awar.cxx:198
const int NAME_WIDTH
static void gene_delete_cb(AW_window *aww, GBDATA *gb_main)
AW_awar * awar(const char *awar)
Definition: AW_root.cxx:554
static int pos2
Definition: ClustalV.cxx:59
static BasicStatus status
#define GENOM_ALIGNMENT
Definition: adGene.h:19
GBDATA * GBT_find_sequence(GBDATA *gb_species, const char *aliname)
Definition: adali.cxx:708
AW_window * create_fields_reorder_window(AW_root *root, BoundItemSel *bound_selector)
Definition: ui_species.cxx:590
char * GBT_read_gene_sequence(GBDATA *gb_gene, bool use_revComplement, char partSeparator)
Definition: adali.cxx:1062
#define CHANGE_KEY_PATH_GENES
Definition: arbdbt.h:87
void search_duplicated_field_content(AW_window *dummy, DbQuery *query, bool tokenize)
Definition: db_query.cxx:1191
#define AWAR_GENE_CONTENT
static void gene_create_cb(AW_window *aww, GBDATA *gb_main, LocationEditor *loced)
#define AWAR_COMBINED_GENE_NAME
Definition: GEN_local.hxx:23
QUERY_RANGE
Definition: items.h:41
static char * old_species_marks
GEN_position * GEN_new_position(int parts, bool joinable)
Definition: adGene.cxx:155
bool aw_ask_sure(const char *unique_id, const char *msg)
SmartCharPtr dupSizedPart(const unsigned char *in, int size)
AW_awar * loc_awar(const char *aname) const
void create_input_field(const char *awar_name, int columns=0)
Definition: AW_button.cxx:857
static void gene_changed_cb(AW_root *aw_root, LocationEditor *loced)
#define AD_F_ALL
const int POS_WIDTH
#define IF_ASSERTION_USED(x)
Definition: arb_assert.h:308
popup_info_window_cb popup_info_window
Definition: db_query.h:69
GB_ERROR close(GB_ERROR error)
Definition: arbdbpp.cxx:35
ItemSelector & GEN_get_selector()
void GB_write_flag(GBDATA *gbd, long flag)
Definition: arbdb.cxx:2773
GBDATA * GEN_find_origin_organism(GBDATA *gb_pseudo, const GB_HASH *organism_hash)
Definition: adGene.cxx:643
char * ARB_strndup(const char *start, int len)
Definition: arb_string.h:83
GB_ERROR GBT_write_string(GBDATA *gb_container, const char *fieldpath, const char *content)
Definition: adtools.cxx:451
AW_window * create_field_create_window(AW_root *root, BoundItemSel *bound_selector)
Definition: ui_species.cxx:787
const char * do_mark_pos_fig
Definition: db_query.h:62
static GBDATA * GEN_get_next_gene_data(GBDATA *gb_gene_data, QUERY_RANGE range)
static void gene_copy_cb(AW_window *aww, GBDATA *gb_main)
GBDATA * gb_main
Definition: items.h:86
const char * GBS_static_string(const char *str)
Definition: arb_msg.cxx:212
AW_window * create_field_delete_window(AW_root *root, BoundItemSel *bound_selector)
Definition: ui_species.cxx:720
static void refresh_displayed_genes()
const char * query_pos_fig
Definition: db_query.h:54
#define AWAR_GENE_NAME
Definition: GEN.hxx:33
void aw_message(const char *msg)
Definition: AW_status.cxx:1142
static void gene_rename_cb(AW_window *aww, GBDATA *gb_main)
size_t * start_pos
Definition: adGene.h:39
const char * do_query_pos_fig
Definition: db_query.h:60
void hide()
Definition: AW_window.cxx:1835
static void GLE_update_from_location(AW_root *, LocationEditor *loced)
static SmartCharPtr sizetarray2string(const size_t *array, int size)
void add_detach_area(detached_uppopper popup_detached_cb) const
AW_root * get_root()
Definition: aw_window.hxx:359
void gene_field_selection_list_update_cb(AW_window *, GBDATA *gb_main)
Definition: changekey.cxx:192
#define NULp
Definition: cxxforward.h:116
GBDATA * GBT_find_species(GBDATA *gb_main, const char *name)
Definition: aditem.cxx:139
#define GLE_POS1
GB_ERROR write_string(const char *aw_string)
void GBT_split_string(ConstStrArray &dest, const char *namelist, const char *separator, SplitMode mode)
Definition: arb_strarray.h:223
void sep______________()
Definition: AW_window.cxx:753
#define GB_USERFLAG_QUERY
Definition: arbdb.h:55
const char * local_id(const char *id) const
Definition: AW_window.cxx:747
static char * gen_get_gene_id(GBDATA *, GBDATA *gb_gene)
void set_pos(GEN_position *&pos_)
char * GBT_store_marked_species(GBDATA *gb_main, bool unmark_all)
Definition: aditem.cxx:377
GBDATA * GB_first_marked(GBDATA *gbd, const char *keystring)
Definition: adquery.cxx:655
static GB_ERROR gene_rename_handler(const char *dest, GBDATA *gb_main)
void GEN_popup_gene_infowindow(AW_root *aw_root, GBDATA *gb_main)
static struct MutableItemSelector GEN_item_selector
GB_transaction ta(gb_var)
void callback(const WindowCallback &cb)
Definition: AW_window.cxx:133
bool joinable
Definition: adGene.h:38
#define BUFSIZE
GBDATA * gb_main
Definition: db_query.h:39
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
Definition: arbdb.cxx:904
GBDATA * gb_main
Definition: adname.cxx:32
GB_ERROR GEN_organism_not_found(GBDATA *gb_pseudo)
Definition: adGene.cxx:565
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:570
const GEN_position * get_pos() const
GBDATA * GEN_next_marked_gene(GBDATA *gb_gene)
Definition: adGene.cxx:146
GBDATA * GEN_first_marked_organism(GBDATA *gb_main)
Definition: adGene.cxx:767
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
Definition: adquery.cxx:531
GBDATA * GEN_first_organism(GBDATA *gb_main)
Definition: adGene.cxx:739
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
Definition: aditem.cxx:459
const char * do_set_pos_fig
Definition: db_query.h:65
GEN_position * GEN_read_position(GBDATA *gb_gene)
Definition: adGene.cxx:250
bool GEN_is_pseudo_gene_species(GBDATA *gb_species)
Definition: adGene.cxx:558
static int loc_update_running
GBDATA * GEN_first_marked_pseudo_species(GBDATA *gb_main)
Definition: adGene.cxx:711
#define GLE_READABLE
static GBDATA * GEN_get_current_gene(GBDATA *gb_main, AW_root *aw_root)
AwarName tree_name
Definition: db_query.h:43
GBDATA * GEN_get_current_organism(GBDATA *gb_main)
GB_ERROR GEN_mark_organism_or_corresponding_organism(GBDATA *gb_species, int *)
GB_ERROR write_int(long aw_int)
const MutableBoundItemSel BoundItemSel
Definition: items.h:106
void set_status(const char *status_)
GBDATA * GEN_first_gene_rel_gene_data(GBDATA *gb_gene_data)
Definition: adGene.cxx:134
const InfoWindow & registerInfoWindow(AW_window *aww, DbScanner *scanner, int detach_id)
Definition: info_window.h:142
static void boundloc_changed_cb(AW_root *aw_root, LocationEditor *loced)
void init(AW_root *root, const char *wid, const char *windowname)
Definition: AW_window.cxx:2845
const char * do_delete_pos_fig
Definition: db_query.h:64
const char * do_unmark_pos_fig
Definition: db_query.h:63
char * GBS_global_string_copy(const char *templat,...)
Definition: arb_msg.cxx:194
GBDATA * GEN_find_pseudo_species(GBDATA *gb_main, const char *organism_name, const char *gene_name, const GB_HASH *pseudo_hash)
Definition: adGene.cxx:613
const char * do_refresh_pos_fig
Definition: db_query.h:67
static void GEN_update_GENE_CONTENT(GBDATA *gb_main, AW_root *awr)
static const char * localize_scanner_id(const char *scanner_id, int detach_id)
Definition: info_window.h:195
void put(char c)
Definition: arb_strbuf.h:174
void create_button(const char *macro_name, AW_label label, const char *mnemonic=NULp, const char *color=NULp)
Definition: AW_button.cxx:448
#define GLE_POS2
unsigned char * stop_uncertain
Definition: adGene.h:54
static void GLE_revcomp_cb(AW_window *, LocationEditor *loced)
static void GEN_select_gene(GBDATA *, AW_root *aw_root, const char *item_name)
void AWT_activate_prompt(const char *title, const char *prompt, const char *defaultResult, const char *button, const ResultHandler &handle_result, const char *helpfile, const char *srt)
Definition: AWT_prompt.cxx:62