33 #define AWAR_SPECIES_SRC AWAR_MERGE_TMP_SRC "name"
34 #define AWAR_FIELD_SRC AWAR_MERGE_TMP_SRC "field"
35 #define AWAR_TAG_SRC AWAR_MERGE_TMP_SRC "tag"
37 #define AWAR_SPECIES_DST AWAR_MERGE_TMP_DST "name"
38 #define AWAR_FIELD_DST AWAR_MERGE_TMP_DST "field"
39 #define AWAR_TAG_DST AWAR_MERGE_TMP_DST "tag"
41 #define AWAR_TAG_DEL AWAR_MERGE_TMP "tagdel"
42 #define AWAR_APPEND AWAR_MERGE_TMP "append"
44 #define AWAR_SPECIES_XFER_TYPE AWAR_MERGE_SAV "xferType"
45 #define AWAR_SPECIES_XFER_SCOPE AWAR_MERGE_SAV "xferScope"
46 #define AWAR_SPECIES_XFER_FTS AWAR_MERGE_SAV "fts"
89 scanner->
Map(gb_species, awar_name);
92 free(selected_species);
113 if (!fieldname || strcmp(fieldname, name) == 0) {
127 bool src_is_genome,
bool dst_is_genome,
140 bool transfer_fields =
false;
143 error =
"refused to transfer unnamed species";
150 GBDATA *dest_organism = dest_species_hash
154 if (dest_organism) transfer_fields =
true;
156 error =
GBS_global_string(
"Destination DB does not contain '%s's origin-organism '%s'",
165 error =
GBS_global_string(
"You can't merge organisms (%s) into a non-genome DB.\n"
166 "Only pseudo-species are possible", src_name);
172 error =
GBS_global_string(
"You can't merge non-genome species (%s) into a genome DB", src_name);
180 gb_dst_species = dest_species_hash
184 if (gb_dst_species) error =
GB_delete(gb_dst_species);
191 if (!error && transfer_fields) {
193 error =
MG_export_fields(aw_root, gb_src_species, gb_dst_species, error_suppressor, source_organism_hash);
197 if (!error && dest_species_hash)
GBS_write_hash(dest_species_hash, src_name, (
long)gb_dst_species);
216 if (!src_name || !src_name[0]) {
217 error =
"Please select a species in the left list";
235 if (!gb_src_species) {
236 error =
GBS_global_string(
"Could not find species '%s' in source database", src_name);
240 gb_src_species, gb_dst_species_data,
241 src_is_genome, dst_is_genome,
284 gb_src_species, gb_dst_species_data,
285 src_is_genome, dst_is_genome,
286 source_organism_hash, dest_species_hash,
294 if (source_organism_hash)
GBS_free_hash(source_organism_hash);
308 bool use_copy =
true;
313 error =
"You can use 'Append data' with text fields only!";
315 else if (gb_dst_field) {
334 if (!error && use_copy) {
335 if (dst_type != src_type) error =
"type mismatch";
336 if (!error && src_type ==
GB_DB && gb_dst_field) {
342 if (!error && !gb_dst_field) {
343 gb_dst_field =
GB_search(gb_dst_species, field, src_type);
366 error =
"Please select the field you like to transfer";
368 else if (strcmp(field,
"name") == 0) {
369 error =
"Transferring the 'name' field is forbidden";
374 if (transfer_of_alignment && append) {
375 error =
"Appending alignment data is not permitted\n"
376 "(please refer to ARB_NT/Sequence/Concatenate.. to do so)";
391 gb_src_species && !
error;
399 if (!gb_dst_species) {
413 error =
transfer_single_field(gb_src_species, gb_dst_species, field, gb_src_field, append, transfer_of_alignment, rm);
419 error =
"refusing to transfer from unnamed species";
443 const bool append =
false;
447 error =
"Please select the field you like to transfer";
449 else if (strcmp(field,
"name") == 0) {
450 error =
"Transferring the 'name' field is forbidden";
455 if (transfer_of_alignment && append) {
456 error =
"Appending alignment data is not permitted\n"
457 "(please refer to ARB_NT/Sequence/Concatenate.. to do so)";
481 if (!gb_src_species) error =
"Please select a species in left hitlist";
482 if (!gb_dst_species) error =
"Please select a species in right hitlist";
487 if (!gb_src_field) error =
GBS_global_string(
"Source species has no field '%s'", field);
490 error =
transfer_single_field(gb_src_species, gb_dst_species, field, gb_src_field, append, transfer_of_alignment, rm);
511 AW_window_simple *aws =
new AW_window_simple;
516 if (listed) aws->init(aw_root,
"MERGE_XFER_FIELD_OF_LISTED",
"Transfer field of listed");
517 else aws->init(aw_root,
"MERGE_XFER_SINGLE_FIELD",
"Transfer field of selected");
519 aws->load_xfig(
"merge/mg_transfield.fig");
520 aws->button_length(10);
524 aws->create_button(
"CLOSE",
"CLOSE",
"C");
527 aws->callback(
makeHelpCallback(listed ?
"mg_xfer_field_of_listed.hlp" :
"mg_xfer_field_of_sel.hlp"));
528 aws->create_button(
"HELP",
"HELP");
532 aws->label(
"Append data?");
541 aws->create_button(
"GO",
"GO");
561 error =
"Please select source- and target-fields.";
575 gb_src_species && !
error;
591 dst_val, dst_tag, del_tag);
607 if (error) progress.
done();
620 static AW_window_simple *aws =
NULp;
630 aws =
new AW_window_simple;
631 aws->init(aw_root,
"MERGE_TAGGED_FIELD",
"Merge tagged field");
632 aws->load_xfig(
"merge/mg_mergetaggedfield.fig");
633 aws->button_length(13);
637 aws->create_button(
"CLOSE",
"CLOSE",
"C");
641 aws->create_button(
"GO",
"GO");
645 aws->create_button(
"HELP",
"HELP");
647 aws->at(
"tag1"); aws->create_input_field(
AWAR_TAG_SRC, 5);
648 aws->at(
"tag2"); aws->create_input_field(
AWAR_TAG_DST, 5);
650 aws->at(
"del1"); aws->create_input_field(
AWAR_TAG_DEL, 5);
666 if (!S_alignment_names[0]) {
671 const char *dest =
NULp;
673 for (
int d = D_alignment_names.
size()-1; d>0; --d) {
675 if (strcmp(src_type, dst_type) != 0) D_alignment_names.
remove(d--);
679 int d = D_alignment_names.
size();
682 error =
GB_export_errorf(
"Cannot find a target alignment with a type of '%s'\n"
683 "You should create one first or select a different alignment type\n"
684 "during sequence import", src_type);
687 dest = D_alignment_names[0];
691 if (autoselect_equal_alignment_name) {
692 for (
int i = 0; i<d; ++i) {
693 if (
ARB_stricmp(S_alignment_names[0], D_alignment_names[i]) == 0) {
694 dest = D_alignment_names[i];
703 for (
int i=0; i<d; i++) {
704 buttonstr.
cat(D_alignment_names[i]);
707 buttonstr.
cat(
"ABORT");
710 "There are more than one possible alignment targets\n"
711 "Choose one destination alignment or ABORT",
715 error =
"Operation Aborted";
718 dest = D_alignment_names[aliid];
722 if (!error && dest && strcmp(S_alignment_names[0], dest) != 0) {
725 error =
GBS_global_string(
"Failed to rename alignment '%s' to '%s' (Reason: %s)",
726 S_alignment_names[0], dest, error);
741 static char *s_name =
NULp;
766 bool overwriteall =
false;
767 bool autorenameall =
false;
785 else if (autorenameall) {
790 freeset(s_name, newname);
796 " - Overwrite existing species\n"
797 " - Overwrite all species with ID conflicts\n"
798 " - Not import species\n"
799 " - Enter ID for imported species\n"
800 " - Automatically create unique species IDs (append .NUM)\n"
801 " - Abort everything", s_name),
802 "overwrite, overwrite all, don't import, create ID, auto-create IDs, abort")) {
818 freeset(s_name,
aw_input(
"Species ID",
"Enter new species ID", autoname));
824 autorenameall =
true;
829 error =
"Operation aborted";
861 error = taSrc.
close(error);
862 error = taDst.
close(error);
903 for (
int s = 0;
s <= 1; ++
s) {
918 GBDATA *expect_selected_species(
GBDATA *
gb_main,
const char *awarname_selected,
const char *species_role,
const char *listLocation,
GB_ERROR&
error,
bool acceptNone) {
922 if (species_name[0]) {
930 error =
GBS_global_string(
"Please select a %s species in %s hitlist", species_role, listLocation);
946 error =
"unnamed item";
990 unsigned long scopeSize = 0;
1006 if (gb_dst_species) {
1010 error = transferExistingOrNew(gb_src_species, gb_dst_species_container);
1019 gb_src_species && !
error;
1023 error = transferExistingOrNew(gb_src_species, gb_dst_species_container);
1035 if (error) progress.
done();
1080 aliTransporter(transp)
1084 mg_assert(contradicted(gb_dst_item, gb_dst_item_container));
1091 gb_dst_item ? gb_dst_item : gb_dst_item_container,
1102 mg_assert(contradicted(error, gb_transferred));
1103 if (!error) markTarget(gb_transferred);
1116 error =
"No FTS selected";
1126 if (xfer_seq_data) {
1142 error = transporter.
transferAllIn(scope,
"Transfer using FTS");
1199 aws->
init(awr,
"MERGE_TRANSFER_SPECIES",
"TRANSFER SPECIES");
1242 scanner_src = scanner;
1274 scanner_dst = scanner;
1297 aws->
at(
"reference");
1300 aws->
at(
"pres_sel");
1308 aws->
at(
"xferType");
1320 aws->
at(
"xferWhat");
1329 aws->
at(
"transfer");
GB_ERROR GB_begin_transaction(GBDATA *gbd)
void insert_option(AW_label choice_label, const char *mnemonic, const char *var_value, const char *name_of_color=NULp)
GB_ERROR GB_copy_dropProtectMarksAndTempstate(GBDATA *dest, GBDATA *source)
AW_window * create_mg_check_fields_window(AW_root *aw_root)
#define AWAR_SPECIES_XFER_SCOPE
GB_ERROR transferAllIn(SpeciesXferScope scope, const char *progressTitle)
void button_length(int length)
GB_ERROR transport(GBDATA *, GBDATA *) const OVERRIDE
static void MG_map_species(AW_root *aw_root, DbSel db)
static MutableItemSelector MG_species_selector[2]
void sens_mask(AW_active mask)
void scanFields(StrArray &fields, FieldsToScan whatToScan) const OVERRIDE
long GB_read_int(GBDATA *gbd)
#define implicated(hypothesis, conclusion)
void XFER_select_RuleSet(AW_window *aww, const char *awar_selected_fts, const AvailableFieldScanner *fieldScanner)
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
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)
AW_window * MG_gene_species_create_field_transfer_def_window(AW_root *aw_root)
GB_ERROR GB_write_string(GBDATA *gbd, const char *s)
bool fieldContainsAlignment(const char *field)
void load_xfig(const char *file, bool resize=true)
void DbQuery_update_list(DbQuery *query)
GB_ERROR GBT_rename_alignment(GBDATA *gbMain, const char *source, const char *dest)
static void transfer_field_of_selected_cb(AW_window *aww)
static void mg_select_species2(GBDATA *, AW_root *aw_root, const char *item_name)
bool shallCopyBefore() const OVERRIDE
#define AWAR_REMAP_SPECIES_LIST
static GBDATA * mg_get_first_species_data2(GBDATA *, AW_root *, QUERY_RANGE)
int MG_copy_and_check_alignments()
static void transfer_field_of_listed_cb(AW_window *aww)
GBDATA * GB_nextEntry(GBDATA *entry)
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
int ARB_stricmp(const char *s1, const char *s2)
static const char * get_reference_species_names(AW_root *awr)
void GBT_get_alignment_names(ConstStrArray &names, GBDATA *gbd)
static MergeFieldScanner fieldScanner
static void mg_transfer_listed_species(AW_window *aww)
static GB_ERROR transfer_single_field(GBDATA *const gb_src_species, GBDATA *const gb_dst_species, const char *const field, GBDATA *const gb_src_field, const bool append, const bool transfer_of_alignment, const MG_remaps &rm)
char * ARB_strdup(const char *str)
void create_toggle(const char *awar_name)
void GB_end_transaction_show_error(GBDATA *gbd, GB_ERROR error, void(*error_handler)(GB_ERROR))
DbQuery * create_query_box(AW_window *aws, query_spec *awtqs, const char *query_id)
ViaFtsTransporter(RuleSetPtr fts_, AlignmentTransporterPtr transp)
const char * GBS_global_string(const char *templat,...)
void warning(int warning_num, const char *warning_message)
const char * result_pos_fig
static DbScanner * scanner_dst
static void markTarget(GBDATA *gb_dst_item)
GB_ERROR MG_expect_renamed()
void AW_POPDOWN(AW_window *window)
static GB_ERROR MG_transfer_one_species(AW_root *aw_root, MG_remaps &remap, GBDATA *gb_src_species, GBDATA *gb_dst_species_data, bool src_is_genome, bool dst_is_genome, GB_HASH *source_organism_hash, GB_HASH *dest_species_hash, GB_HASH *error_suppressor)
void GBS_free_hash(GB_HASH *hs)
GBDATA * GEN_find_organism(GBDATA *gb_main, const char *name)
static AW_window * create_mg_merge_tagged_fields_window(AW_root *aw_root)
GB_HASH * GBT_create_species_hash(GBDATA *gb_main)
void cat(const char *from)
const char * MG_left_AWAR_SPECIES_NAME()
GB_ERROR MG_export_fields(AW_root *aw_root, GBDATA *gb_src, GBDATA *gb_dst, GB_HASH *error_suppressor, GB_HASH *source_organism_hash)
const char * open_parser_pos_fig
char * GBT_get_alignment_type_string(GBDATA *gb_main, const char *aliname)
GBDATA * GB_get_father(GBDATA *gbd)
void update_option_menu()
#define NO_FIELD_SELECTED
GB_CSTR GBS_find_string(GB_CSTR cont, GB_CSTR substr, int match_mode)
AW_awar * add_callback(const RootCallback &cb)
GB_ERROR GB_delete(GBDATA *&source)
GB_ERROR GBT_add_alignment_changekeys(GBDATA *gb_main, const char *ali)
void create_itemfield_selection_button(AW_window *aws, const FieldSelDef &selDef, const char *at)
GB_ERROR MERGE_sequences_simple(AW_root *awr)
static void popup_single_field_transfer_window(AW_root *aw_root, SpeciesXferScope scope)
void GB_raise_user_flag(GBDATA *gbd, unsigned char user_bit)
const char * read_char_pntr() const
GB_ERROR MG_adaptAllCopiedAlignments(const MG_remaps &remaps, GBDATA *source_species, GBDATA *destination_species)
GB_ERROR GB_export_error(const char *error)
GB_ERROR GBT_add_new_species_changekey(GBDATA *gb_main, const char *name, GB_TYPES type)
GB_ERROR GB_await_error()
static AW_root * SINGLETON
GBDATA * GB_create_container(GBDATA *father, const char *key)
WindowCallback makeHelpCallback(const char *helpfile)
char * GBT_read_string(GBDATA *gb_container, const char *fieldpath)
GB_TYPES GB_read_type(GBDATA *gbd)
static GB_ERROR MG_transfer_fields_info(char *fieldname=NULp)
bool isSet() const
test if SmartPtr is not NULp
long GB_number_of_subentries(GBDATA *gbd)
static GB_ERROR MG_equal_alignments(bool autoselect_equal_alignment_name)
SmartPtr< MG_remaps > MG_remapsPtr
static void mg_transfer_selected_species(AW_window *aww)
GBDATA *(* get_selected_item)(GBDATA *gb_main, AW_root *aw_root)
static void MG_transfer_species(AW_window *aww)
bool GB_is_ancestor_of(GBDATA *gb_ancestor, GBDATA *gb_descendant)
void create_menu(const char *name, const char *mnemonic, AW_active mask=AWM_ALL)
const char * qbox_pos_fig
GBDATA * GBT_expect_species(GBDATA *gb_main, const char *name)
static void MG_merge_tagged_field_cb(AW_window *aww)
GBDATA *(* get_first_item_container)(GBDATA *, AW_root *, QUERY_RANGE)
static void error(const char *msg)
static GBDATA * mg_get_first_species_data1(GBDATA *, AW_root *, QUERY_RANGE)
char * GBT_readOrCreate_string(GBDATA *gb_container, const char *fieldpath, const char *default_value)
GBDATA * GBT_find_or_create_species_rel_species_data(GBDATA *gb_species_data, const char *name, bool markCreated)
static void mg_xfer_via_fts(AW_root *aw_root, SpeciesXferScope scope, bool xfer_seq_data)
const char * GEN_origin_organism(GBDATA *gb_pseudo)
long mg_count_queried(GBDATA *gb_main)
static DbScanner * scanner_src
#define AWAR_SPECIES_NAME
const char * count_pos_fig
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)
GBDATA * GBT_find_species_rel_species_data(GBDATA *gb_species_data, const char *name)
char * read_string() const
GB_ERROR get_error() const
AW_awar * awar(const char *awar)
bool expect_hit_in_ref_list
const char * XFER_getFullFTS(const char *name)
CONSTEXPR long FIELD_FILTER_ANY_FIELD
void create_autosize_button(const char *macro_name, AW_label label, const char *mnemonic=NULp, unsigned xtraSpace=1)
static void set_query_to_update(QUERY::DbQuery *query)
void MG_create_species_awars(AW_root *aw_root, AW_default aw_def)
void(* update_item_awars)(GBDATA *gb_main, AW_root *aw_root, const char *item_name)
int aw_question(const char *unique_id, const char *question, const char *buttons, bool sameSizeButtons, const char *helpfile)
GB_ERROR GB_export_errorf(const char *templat,...)
AdaptedAlignmentTransporter(MG_remapsPtr remaps_)
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
AW_window * MG_create_preserves_selection_window(AW_root *awr)
GB_ERROR close(GB_ERROR error)
void GB_write_flag(GBDATA *gbd, long flag)
GB_ERROR GBT_write_string(GBDATA *gb_container, const char *fieldpath, const char *content)
const char * do_mark_pos_fig
char * AWTC_create_numbered_suffix(GB_HASH *species_name_hash, const char *shortname, GB_ERROR &warning)
#define AWAR_SPECIES_XFER_FTS
static GBDATA * mg_get_selected_species1(GBDATA *, AW_root *aw_root)
char * GB_read_string(GBDATA *gbd)
GB_ERROR GB_copy_dropMarksAndTempstate(GBDATA *dest, GBDATA *source)
void Map(GBDATA *gb_new_item, const char *key_path)
ItemSelector & SPECIES_get_selector()
GBDATA * GBT_first_species(GBDATA *gb_main)
#define IS_QUERIED_SPECIES(gb_species)
const char * query_pos_fig
static void mg_select_species1(GBDATA *, AW_root *aw_root, const char *item_name)
void aw_message(const char *msg)
const char * do_query_pos_fig
AW_option_menu_struct * create_option_menu(const char *awar_name)
GBDATA * GB_find_string(GBDATA *gbd, const char *key, const char *str, GB_CASE case_sens, GB_SEARCH_TYPE gbs)
GBDATA * GBT_next_species(GBDATA *gb_species)
GBDATA * GBT_find_species(GBDATA *gb_main, const char *name)
GB_HASH * GBT_create_organism_hash(GBDATA *gb_main)
#define AWAR_SPECIES_XFER_TYPE
virtual GB_ERROR transferOne(GBDATA *gb_src_item, GBDATA *gb_dst_item, GBDATA *gb_dst_item_container)=0
GB_ERROR write_string(const char *aw_string)
static ErrorOrRuleSetPtr loadFrom(const char *filename)
const char * get_data() const
GB_HASH * GBT_create_species_hash_sized(GBDATA *gb_main, long species_count)
const char * GBT_get_name(GBDATA *gb_item)
#define GB_USERFLAG_QUERY
ARB_ERROR getError() const
bool shallCopyBefore() const OVERRIDE
virtual ~ScopedTransporter()
GB_transaction ta(gb_var)
void callback(const WindowCallback &cb)
GB_ERROR transferOne(GBDATA *gb_src_item, GBDATA *gb_dst_item, GBDATA *gb_dst_item_container) OVERRIDE
ItemSelector & get_queried_itemtype() const
char * GBS_merge_tagged_strings(const char *s1, const char *tag1, const char *replace1, const char *s2, const char *tag2, const char *replace2)
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
CONSTEXPR long FIELD_FILTER_STRING
bool GBS_string_matches(const char *str, const char *expr, GB_CASE case_sens)
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
bool GEN_is_genome_db(GBDATA *gb_main, int default_value)
void shadow_width(int shadow_thickness)
const char * do_set_pos_fig
char * aw_input(const char *title, const char *prompt, const char *default_input)
static GBDATA * mg_get_selected_species2(GBDATA *, AW_root *aw_root)
#define AWAR_REMAP_ENABLE
GBDATA * get_gb_main(DbSel db)
bool GEN_is_pseudo_gene_species(GBDATA *gb_species)
AW_window * MG_create_merge_species_window(AW_root *awr, bool dst_is_new)
static bool adaption_enabled(AW_root *awr)
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 inc_and_check_user_abort(GB_ERROR &error)
void collectKeysRegisteredInDatabase(StrArray &fields, GBDATA *gb_main, ItemSelector &sel, bool skipContainers, bool skipHidden)
void create_text_field(const char *awar_name, int columns=20, int rows=4)
const char * do_delete_pos_fig
void aw_message_if(GB_ERROR error)
const char * do_unmark_pos_fig
const char * do_refresh_pos_fig
static void mg_initialize_species_selectors()
CONSTEXPR long FIELD_UNFILTERED
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)
void create_button(const char *macro_name, AW_label label, const char *mnemonic=NULp, const char *color=NULp)
GBDATA * GBT_get_species_data(GBDATA *gb_main)
GB_ERROR transport(GBDATA *gb_src_item, GBDATA *gb_dst_item) const OVERRIDE
GB_write_int const char s