source: trunk/NTREE/NT_import.cxx

Last change on this file was 19613, checked in by westram, 3 weeks ago
  • reintegrates 'lib' into 'trunk'
    • replace dynamic library AWT by several static libraries: APP, ARB_SPEC, MASKS, CANVAS, MAPKEY, GUI_TK
    • now also check wrong library dependencies for untested units (only4me)
  • adds: log:branches/lib@19578:19612
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
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 <canvas.hxx>
20
21#include <aw_awar.hxx>
22#include <aw_root.hxx>
23#include <aw_msg.hxx>
24
25#include <arbdbt.h>
26
27static void nt_seq_load_cb(AW_root *awr, TREE_canvas *ntw) {
28    GLOBAL_gb_dst     = GLOBAL.gb_main;
29    AW_window *aww    = DBUI::create_species_query_window(awr, GLOBAL.gb_main);
30    DBUI::unquery_all();
31    GB_ERROR   error  = MERGE_sequences_simple(awr);
32    if (!error) error = NT_format_all_alignments(GLOBAL.gb_main);
33    DBUI::query_update_list();
34    if (!error) aww->activate();
35
36    AWTI_cleanup_importer(); // closes import DB
37
38    GLOBAL_gb_src = NULp;
39    GLOBAL_gb_dst = NULp;
40
41    if (awr->awar(AWAR_IMPORT_AUTOCONF)->read_int()) {
42        NT_create_config_after_import(ntw, false);
43    }
44}
45
46
47void NT_import_sequences(AW_window *aww, TREE_canvas *ntw) {
48    /*! Opens the "Import Sequences" dialog from the ARB main window (ARB_NTREE)
49     */
50    AW_root *awr = aww->get_root();
51
52    AWTI_open_import_window(awr, NULp, false, GLOBAL.gb_main, makeRootCallback(nt_seq_load_cb, ntw));
53    AWTI_set_importDB_pointer(GLOBAL_gb_src);
54
55    nt_assert(got_macro_ability(awr));
56
57    // change awar values (import window just opened!)
58
59    int gb_main_is_genom_db;
60    {
61        GB_transaction t1(GLOBAL.gb_main);
62        GB_transaction t2(GLOBAL_gb_src);
63
64        gb_main_is_genom_db = GEN_is_genome_db(GLOBAL.gb_main, 0);
65        IF_ASSERTION_USED(int gb_merge_is_genom_db =) GEN_is_genome_db(GLOBAL_gb_src, gb_main_is_genom_db);
66
67        nt_assert(gb_main_is_genom_db == gb_merge_is_genom_db);
68    }
69
70
71    awr->awar(AWAR_IMPORT_GENOM_DB)->write_int(gb_main_is_genom_db ? IMP_GENOME_FLATFILE : IMP_PLAIN_SEQUENCE);
72
73    {
74        GB_transaction ta(GLOBAL.gb_main);
75
76        char *ali_name = GBT_get_default_alignment(GLOBAL.gb_main);
77        char *ali_type = ali_name ? GBT_get_alignment_type_string(GLOBAL.gb_main, ali_name) : NULp;
78
79        if (!ali_type) aw_message(GB_await_error());
80
81        AWTI_import_set_ali_and_type(awr, ali_name, ali_type, GLOBAL.gb_main);
82
83        free(ali_type);
84        free(ali_name);
85    }
86}
87
Note: See TracBrowser for help on using the repository browser.