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

Last change on this file was 11512, 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 <awt.hxx>
14#include <dbui.h>
15#include <GEN.hxx>
16#include <awti_import.hxx>
17#include <awt_canvas.hxx>
18#include <mg_merge.hxx>
19#include <aw_awar.hxx>
20#include <aw_root.hxx>
21#include <arbdbt.h>
22#include <macros.hxx>
23
24static void nt_seq_load_cb(AW_root *awr) {
25    GLOBAL_gb_dst     = GLOBAL.gb_main;
26    AW_window *aww    = DBUI::create_species_query_window(awr, GLOBAL.gb_main);
27    DBUI::unquery_all();
28    GB_ERROR   error  = MERGE_sequences_simple(awr);
29    if (!error) error = NT_format_all_alignments(GLOBAL.gb_main);
30    DBUI::query_update_list();
31    if (!error) aww->activate();
32
33    AWTI_cleanup_importer(); // closes import DB
34
35    GLOBAL_gb_src = NULL;
36    GLOBAL_gb_dst = NULL;
37}
38
39
40void NT_import_sequences(AW_window *aww, AW_CL, AW_CL) {
41    /*! Opens the "Import Sequences" dialog from the ARB main window (ARB_NTREE)
42     */
43
44    AW_root *awr = aww->get_root();
45
46    awr->awar_int(AWAR_READ_GENOM_DB, IMP_PLAIN_SEQUENCE); // value is overwritten below
47
48    nt_assert(!GLOBAL_gb_src);
49    AWTI_open_import_window(aww->get_root(), "", false, GLOBAL.gb_main, makeRootCallback(nt_seq_load_cb));
50    GLOBAL_gb_src = AWTI_peek_imported_DB();
51
52    nt_assert(got_macro_ability(awr));
53
54    // change awar values (import window just opened!)
55
56    int gb_main_is_genom_db;
57    {
58        GB_transaction t1(GLOBAL.gb_main);
59        GB_transaction t2(GLOBAL_gb_src);
60
61        gb_main_is_genom_db = GEN_is_genome_db(GLOBAL.gb_main, 0);
62        IF_ASSERTION_USED(int gb_merge_is_genom_db =) GEN_is_genome_db(GLOBAL_gb_src, gb_main_is_genom_db);
63
64        nt_assert(gb_main_is_genom_db == gb_merge_is_genom_db);
65    }
66
67
68    awr->awar(AWAR_READ_GENOM_DB)->write_int(gb_main_is_genom_db ? IMP_GENOME_FLATFILE : IMP_PLAIN_SEQUENCE);
69
70    {
71        GB_transaction ta(GLOBAL.gb_main);
72        char *ali_name = GBT_get_default_alignment(GLOBAL.gb_main);
73        char *ali_type = GBT_get_alignment_type_string(GLOBAL.gb_main, ali_name);
74
75        AWTI_import_set_ali_and_type(awr, ali_name, ali_type, GLOBAL.gb_main);
76
77        free(ali_type);
78        free(ali_name);
79    }
80}
81
Note: See TracBrowser for help on using the repository browser.