61 arb_progress progress(
"Formatting alignments", ali_count);
64 AW_repeated_question question;
65 question.add_help(
"prompt/format_alignments.hlp");
91 if (format_action != FA_SKIP_ALL) {
92 format_action = FA_SKIP_ALL;
97 else if (is_ali_genom) {
98 format_action = FA_SKIP_ALL;
103 bool perform_format =
false;
105 switch (format_action) {
106 case FA_FORMAT_ALL: perform_format =
true;
break;
107 case FA_SKIP_ALL: perform_format =
false;
break;
110 int answer = question.get_answer(
"format_alignments", qtext,
"Format,Skip,Always format,Always skip",
"all",
false);
117 perform_format =
true;
130 if (!err && perform_format) {
137 if (err) progress.
done();
170 if (!error) error =
GBK_system(
"arb_macro_compatibility.sh &");
172 if (!error && autorun_macro)
execute_macro(aw_root, autorun_macro);
189 #define MAXNAMELEN 35
190 int len = strlen(db_server);
192 char *nameOnly = strrchr(db_server,
'/');
195 len -= (nameOnly-db_server);
196 memmove(db_server, nameOnly, len+1);
215 #define AWAR_DB_FILTER AWAR_DBBASE "/filter"
216 #define AWAR_DB_DIRECTORY AWAR_DBBASE "/directory"
222 if (strlen(db_server)) {
290 AW_window_simple *aws =
new AW_window_simple;
291 aws->init(awr,
"ARB_INTRO",
"ARB INTRO");
296 aws->create_button(
"EXIT",
"Exit",
"x");
300 aws->create_button(
"HELP",
"HELP",
"H");
304 aws->button_length(0);
307 aws->create_button(
NULp,
"#logo.xpm");
312 aws->at(
"copyright");
317 aws->create_autosize_button(
"OPEN_SELECTED",
"OPEN SELECTED",
"O");
321 aws->create_autosize_button(
"DELETE_SELECTED",
"DELETE SELECTED");
323 aws->at(
"new_complex");
325 aws->create_autosize_button(
"CREATE_AND_IMPORT",
"CREATE AND IMPORT",
"I");
329 aws->create_autosize_button(
"MERGE_TWO_DATABASES",
"MERGE TWO ARB DATABASES",
"O");
338 static bool avoid_recursion =
false;
340 if (!avoid_recursion) {
344 char *lslash = strrchr(value,
'/');
346 char *name = lslash ? lslash+1 : value;
348 printf(
"writing '%s' to AWAR_DB_NAME\n", name);
364 char const*
const* args;
373 : arg_count(argc_-1),
375 help_requested(
false),
380 void shift() { ++args; --arg_count; }
383 const char *
get_arg(
int num)
const {
return num<arg_count ? args[num] :
NULp; }
396 "http://www.arb-home.de/\n"
400 " arb_ntree => start ARB (intro)\n"
401 " arb_ntree DB => start ARB with DB\n"
402 " arb_ntree DB1 DB2 => merge from DB1 into DB2\n"
403 " arb_ntree --import FILE => import FILE into new database (FILE may be a filemask)\n"
405 "Additional arguments possible with command lines above:\n"
406 " --execute macroname => execute macro 'macroname' after startup\n"
408 "Each DB argument may be one of the following:\n"
409 " database.arb -> use existing or new database\n"
410 " \":\" -> connect to database of a running instance of ARB\n"
411 " directory -> prompt for databases inside directory\n"
412 " filemask -> also prompt for DB, but more specific (e.g. \"prot*.arb\")\n"
420 while (!error && arg_count>0 && args[0][0] ==
'-') {
421 const char *opt = args[0]+1;
422 if (opt[0] ==
'-') ++opt;
423 if (strcmp(opt,
"help") == 0 || strcmp(opt,
"h") == 0) { help_requested =
true; }
424 else if (strcmp(opt,
"execute") == 0) { shift(); macro_name = *args; }
425 else if (strcmp(opt,
"import") == 0) { do_import =
true; }
428 else if (strcmp(opt,
"crash") == 0) {
GBK_terminate(
"crash requested"); }
429 else if (strcmp(opt,
"trap") == 0) {
arb_assert(0); }
430 else if (strcmp(opt,
"sighup") == 0) {
raise(SIGHUP); }
431 else if (strcmp(opt,
"sigsegv") == 0) {
raise(SIGSEGV); }
432 else if (strcmp(opt,
"sigterm") == 0) {
raise(SIGTERM); }
433 else if (strcmp(opt,
"fail") == 0) { exit(
EXIT_FAILURE); }
434 else if (strcmp(opt,
"exit") == 0) { exit(
EXIT_SUCCESS); }
442 if (do_import && arg_count != 1) error =
"expected exactly one file-name or file-mask behind --import";
443 else if (arg_count>2) error =
"too many stray arguments given (max. 2 accepted)";
460 const char *suffix = strstr(arg,
".arb");
462 return strcmp(suffix,
".arb") == 0;
470 if (strpbrk(arg,
"*?"))
return FILEMASK;
483 #define ABORTED_BY_USER "aborted by user"
496 if (!database) mode =
BROWSE;
502 enum Action { LOAD_DB, CONVERT_DB, BROWSE_DB, EXIT, NOIDEA };
509 const char *msg =
GBS_global_string(
"'%s' is neither a known option nor a legal file- or directory-name.\n(Error: %s)",
510 full_path, load_file_err);
513 action = ans ? EXIT : BROWSE_DB;
516 const char *msg =
GBS_global_string(
"Your file is not an original arb file\n(%s)", load_file_err);
522 case CONVERT_DB: mode =
IMPORT;
break;
527 char *dir = nulldup(full_path);
532 reassign(browser_startdir, dir);
565 if (strcmp(name, changed) != 0) {
566 reselect_file(changed);
593 const char *slash = strrchr(name,
'/');
594 return slash ? slash+1 : name;
602 const char *dir =
NULp;
605 dir = get_fullname();
615 static SmartCharPtr dir_store;
616 dir_store = dir_copy;
636 static SmartCharPtr mask_store;
637 mask_store = mask_copy;
657 if (file) reselect_file(file);
661 GB_ERROR open_db_for_merge(
bool is_source_db);
667 const char *openMode =
"rw";
672 GBK_terminate(
"Program logic error (should have been prompted for explicit DB name)");
746 if (restart_args)
NT_start(restart_args,
true);
756 fputs(
"Error: merge aborted by user\n", stderr);
761 AW_window_simple *aw_msg =
new AW_window_simple;
763 aw_msg->init(aw_root,
"arb_merge_error",
"ARB merge error");
767 aw_msg->auto_space(10, 10);
769 aw_msg->create_autosize_button(
NULp, error,
"", 2);
770 aw_msg->at_newline();
773 aw_msg->create_autosize_button(
"OK",
"Ok",
"O", 2);
775 aw_msg->window_fit();
787 ms->
error =
"Need two databases to merge";
884 error =
"You cannot merge from running to running DB";
900 const char *database =
NULp;
914 else if (mode ==
NORMAL) {
922 else if (mode ==
BROWSE) {
926 int l = strlen(latest);
927 strcpy(latest+l-3,
"arb");
936 free(browser_startdir);
984 fprintf(stderr,
"arb_ntree: Error: %s\n", error.
deliver());
void reselect_file(const char *file)
static __ATTR__USERESULT GB_ERROR startup_mainwindow_and_dbserver(AW_root *aw_root, const char *autorun_macro, TREE_canvas *&result_ntw)
GB_ERROR GBK_system(const char *system_command)
const char * get_dir() const
#define AWAR_SAVED_DB_PATH
void MERGE_create_db_file_awars(AW_root *awr, AW_default aw_def, const char *src_name, const char *dst_name)
static GB_ERROR nt_check_database_consistency()
#define AWAR_DB_DIRECTORY
GB_ERROR preserve() const
GB_CSTR GB_path_in_arbprop(const char *relative_path)
const char * get_mask() const
void NT_create_config_after_import(TREE_canvas *ntw, bool imported_from_scratch)
const char * get_role() const
long GB_read_int(GBDATA *gbd)
bool wants_import() const
bool GB_is_server(GBDATA *gbd)
void load_xfig(const char *file, bool resize=true)
const char * get_arg(int num) const
SelectedDatabase(GBDATA *&gb_main_, const char *name_, const char *role_)
int GBT_count_alignments(GBDATA *gb_main)
bool needs_to_prompt() const
void AW_edit(const char *path)
static AW_window * startup_merge_main_window(AW_root *aw_root, merge_scheme *ms)
AW_window * awt_create_load_box(AW_root *aw_root, const char *action, const char *what, const char *default_directory, const char *file_extension, char **set_file_name_awar, const WindowCallback &ok_cb, const WindowCallback &close_cb, const char *close_button_text)
void print_help(FILE *out) const
AW_window * MERGE_create_main_window(AW_root *aw_root, bool dst_is_new, void(*exit_cb)(const char *))
GBDATA * GB_nextEntry(GBDATA *entry)
void AWTI_set_importDB_pointer(GBDATA *&dbPtr)
static AW_window * merge_startup_error_window(AW_root *aw_root, GB_ERROR error)
void AW_create_standard_fileselection(AW_window *aws, const char *awar_prefix)
#define ARB_VERSION_DETAILED
GB_ERROR GB_delete_database(GB_CSTR filename)
char * ARB_strdup(const char *str)
static void nt_intro_start_import(AW_window *aw_intro)
static WindowCallback makeWindowReplacer(const CreateWindowCallback &cwcb)
const char * GBS_global_string(const char *templat,...)
static void nt_intro_start_merge(AW_window *aw_intro)
static void nt_intro_start_existing(AW_window *aw_intro)
NtreeCommandLine(int argc_, char const *const *argv_)
static ARB_ERROR check_argument_for_mode(const char *database, char *&browser_startdir, RunMode &mode)
__ATTR__USERESULT GB_ERROR configure_macro_recording(AW_root *aw_root, const char *client_id, GBDATA *gb_main)
const char * get_fullname() const
bool has_arb_suffix(const char *arg)
static void start_main_window_after_import(AW_root *aw_root)
GB_CSTR GB_canonical_path(const char *anypath)
GBDATA * GBT_open(const char *path, const char *opent)
static void exit_from_merge(const char *restart_args)
AW_awar * add_callback(const RootCallback &cb)
void setUserActionTracker(UserActionTracker *user_tracker)
GB_ERROR open_db_for_merge(bool is_source_db)
const char * read_char_pntr() const
GB_ERROR GB_await_error()
GBDATA * AWTI_acquire_imported_DB_and_cleanup_importer()
static AW_root * SINGLETON
WindowCallback makeHelpCallback(const char *helpfile)
GB_ERROR ARB_format_alignment(GBDATA *Main, const char *alignment_name)
static void merge_startup_abort_cb(AW_window *)
void MERGE_create_all_awars(AW_root *awr, AW_default aw_def)
void aw_popup_ok(const char *msg)
void recalc_size_atShow(enum AW_SizeRecalc sr)
int ARB_main(int argc, char *argv[])
void GBK_terminate(const char *error) __ATTR__NORETURN
unsigned long GB_time_of_file(const char *path)
char * GB_find_latest_file(const char *dir, const char *mask)
void NT_restart(AW_root *aw_root, const char *arb_ntree_args)
static ARB_ERROR load_and_startup_main_window(AW_root *aw_root, const char *autorun_macro)
static bool merge_tool_running_as_client
merge_scheme(SelectedDatabase *src_, SelectedDatabase *dst_)
void message(char *errortext)
static char const * macro_name
static void error(const char *msg)
#define AWAR_TREE_REFRESH
void AW_create_fileselection_awars(AW_root *awr, const char *awar_base, const char *directories, const char *filter, const char *file_name)
AW_HEADER_MAIN NT_global GLOBAL
void fix_dst(AW_root *aw_root)
void expect_no_error() const
static ArgType detectArgType(const char *arg)
#define AWAR_IMPORT_AUTOCONF
void execute_macro(AW_root *root, const char *macroname)
static AW_window * nt_create_intro_window(AW_root *awr)
char * AW_unfold_path(const char *pwd_envar, const char *path)
UserActionTracker * need_macro_ability()
char * read_string() const
GB_CSTR GB_path_in_ARBLIB(const char *relative_path)
AW_awar * awar(const char *awar)
GB_ERROR GB_write_int(GBDATA *gbd, long i)
bool got_macro_ability(AW_root *aw_root)
void ARB_declare_global_awars(AW_root *aw_root, AW_default aw_def)
bool aw_ask_sure(const char *unique_id, const char *msg)
AW_root * AWT_create_root(const char *properties, const char *program, UserActionTracker *user_tracker)
int aw_question(const char *unique_id, const char *question, const char *buttons, bool sameSizeButtons, const char *helpfile)
fputs(TRACE_PREFIX, stderr)
TREE_canvas * NT_create_main_window(AW_root *aw_root)
const char * get_nameonly() const
static AW_window * startup_merge_prompting_for_nonexplicit_dbs(AW_root *aw_root, merge_scheme *ms)
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
GB_CSTR GB_unfold_in_directory(const char *relative_directory, const char *path)
GB_ERROR close(GB_ERROR error)
static void nt_delete_database(AW_window *aww)
bool GB_is_directory(const char *path)
#define __ATTR__USERESULT
GB_ERROR NT_format_all_alignments(GBDATA *gb_main)
#define TREEDISP_STACKSIZE
void aw_message(const char *msg)
GB_ERROR NT_repair_DB(GBDATA *gb_main)
void NT_start(const char *arb_ntree_args, bool restart_with_new_ARB_PID)
void GB_split_full_path(const char *fullpath, char **res_dir, char **res_fullname, char **res_name_only, char **res_suffix)
bool GB_is_regularfile(const char *path)
void reselect_from_awar(AW_root *aw_root, const char *awar_name)
void fix_src(AW_root *aw_root)
static AW_window * startup_merge_prompting_for_nonexplicit_dst_db(AW_root *aw_root, merge_scheme *ms)
GB_ERROR write_string(const char *aw_string)
static void startup_gui(NtreeCommandLine &cl, ARB_ERROR &error)
void AWT_install_cb_guards()
void AWTI_open_import_window(AW_root *awr, const char *def_importname, bool do_exit, GBDATA *gb_main, const RootCallback &after_import_cb)
char * AW_extract_directory(const char *path)
const char * autorun_macro() const
GB_transaction ta(gb_var)
GB_ERROR GBT_write_int(GBDATA *gb_container, const char *fieldpath, long content)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
GB_ERROR GBT_check_data(GBDATA *Main, const char *alignment_name)
GBDATA * GBT_get_presets(GBDATA *gb_main)
GB_ERROR GBT_check_arb_file(const char *name)
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
void NT_exit(AW_window *aws, int exitcode)
const char * get_description() const
void NT_repair_userland_problems(void)
static void AWAR_DB_PATH_changed_cb(AW_root *awr)
GBDATA * GB_entry(GBDATA *father, const char *key)
void inc_and_check_user_abort(GB_ERROR &error)
void aw_message_if(GB_ERROR error)
void AWT_initTreeAwarRegistry(GBDATA *gbmain)
char * GBS_global_string_copy(const char *templat,...)
void GB_close(GBDATA *gbd)
void AWT_system_cb(AW_window *, const char *command)