26 #define AWAR_CHECK AWAR_MERGE_TMP "chk/"
28 #define AWAR_COMPARE_FIELD AWAR_CHECK "compare"
29 #define AWAR_REPORT_FIELD AWAR_CHECK "report"
30 #define AWAR_TOUPPER AWAR_CHECK "ToUpper"
31 #define AWAR_EXCLUDE AWAR_CHECK "exclude"
32 #define AWAR_CORRECT AWAR_CHECK "correct"
33 #define AWAR_ETAG AWAR_CHECK "tag"
43 do { c1 = *(s1++); }
while (tab[c1] < 0);
44 do { c2 = *(s2++); }
while (tab[c2] < 0);
45 if (tab[c1] != tab[c2]) {
49 }
while (count && c1 && c2);
54 static char *
MG_diff_strings(
char *str1,
char * &str2,
char *exclude,
bool ToUpper,
bool correct,
55 char **res1,
char **res2,
bool& corrrected) {
59 char *dest1 = buffer1;
60 char *dest2 = buffer2;
73 if (strlen(exclude)) gapchar = exclude[0];
76 for (i=1; i<256; i++) {
78 if (exclude && strchr(exclude, i)) {
82 if (ToUpper && i >=
'a' && i <=
'z') {
88 do { c1 = *(s1++); }
while (tab[c1] < 0);
89 do { c2 = *(s2++); }
while (tab[c2] < 0);
90 if (tab[c1] != tab[c2]) {
106 do { c2 = *(s2++); }
while (tab[c2] < 0);
113 char *toinspos = s2-1;
114 if (toinspos > str2) toinspos--;
115 if (tab[(
unsigned char)toinspos[0]]> 0) {
131 if (tab[(
unsigned char)s1[0]]<0) side = 0;
133 while (toinspos > str2 &&
134 tab[(
unsigned char)toinspos[-1]] < 0) toinspos--;
138 do { c1 = *(s1++); }
while (tab[c1] < 0);
147 sprintf(dest1,
"%ti ", s1-str1-1);
148 sprintf(dest2,
"%ti ", s2-str2-1);
149 dest1 += strlen(dest1);
150 dest2 += strlen(dest2);
157 sprintf(dest1,
"... %ti ", s1-str1-1);
158 sprintf(dest2,
"... %ti ", s2-str2-1);
159 dest1 += strlen(dest1);
160 dest2 += strlen(dest2);
163 sprintf(dest1,
"and %i more", 1-count);
164 sprintf(dest2,
"and %i more", 1-count);
165 dest1 += strlen(dest1);
166 dest2 += strlen(dest2);
168 if (strlen(buffer1)) {
198 int correctCount = 0;
201 error =
"Please select a field to compare";
207 const char *reportField =
NULp;
215 if (!otherdb_reportField) {
219 mg_assert(strcmp(reportField, otherdb_reportField) == 0);
236 gb_dst_species && !
error;
243 bool seenQueried =
false;
245 gb_src_species && !
error;
258 if (!gb_dst_species) {
270 if (src_val || dst_val) {
271 char *src_positions =
NULp;
272 char *dst_positions =
NULp;
274 if (src_val && dst_val) {
275 bool corrected =
false;
276 MG_diff_strings(src_val, dst_val, exclude, ToUpper, correct, &src_positions, &dst_positions, corrected);
290 if (src_positions && !error) {
292 if (!error) error =
GBT_write_string(gb_src_species, reportField, src_positions);
307 if (!seenQueried && !error) {
308 error =
"Empty hitlist in source database (nothing to do)";
318 else if (correctCount) {
320 "(species %s been marked in target database).",
321 correctCount, correctCount == 1 ?
"has" :
"have"));
338 AW_window_simple *aws =
new AW_window_simple;
339 aws->init(aw_root,
"MERGE_COMPARE_FIELD",
"COMPARE DATABASE FIELD");
340 aws->load_xfig(
"merge/seqcheck.fig");
343 aws->create_button(
"CLOSE",
"CLOSE",
"C");
347 aws->create_button(
"HELP",
"HELP",
"H");
368 aws->create_button(
"GO",
"GO");
GB_ERROR GB_begin_transaction(GBDATA *gbd)
static GB_ERROR tab(GBL_command_arguments *args, bool pretab)
long mg_count_queried(GBDATA *gb_main)
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
char * ARB_strdup(const char *str)
char * GB_read_as_tagged_string(GBDATA *gbd, const char *tagi)
const char * GBS_global_string(const char *templat,...)
void AW_POPDOWN(AW_window *window)
void cat(const char *from)
GBDATA * GB_get_father(GBDATA *gbd)
static int gbs_cmp_strings(char *str1, char *str2, int *tab)
#define NO_FIELD_SELECTED
#define AWAR_COMPARE_FIELD
GB_ERROR GB_delete(GBDATA *&source)
GBDATA * GBT_first_species_rel_species_data(GBDATA *gb_species_data)
void create_itemfield_selection_button(AW_window *aws, const FieldSelDef &selDef, const char *at)
GB_ERROR GB_await_error()
WindowCallback makeHelpCallback(const char *helpfile)
CONSTEXPR long FIELD_FILTER_STRING_WRITEABLE
static void error(const char *msg)
const char * prepare_and_get_selected_itemfield(AW_root *awr, const char *awar_name, GBDATA *gb_main, const ItemSelector &itemtype, FailIfField failIf)
char * read_string() const
#define AWAR_REPORT_FIELD
AW_awar * awar(const char *awar)
static void mg_check_field_cb(AW_window *aww)
void ncat(const char *from, size_t count)
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
void GB_write_flag(GBDATA *gbd, long flag)
GB_ERROR GBT_write_string(GBDATA *gb_container, const char *fieldpath, const char *content)
ItemSelector & SPECIES_get_selector()
GBDATA * GBT_first_species(GBDATA *gb_main)
#define IS_QUERIED_SPECIES(gb_species)
void aw_message(const char *msg)
GBDATA * GB_find_string(GBDATA *gbd, const char *key, const char *str, GB_CASE case_sens, GB_SEARCH_TYPE gbs)
AW_window * create_mg_check_fields_window(AW_root *aw_root)
GBDATA * GBT_next_species(GBDATA *gb_species)
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
static char * MG_diff_strings(char *str1, char *&str2, char *exclude, bool ToUpper, bool correct, char **res1, char **res2, bool &corrrected)
void inc_and_check_user_abort(GB_ERROR &error)
CONSTEXPR long FIELD_FILTER_STRING_READABLE
char * GBS_global_string_copy(const char *templat,...)
GBDATA * GBT_get_species_data(GBDATA *gb_main)
GB_ERROR GB_write_autoconv_string(GBDATA *gbd, const char *val)