| 1 | // =============================================================== // |
|---|
| 2 | // // |
|---|
| 3 | // File : NT_import.cxx // |
|---|
| 4 | // Purpose : // |
|---|
| 5 | // // |
|---|
| 6 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 7 | // http://www.arb-home.de/ // |
|---|
| 8 | // // |
|---|
| 9 | // =============================================================== // |
|---|
| 10 | |
|---|
| 11 | #include "NT_local.h" |
|---|
| 12 | |
|---|
| 13 | #include <dbui.h> |
|---|
| 14 | #include <GEN.hxx> |
|---|
| 15 | #include <mg_merge.hxx> |
|---|
| 16 | #include <macros.hxx> |
|---|
| 17 | |
|---|
| 18 | #include <awti_import.hxx> |
|---|
| 19 | #include <awt.hxx> |
|---|
| 20 | #include <awt_canvas.hxx> |
|---|
| 21 | |
|---|
| 22 | #include <aw_awar.hxx> |
|---|
| 23 | #include <aw_root.hxx> |
|---|
| 24 | #include <aw_msg.hxx> |
|---|
| 25 | |
|---|
| 26 | #include <arbdbt.h> |
|---|
| 27 | |
|---|
| 28 | static void nt_seq_load_cb(AW_root *awr, TREE_canvas *ntw) { |
|---|
| 29 | GLOBAL_gb_dst = GLOBAL.gb_main; |
|---|
| 30 | AW_window *aww = DBUI::create_species_query_window(awr, GLOBAL.gb_main); |
|---|
| 31 | DBUI::unquery_all(); |
|---|
| 32 | GB_ERROR error = MERGE_sequences_simple(awr); |
|---|
| 33 | if (!error) error = NT_format_all_alignments(GLOBAL.gb_main); |
|---|
| 34 | DBUI::query_update_list(); |
|---|
| 35 | if (!error) aww->activate(); |
|---|
| 36 | |
|---|
| 37 | AWTI_cleanup_importer(); // closes import DB |
|---|
| 38 | |
|---|
| 39 | GLOBAL_gb_src = NULp; |
|---|
| 40 | GLOBAL_gb_dst = NULp; |
|---|
| 41 | |
|---|
| 42 | if (awr->awar(AWAR_IMPORT_AUTOCONF)->read_int()) { |
|---|
| 43 | NT_create_config_after_import(ntw, false); |
|---|
| 44 | } |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | void NT_import_sequences(AW_window *aww, TREE_canvas *ntw) { |
|---|
| 49 | /*! Opens the "Import Sequences" dialog from the ARB main window (ARB_NTREE) |
|---|
| 50 | */ |
|---|
| 51 | AW_root *awr = aww->get_root(); |
|---|
| 52 | |
|---|
| 53 | AWTI_open_import_window(awr, NULp, false, GLOBAL.gb_main, makeRootCallback(nt_seq_load_cb, ntw)); |
|---|
| 54 | AWTI_set_importDB_pointer(GLOBAL_gb_src); |
|---|
| 55 | |
|---|
| 56 | nt_assert(got_macro_ability(awr)); |
|---|
| 57 | |
|---|
| 58 | // change awar values (import window just opened!) |
|---|
| 59 | |
|---|
| 60 | int gb_main_is_genom_db; |
|---|
| 61 | { |
|---|
| 62 | GB_transaction t1(GLOBAL.gb_main); |
|---|
| 63 | GB_transaction t2(GLOBAL_gb_src); |
|---|
| 64 | |
|---|
| 65 | gb_main_is_genom_db = GEN_is_genome_db(GLOBAL.gb_main, 0); |
|---|
| 66 | IF_ASSERTION_USED(int gb_merge_is_genom_db =) GEN_is_genome_db(GLOBAL_gb_src, gb_main_is_genom_db); |
|---|
| 67 | |
|---|
| 68 | nt_assert(gb_main_is_genom_db == gb_merge_is_genom_db); |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | awr->awar(AWAR_IMPORT_GENOM_DB)->write_int(gb_main_is_genom_db ? IMP_GENOME_FLATFILE : IMP_PLAIN_SEQUENCE); |
|---|
| 73 | |
|---|
| 74 | { |
|---|
| 75 | GB_transaction ta(GLOBAL.gb_main); |
|---|
| 76 | |
|---|
| 77 | char *ali_name = GBT_get_default_alignment(GLOBAL.gb_main); |
|---|
| 78 | char *ali_type = ali_name ? GBT_get_alignment_type_string(GLOBAL.gb_main, ali_name) : NULp; |
|---|
| 79 | |
|---|
| 80 | if (!ali_type) aw_message(GB_await_error()); |
|---|
| 81 | |
|---|
| 82 | AWTI_import_set_ali_and_type(awr, ali_name, ali_type, GLOBAL.gb_main); |
|---|
| 83 | |
|---|
| 84 | free(ali_type); |
|---|
| 85 | free(ali_name); |
|---|
| 86 | } |
|---|
| 87 | } |
|---|
| 88 | |
|---|