source: tags/arb-6.0/NTREE/NT_import.cxx

Last change on this file was 12267, checked in by westram, 10 years ago
  • 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 <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
28static void nt_seq_load_cb(AW_root *awr) {
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 = NULL;
40    GLOBAL_gb_dst = NULL;
41}
42
43
44void NT_import_sequences(AW_window *aww, AW_CL, AW_CL) {
45    /*! Opens the "Import Sequences" dialog from the ARB main window (ARB_NTREE)
46     */
47
48    AW_root *awr = aww->get_root();
49
50    awr->awar_int(AWAR_READ_GENOM_DB, IMP_PLAIN_SEQUENCE); // value is overwritten below
51
52    nt_assert(!GLOBAL_gb_src);
53    AWTI_open_import_window(aww->get_root(), "", false, GLOBAL.gb_main, makeRootCallback(nt_seq_load_cb));
54    GLOBAL_gb_src = AWTI_peek_imported_DB();
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_READ_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 = GBT_get_alignment_type_string(GLOBAL.gb_main, ali_name);
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
Note: See TracBrowser for help on using the repository browser.