38 #define AWAR_GENE_DEST "tmp/gene/dest"
42 #define AD_F_ALL AWM_ALL // @@@ replace all occurrences of AD_F_ALL by AWM_ALL
48 char *gene = strchr(organism,
'/');
55 else if (!item_name[0]) {
72 char *gene = strchr(organism,
'/');
110 if (old_species_marks) {
112 freenull(old_species_marks);
296 const int prefix_len = 10;
298 if (strncmp(gene_name,
"intergene_", prefix_len) == 0) {
299 char *start_pos_ptr = gene_name+prefix_len;
300 char *end_pos_ptr = strchr(start_pos_ptr,
'_');
305 long start_pos = atol(start_pos_ptr);
306 long end_pos = atol(end_pos_ptr);
315 long len = end_pos-start_pos+1;
339 if (strcmp(combined, old_combined) != 0) {
386 if (strcmp(source, dest) != 0) {
392 if (!gb_gene_data) error =
"Please select an organism";
393 else if (!dest[0]) error =
"empty name not possible";
398 if (!gb_source) error =
"Please select a gene";
425 if (!gb_gene_data) error =
"Please select an organism";
426 else if (!dest[0]) error =
"empty name not possible";
431 if (!gb_source) error =
"Please select a gene";
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"
485 PosChanged_cb pos_changed_cb;
489 void createInputField(
AW_window *aws,
const char *at,
const char *aname,
int width)
const {
523 if (pos && pos_changed_cb) {
524 pos_changed_cb(aw_root,
this);
528 if (status != status_) freedup(status, status_);
529 loc_awar(
GLE_STATUS)->write_string(status ? status : (pos ?
"Ok" :
"No data"));
542 const char *
awar_charp_value(
const char *aname)
const {
return loc_awar(aname)->read_char_pntr(); }
553 return i<a.
size() ? a[i] : Default;
555 inline char elemOr(
const char *a,
size_t len,
size_t i,
char Default) {
556 return i<len ? a[i] : Default;
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);
566 const char *sep =
",; ";
572 size_t clen1 = strlen(icert1);
573 size_t clen2 = strlen(icert2);
574 size_t clen = strlen(icomp);
576 size_t max_size = pos1.
size();
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));
589 char c =
elemOr(icomp, clen, i,
'0');
590 char c1 =
elemOr(icert1, clen1, i,
'=');
591 char c2 =
elemOr(icert2, clen2, i,
'=');
628 if (!loc_update_running) {
629 loc_update_running++;
641 loc_update_running--;
648 for (
int i = 0; i<size; ++i) {
656 const char *in2 =
reinterpret_cast<const char*
>(in);
660 char *dup = ARB_alloc<char>(size+1);
661 for (
int i = 0; i<size; ++i) {
662 dup[i] = in[i] ?
'1' :
'0';
670 if (!loc_update_running) {
671 loc_update_running++;
699 loc_update_running--;
707 void LocationEditor::createAwars() {
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);
715 aw_root->awar_int (loc_awar_name(
GLE_JOINABLE), 1,
gb_main)->add_callback(update_from_detail);
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);
727 createInputField(aws,
"status",
GLE_STATUS, LOC_WIDTH);
763 error =
"That had no effect (no gene is selected)";
779 if (!gb_gene_data) error =
"Please select an organism";
788 if (!pos) error =
"Won't create a gene with invalid position";
810 static AW_window_simple *awa[2] = {
NULp,
NULp};
813 AW_window_simple*& aws = awa[createGene];
819 aws =
new AW_window_simple;
820 loced =
new LocationEditor(root, gb_main, createGene ?
"create" :
"edit");
822 if (createGene) aws->init(root,
"CREATE_GENE",
"GENE CREATE");
823 else aws->init(root,
"EDIT_LOCATION",
"EDIT LOCATION");
825 aws->load_xfig(
"ad_gen_create.fig");
829 aws->create_button(
"CLOSE",
"Close",
"C");
833 aws->create_button(
"HELP",
"Help",
"H");
835 aws->button_length(NAME_WIDTH);
852 aws->button_length(0);
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");
873 if (
aw_ask_sure(
"gene_delete",
"Are you sure to delete the gene?")) {
879 error = ta.
close(error);
934 aws,
"box",
"field",
"enable",
DB_KEYVIEWER,
"mark", itemType);
975 aws->
init(aw_root,
"GEN_QUERY",
"Gene SEARCH and QUERY");
1005 GLOBAL_gene_query = query;
GB_ERROR GB_begin_transaction(GBDATA *gbd)
GB_ERROR GB_copy_dropProtectMarksAndTempstate(GBDATA *dest, GBDATA *source)
const InfoWindow * find_reusable_of_same_type_as(const InfoWindow &other)
void cut_tail(size_t byte_count)
static AW_window * get_gene_create_or_locationEdit_window(AW_root *root, bool createGene, GBDATA *gb_main)
unsigned char * complement
void button_length(int length)
GBDATA * GEN_next_gene(GBDATA *gb_gene)
bool GEN_is_organism(GBDATA *gb_species)
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)
const char * elemOr(ConstStrArray &a, size_t i, const char *Default)
const char * GEN_origin_gene(GBDATA *gb_pseudo)
const char * config_pos_fig
void insert_menu_topic(const char *id, const char *name, const char *mnemonic, const char *help_text_, AW_active mask, const WindowCallback &wcb)
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)
GB_ERROR GB_write_string(GBDATA *gbd, const char *s)
void load_xfig(const char *file, bool resize=true)
void GEN_free_position(GEN_position *pos)
void GEN_refresh_all_windows()
GBDATA * GEN_find_gene(GBDATA *gb_species, const char *name)
ItemSelector & ORGANISM_get_selector()
static GBDATA * gen_find_gene_by_id(GBDATA *gb_main, const char *id)
static const int MAIN_WINDOW
#define AWAR_ORGANISM_NAME
int allocate_detach_id(const InfoWindow &other)
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
NOT4PERL GB_ERROR GBT_with_stored_species(GBDATA *gb_main, const char *stored, species_callback doit, int *clientdata)
static GBDATA * first_gene_in_range(GBDATA *gb_gene_data, QUERY_RANGE range)
static void popup_gene_location_editor(AW_window *aww, GBDATA *gb_main)
void(* add_selection_changed_cb)(AW_root *aw_root, const RootCallback &cb)
const char * where_pos_fig
char * ARB_strdup(const char *str)
void GB_end_transaction_show_error(GBDATA *gbd, GB_ERROR error, void(*error_handler)(GB_ERROR))
const char * loc_awar_name(const char *aname) const
void gene_field_selection_list_unhide_all_cb(AW_window *, GBDATA *gb_main)
DbQuery * create_query_box(AW_window *aws, query_spec *awtqs, const char *query_id)
static QUERY::DbQuery * GLOBAL_gene_query
const char * GBS_global_string(const char *templat,...)
const char * result_pos_fig
LocationPtr parseLocation(const string &source)
void AW_POPDOWN(AW_window *window)
GBDATA * GEN_find_organism(GBDATA *gb_main, const char *name)
GBDATA * GEN_expect_gene_data(GBDATA *gb_species)
void createEditFields(AW_window *aws)
void GEN_use_uncertainties(GEN_position *pos)
char * ARB_strpartdup(const char *start, const char *end)
const char * open_parser_pos_fig
GBDATA * GB_get_grandfather(GBDATA *gbd)
static void GLE_update_from_detailFields(AW_root *, LocationEditor *loced)
char buffer[MESSAGE_BUFFERSIZE]
GBDATA * GB_get_father(GBDATA *gbd)
GB_ERROR GB_push_transaction(GBDATA *gbd)
GB_ERROR update_location_from_GEN_position(LocationEditor *loced, const GEN_position *gp)
AW_awar * add_callback(const RootCallback &cb)
GB_ERROR GB_delete(GBDATA *&source)
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)
const char * read_char_pntr() const
GB_ERROR GB_export_error(const char *error)
static AW_window * popup_new_gene_window(AW_root *aw_root, GBDATA *gb_main, int detach_id)
void GEN_create_awars(AW_root *aw_root, AW_default aw_def, GBDATA *gb_main)
GB_ERROR GB_await_error()
GBDATA * get_gb_main() const
static AW_root * SINGLETON
static void add_selected_gene_changed_cb(AW_root *aw_root, const RootCallback &cb)
GBDATA * GB_create_container(GBDATA *father, const char *key)
WindowCallback makeHelpCallback(const char *helpfile)
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)
GBDATA * GEN_find_or_create_gene_rel_gene_data(GBDATA *gb_gene_data, const char *name)
const char * awar_charp_value(const char *aname) const
unsigned char * start_uncertain
virtual std::string as_string() const =0
LocationPtr to_Location(const GEN_position *gp)
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
void create_menu(const char *name, const char *mnemonic, AW_active mask=AWM_ALL)
const char * qbox_pos_fig
void init_info_window(AW_root *aw_root, AW_window_simple_menu *aws, const ItemSelector &itemType, int detach_id)
GBDATA * GEN_next_marked_organism(GBDATA *gb_organism)
static void error(const char *msg)
GBDATA * GB_get_root(GBDATA *gbd)
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
const char * GEN_origin_organism(GBDATA *gb_pseudo)
static void reactivate(AW_window *aww)
#define AWAR_SPECIES_NAME
const char * count_pos_fig
GBDATA * GEN_next_organism(GBDATA *gb_organism)
void attach_selected_item() const
GB_ERROR GEN_write_position(GBDATA *gb_gene, const GEN_position *pos, long seqLength)
GEN_position * create_GEN_position() const
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)
LocationEditor(AW_root *aw_root_, GBDATA *gb_main_, const char *tag_)
char * read_string() const
static void gene_delete_cb(AW_window *aww, GBDATA *gb_main)
AW_awar * awar(const char *awar)
static BasicStatus status
GBDATA * GBT_find_sequence(GBDATA *gb_species, const char *aliname)
AW_window * create_fields_reorder_window(AW_root *root, BoundItemSel *bound_selector)
char * GBT_read_gene_sequence(GBDATA *gb_gene, bool use_revComplement, char partSeparator)
#define CHANGE_KEY_PATH_GENES
void search_duplicated_field_content(AW_window *dummy, DbQuery *query, bool tokenize)
#define AWAR_GENE_CONTENT
static void gene_create_cb(AW_window *aww, GBDATA *gb_main, LocationEditor *loced)
#define AWAR_COMBINED_GENE_NAME
static char * old_species_marks
GEN_position * GEN_new_position(int parts, bool joinable)
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)
static void gene_changed_cb(AW_root *aw_root, LocationEditor *loced)
#define IF_ASSERTION_USED(x)
popup_info_window_cb popup_info_window
GB_ERROR close(GB_ERROR error)
ItemSelector & GEN_get_selector()
void GB_write_flag(GBDATA *gbd, long flag)
GBDATA * GEN_find_origin_organism(GBDATA *gb_pseudo, const GB_HASH *organism_hash)
char * ARB_strndup(const char *start, int len)
GB_ERROR GBT_write_string(GBDATA *gb_container, const char *fieldpath, const char *content)
AW_window * create_field_create_window(AW_root *root, BoundItemSel *bound_selector)
const char * do_mark_pos_fig
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)
const char * GBS_static_string(const char *str)
AW_window * create_field_delete_window(AW_root *root, BoundItemSel *bound_selector)
static void refresh_displayed_genes()
const char * query_pos_fig
void aw_message(const char *msg)
static void gene_rename_cb(AW_window *aww, GBDATA *gb_main)
const char * do_query_pos_fig
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
void gene_field_selection_list_update_cb(AW_window *, GBDATA *gb_main)
GBDATA * GBT_find_species(GBDATA *gb_main, const char *name)
GB_ERROR write_string(const char *aw_string)
void GBT_split_string(ConstStrArray &dest, const char *namelist, const char *separator, SplitMode mode)
#define GB_USERFLAG_QUERY
const char * local_id(const char *id) const
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)
GBDATA * GB_first_marked(GBDATA *gbd, const char *keystring)
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)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
GB_ERROR GEN_organism_not_found(GBDATA *gb_pseudo)
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
const GEN_position * get_pos() const
GBDATA * GEN_next_marked_gene(GBDATA *gb_gene)
GBDATA * GEN_first_marked_organism(GBDATA *gb_main)
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
GBDATA * GEN_first_organism(GBDATA *gb_main)
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
const char * do_set_pos_fig
GEN_position * GEN_read_position(GBDATA *gb_gene)
bool GEN_is_pseudo_gene_species(GBDATA *gb_species)
static int loc_update_running
GBDATA * GEN_first_marked_pseudo_species(GBDATA *gb_main)
static GBDATA * GEN_get_current_gene(GBDATA *gb_main, AW_root *aw_root)
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
void set_status(const char *status_)
GBDATA * GEN_first_gene_rel_gene_data(GBDATA *gb_gene_data)
const InfoWindow & registerInfoWindow(AW_window *aww, DbScanner *scanner, int detach_id)
static void boundloc_changed_cb(AW_root *aw_root, LocationEditor *loced)
const char * do_delete_pos_fig
const char * do_unmark_pos_fig
char * GBS_global_string_copy(const char *templat,...)
GBDATA * GEN_find_pseudo_species(GBDATA *gb_main, const char *organism_name, const char *gene_name, const GB_HASH *pseudo_hash)
const char * do_refresh_pos_fig
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)
void create_button(const char *macro_name, AW_label label, const char *mnemonic=NULp, const char *color=NULp)
unsigned char * stop_uncertain
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)