source: tags/ms_r16q3/AWTI/awti_imp_local.hxx

Last change on this file was 14256, checked in by westram, 9 years ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1// ============================================================ //
2//                                                              //
3//   File      : awti_imp_local.hxx                             //
4//   Purpose   : local definitions for import                   //
5//                                                              //
6//   Institute of Microbiology (Technical University Munich)    //
7//   www.arb-home.de                                            //
8//                                                              //
9// ============================================================ //
10
11#ifndef AWTI_IMP_LOCAL_HXX
12#define AWTI_IMP_LOCAL_HXX
13
14#ifndef _GLIBCXX_STRING
15#include <string>
16#endif
17
18#ifndef ARBDBT_H
19#include <arbdbt.h>
20#endif
21#ifndef AWTI_IMPORT_HXX
22#include <awti_import.hxx>
23#endif
24#ifndef ARB_STRARRAY_H
25#include <arb_strarray.h>
26#endif
27
28#define awti_assert(cond) arb_assert(cond)
29
30// more awars defined at awti_import.hxx@AWAR_IMPORT
31#define AWAR_IMPORT_FILEBASE AWAR_IMPORT_TMP_PREFIX "pattern"
32#define AWAR_IMPORT_FILENAME AWAR_IMPORT_FILEBASE "/file_name"
33
34#define AWAR_IMPORT_FORMATBASE   AWAR_IMPORT_TMP_PREFIX "form"
35#define AWAR_IMPORT_FORMATNAME   AWAR_IMPORT_FORMATBASE "/file_name"
36#define AWAR_IMPORT_FORMATFILTER AWAR_IMPORT_FORMATBASE "/filter"
37#define AWAR_IMPORT_FORMATDIR    AWAR_IMPORT_FORMATBASE "/directory"
38
39#define AWAR_IMPORT_ALI            AWAR_IMPORT_TMP_PREFIX "alignment"
40#define AWAR_IMPORT_ALI_TYPE       AWAR_IMPORT_TMP_PREFIX "alignment_type"
41#define AWAR_IMPORT_ALI_PROTECTION AWAR_IMPORT_TMP_PREFIX "alignment_protection"
42
43#define AWTI_IMPORT_CHECK_BUFFER_SIZE 10000
44
45
46struct import_match : virtual Noncopyable {
47    // one for each "MATCH" section of the import format
48
49    char *match;
50
51    // variables get expanded when one of the following variables is used:
52    // (search for 'expandSetVariables')
53    char *aci;
54    char *srt;
55    char *mtag;
56    char *append;
57    char *write;
58    // --------------------
59
60    char     *setvar;
61    GB_TYPES  type;
62    char     *defined_at; // where was match defined
63
64    import_match *next;
65
66    import_match *reverse(import_match *to_append) {
67        import_match *rest = next;
68        next = to_append;
69        return rest ? rest->reverse(this) : this;
70    }
71
72    import_match();
73    ~import_match();
74};
75
76#define IFS_VARIABLES 26                            // 'a'-'z'
77
78class SetVariables {
79    typedef SmartPtr<std::string> StringPtr;
80    StringPtr value[IFS_VARIABLES];
81
82public:
83    SetVariables() {}
84
85    void set(char c, const char *s) {
86        awti_assert(c >= 'a' && c <= 'z');
87        value[c-'a'] = new std::string(s);
88    }
89    const std::string *get(char c) const {
90        awti_assert(c >= 'a' && c <= 'z');
91        StringPtr v = value[c-'a'];
92        return v.isNull() ? NULL : &*v;
93    }
94};
95
96
97struct import_format : virtual Noncopyable {
98    char   *autodetect;
99    char   *system;
100    char   *new_format;
101    size_t  new_format_lineno;
102    size_t  tab;
103
104    char    *begin;
105
106    char   *sequencestart;
107    int     read_this_sequence_line_too;
108    char   *sequenceend;
109    char   *sequencesrt;
110    char   *sequenceaci;
111    char   *filetag;
112    char   *autotag;
113    size_t  sequencecolumn;
114    int     autocreateacc;
115    int     noautonames;
116
117    char *end;
118
119    SetVariables global_variables;                 // values of global variables
120    SetVariables variable_errors;                  // user-defined errors (used when var not set)
121
122    char *b1;
123    char *b2;
124
125    import_match *match;
126
127    import_format();
128    ~import_format();
129};
130
131struct ArbImporter : virtual Noncopyable {
132    import_format *ifo;  // main input format
133    import_format *ifo2; // symlink to input format
134
135    GBDATA *gb_import_main; // import database
136
137    RootCallback after_import_cb;
138
139    StrArray filenames;
140    int      current_file_idx;
141
142    FILE *in;
143    bool  doExit; // whether import window 'close' does exit // @@@ rename (meaning is: import from inside ARB or not)
144
145    GBDATA *gb_main_4_nameserver; // main DB (needed to select nameserver-settings)
146
147    ArbImporter(const RootCallback& after_import_cb_)
148        : ifo(NULL),
149          ifo2(NULL),
150          gb_import_main(NULL),
151          after_import_cb(after_import_cb_),
152          current_file_idx(0),
153          in(NULL),
154          doExit(false),
155          gb_main_4_nameserver(NULL)
156    {
157    }
158
159    ~ArbImporter() {
160        if (gb_import_main) GB_close(gb_import_main);
161        delete ifo;
162        delete ifo2;
163
164        awti_assert(!in);
165    }
166
167    GB_ERROR read_format(const char *file);
168    void detect_format(AW_root *root);
169
170    int       next_file();
171    char     *read_line(int tab, char *sequencestart, char *sequenceend);
172    GB_ERROR  read_data(char *ali_name, int security_write);
173
174    void go(AW_window *aww);
175
176    GBDATA *peekImportDB() {
177        return gb_import_main;
178    }
179    GBDATA *takeImportDB() {
180        GBDATA *gbm    = gb_import_main;
181        gb_import_main = NULL;
182        return gbm;
183    }
184};
185
186
187#else
188#error awti_imp_local.hxx included twice
189#endif // AWTI_IMP_LOCAL_HXX
Note: See TracBrowser for help on using the repository browser.