27 #define AWAR_MERGE_GENE_SPECIES_SAV AWAR_MERGE_SAV "gene_species/"
28 #define AWAR_MERGE_GENE_SPECIES_TMP AWAR_MERGE_TMP "gene_species/"
32 #define AWAR_MERGE_GENE_SPECIES_CURRENT_FIELD AWAR_MERGE_GENE_SPECIES_TMP "current"
33 #define AWAR_MERGE_GENE_SPECIES_DEST AWAR_MERGE_GENE_SPECIES_TMP "dest"
34 #define AWAR_MERGE_GENE_SPECIES_SOURCE AWAR_MERGE_GENE_SPECIES_TMP "source"
35 #define AWAR_MERGE_GENE_SPECIES_METHOD AWAR_MERGE_GENE_SPECIES_TMP "method"
36 #define AWAR_MERGE_GENE_SPECIES_ACI AWAR_MERGE_GENE_SPECIES_TMP "aci"
37 #define AWAR_MERGE_GENE_SPECIES_EXAMPLE AWAR_MERGE_GENE_SPECIES_TMP "example"
38 #define AWAR_MERGE_GENE_SPECIES_FIELDS_SAVE AWAR_MERGE_GENE_SPECIES_TMP "save" // only used to save/load config
41 #define AWAR_MERGE_GENE_SPECIES_CREATE_FIELDS AWAR_MERGE_GENE_SPECIES_SAV "activated"
42 #define AWAR_MERGE_GENE_SPECIES_FIELDS_DEFS AWAR_MERGE_GENE_SPECIES_SAV "field_defs"
80 inline const char *
field_awar(
const char *field_name,
const char *subfield) {
93 static char *cur_field =
NULp;
97 if (cur_field[0])
return field_awar(cur_field, subfield);
135 if (origins_field[0]) {
145 error =
"Specify a 'Source field'";
150 char *aci_result =
NULp;
168 if (aci_result) freeset(result, aci_result);
171 if (error) freenull(result);
187 char *
start = existing_definitions+1;
189 mg_assert(existing_definitions[0] ==
';');
192 while (!error && start[0]) {
193 char *end = strchr(start,
';');
194 if (!end) end = strchr(start, 0);
216 long error_seen = error_suppressor ?
GBS_read_hash(error_suppressor, error) : 0;
217 #define MAX_EQUAL_WARNINGS 10
226 if (error_suppressor) {
241 free(existing_definitions);
265 if (!curr_species || !curr_species[0]) error =
"No species selected.";
270 if (!gb_species) error =
GB_export_errorf(
"No such species: '%s'", curr_species);
277 if (!error && !result) error =
"no result";
288 aw_message(
"rules writing to 'name' or 'acc' are not allowed.");
307 const char *awar_name =
field_awar(cur_field,
"source");
317 int method = aw_root->
awar_int(awar_name, def_method, MG_props)->
read_int();
343 aw_message(
"Source field is not used with this method");
364 mg_assert(existing_definitions[0] ==
';');
366 if (!strstr(existing_definitions, search)) {
373 free(existing_definitions);
403 mg_assert(existing_definitions[0] ==
';');
405 char *found = strstr(existing_definitions, search);
408 strcpy(found, found+strlen(cur_field)+1);
413 free(existing_definitions);
435 geneSpecFieldList->
clear();
439 char *
start = existing_definitions+1;
441 mg_assert(existing_definitions[0] ==
';');
444 char *end = strchr(start,
';');
445 if (!end) end = strchr(start, 0);
451 geneSpecFieldList->
insert(start, start);
455 free(existing_definitions);
459 geneSpecFieldList->
update();
463 char *
start = existing_definitions+1;
464 mg_assert(existing_definitions[0] ==
';');
466 for (
int count = 0; start[0]; ++count) {
467 char *end = strchr(start,
';');
468 if (!end) end = strchr(start, 0);
476 #define add_config(s, id) cdef.add(field_awar(s, id), id, count)
503 char *sub_config = cdef.
read();
507 free(existing_definitions);
513 return sub_cdef.
read();
527 sub_cdef.
write(stored_string);
540 cdef.
write(sub_config);
543 free(existing_definitions);
550 static AW_window_simple *aws =
NULp;
553 aws =
new AW_window_simple;
554 aws->init(aw_root,
"DEFINE_GENE_SPECIES_FIELDS",
"DEFINE FIELDS EXPORTED WITH GENE SPECIES");
555 aws->load_xfig(
"merge/mg_def_gene_species_fields.fig");
559 aws->create_button(
"CLOSE",
"CLOSE",
"C");
563 aws->create_button(
"HELP",
"HELP");
573 aws->create_button(
"DELETE",
"DELETE");
575 aws->at(
"sel_method");
580 aws->update_toggle_field();
#define AWAR_MERGE_GENE_SPECIES_FIELDS_DEFS
static void init_gene_species_xfer_fields_config(AWT_config_definition &cdef)
void add(const char *awar_name, const char *config_name)
void MG_create_gene_species_awars(AW_root *aw_root, AW_default aw_def)
const char * GEN_origin_gene(GBDATA *gb_pseudo)
#define AWAR_MERGE_GENE_SPECIES_FIELDS_SAVE
void insert_default(const char *displayed, const AW_scalar &value)
long GBS_incr_hash(GB_HASH *hs, const char *key)
#define AWAR_MERGE_GENE_SPECIES_CURRENT_FIELD
int ARB_stricmp(const char *s1, const char *s2)
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)
char * GB_read_as_string(GBDATA *gbd)
const char * GBS_global_string(const char *templat,...)
static void MG_aci_changed_cb(AW_root *aw_root)
void AW_POPDOWN(AW_window *window)
#define AWAR_MERGE_GENE_SPECIES_CREATE_FIELDS
const char * current_field_awar(AW_root *aw_root, const char *subfield)
#define MAX_EQUAL_WARNINGS
#define AWAR_MERGE_GENE_SPECIES_ACI
GB_ERROR MG_export_fields(AW_root *aw_root, GBDATA *gb_src, GBDATA *gb_dst, GB_HASH *error_suppressor, GB_HASH *source_organism_hash)
static void MG_dest_field_changed_cb(AW_root *aw_root)
char buffer[MESSAGE_BUFFERSIZE]
AW_awar * add_callback(const RootCallback &cb)
void insert(const char *displayed, const AW_scalar &value)
static char * MG_create_field_content(GBDATA *gb_species, CreationMethod method, const char *origins_field, const char *aci, GB_ERROR &error, GB_HASH *organism_hash)
#define add_config(s, id)
static HelixNrInfo * start
GB_ERROR GB_await_error()
static AW_root * SINGLETON
#define AWAR_MERGE_GENE_SPECIES_DEST
WindowCallback makeHelpCallback(const char *helpfile)
AW_window * MG_gene_species_create_field_transfer_def_window(AW_root *aw_root)
static void MG_method_changed_cb(AW_root *aw_root)
static void create_awars_for_field(const char *cur_field)
#define AWAR_MERGE_GENE_SPECIES_SAV
static AW_default MG_props
#define AWAR_MERGE_GENE_SPECIES_METHOD
static void error(const char *msg)
const char * field_awar(const char *field_name, const char *subfield)
char * strcpydest(char *dest, const char *src)
const char * GEN_origin_organism(GBDATA *gb_pseudo)
static void load_or_reset_gene_species_xfer_fields(const char *stored_string, AW_selection_list *geneSpecFieldList)
static char * MG_create_current_field_content(AW_root *aw_root, GBDATA *gb_species, GB_ERROR &error)
char * read_string() const
AW_awar * awar(const char *awar)
static void MG_delete_selected_field_def(AW_window *aww)
static void MG_current_field_def_changed_cb(AW_root *aw_root)
#define AWAR_MERGE_GENE_SPECIES_SOURCE
GB_ERROR GB_export_errorf(const char *templat,...)
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
static void MG_update_selection_list_on_field_transfers(AW_root *aw_root, AW_selection_list *geneSpecFieldList)
GBDATA * GEN_find_origin_organism(GBDATA *gb_pseudo, const GB_HASH *organism_hash)
GB_ERROR GBT_write_string(GBDATA *gb_container, const char *fieldpath, const char *content)
#define AWAR_MERGE_GENE_SPECIES_EXAMPLE
static char * store_gene_species_xfer_fields()
static void MG_update_example(AW_root *aw_root)
static void init_gene_species_xfer_fields_subconfig(AWT_config_definition &cdef, char *existing_definitions)
static void check_and_correct_current_field(char *&cur_field)
void aw_message(const char *msg)
GBDATA * GBT_find_species(GBDATA *gb_main, const char *name)
static bool allow_callbacks
GB_ERROR write_string(const char *aw_string)
NOT4PERL char * GB_command_interpreter_in_env(const char *str, const char *commands, const GBL_call_env &callEnv)
static void MG_source_field_changed_cb(AW_root *aw_root)
GB_transaction ta(gb_var)
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
bool GEN_is_pseudo_gene_species(GBDATA *gb_species)
GB_ERROR write_int(long aw_int)
long GBS_read_hash(const GB_HASH *hs, const char *key)
GBDATA * GB_entry(GBDATA *father, const char *key)
void aw_message_if(GB_ERROR error)
char * GBS_global_string_copy(const char *templat,...)
void GBS_optimize_hash(const GB_HASH *hs)
void write(const char *cfgStr) const
GBDATA * GEN_find_origin_gene(GBDATA *gb_pseudo, const GB_HASH *organism_hash)
const char * MG_left_AWAR_SPECIES_NAME()