1 | // =============================================================== // |
---|
2 | // // |
---|
3 | // File : phylo.hxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Institute of Microbiology (Technical University Munich) // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // =============================================================== // |
---|
10 | |
---|
11 | #ifndef PHYLO_HXX |
---|
12 | #define PHYLO_HXX |
---|
13 | |
---|
14 | #ifndef PH_FILTER_HXX |
---|
15 | #include "PH_filter.hxx" |
---|
16 | #endif |
---|
17 | #ifndef AW_BASE_HXX |
---|
18 | #include <aw_base.hxx> |
---|
19 | #endif |
---|
20 | #ifndef ARB_ASSERT_H |
---|
21 | #include <arb_assert.h> |
---|
22 | #endif |
---|
23 | |
---|
24 | #define ph_assert(cond) arb_assert(cond) |
---|
25 | |
---|
26 | #define AWAR_PHYLO_ALIGNMENT "tmp/phyl/alignment" |
---|
27 | #define AWAR_PHYLO_FILTER_FILTER "phyl/filter/filter" |
---|
28 | |
---|
29 | #define AWAR_PHYLO_FILTER_STARTCOL "phyl/filter/startcol" |
---|
30 | #define AWAR_PHYLO_FILTER_STOPCOL "phyl/filter/stopcol" |
---|
31 | #define AWAR_PHYLO_FILTER_MINHOM "phyl/filter/minhom" |
---|
32 | #define AWAR_PHYLO_FILTER_MAXHOM "phyl/filter/maxhom" |
---|
33 | #define AWAR_PHYLO_FILTER_DOT "phyl/filter/point" |
---|
34 | #define AWAR_PHYLO_FILTER_MINUS "phyl/filter/minus" |
---|
35 | #define AWAR_PHYLO_FILTER_AMBIG "phyl/filter/rest" |
---|
36 | #define AWAR_PHYLO_FILTER_LOWER "phyl/filter/lower" |
---|
37 | #define AWAR_PHYLO_FILTER_AUTOCALC "phyl/filter/autocalc" |
---|
38 | |
---|
39 | #define AWAR_PHYLO_MARKERLINENAME "tmp/phylo/markerlinename" |
---|
40 | |
---|
41 | enum FilterMode { |
---|
42 | DONT_COUNT, |
---|
43 | SKIP_COLUMN_IF_MAX, |
---|
44 | SKIP_COLUMN_IF_OCCUR, |
---|
45 | COUNT_DONT_USE_MAX, |
---|
46 | TREAT_AS_UPPERCASE, |
---|
47 | TREAT_AS_REGULAR, |
---|
48 | |
---|
49 | // Note: enum values are saved in properties (do not modify w/o need!) |
---|
50 | // update on changes: PH_main.cxx@filter_text |
---|
51 | }; |
---|
52 | const int FILTER_MODES = TREAT_AS_REGULAR+1; |
---|
53 | |
---|
54 | |
---|
55 | #define PH_DB_CACHE_SIZE 2000000 |
---|
56 | |
---|
57 | enum { |
---|
58 | PH_GC_SEQUENCE, |
---|
59 | PH_GC_MARKER, |
---|
60 | PH_GC_NOT_MARKER, |
---|
61 | PH_GC_DRAG |
---|
62 | }; |
---|
63 | |
---|
64 | enum { |
---|
65 | PH_GC_BOTTOM_TEXT, |
---|
66 | PH_GC_BOTTOM_DRAG |
---|
67 | }; |
---|
68 | |
---|
69 | void PH_create_filter_variables(AW_root *aw_root, AW_default default_file, GBDATA *gb_main); |
---|
70 | AW_window *PH_create_filter_window(AW_root *aw_root); |
---|
71 | |
---|
72 | enum display_type { |
---|
73 | DISP_NONE, // initial |
---|
74 | DISP_SPECIES, // after startup, filter not calculated yet |
---|
75 | DISP_FILTER, // after filter has been calculated |
---|
76 | }; |
---|
77 | |
---|
78 | // --------------------------- |
---|
79 | // class definitions |
---|
80 | |
---|
81 | class PH_root : virtual Noncopyable { |
---|
82 | char *use; |
---|
83 | GBDATA *gb_main; |
---|
84 | |
---|
85 | static PH_root *SINGLETON; |
---|
86 | |
---|
87 | public: |
---|
88 | |
---|
89 | PH_root() : |
---|
90 | use(NULp), |
---|
91 | gb_main(NULp) |
---|
92 | { |
---|
93 | ph_assert(!SINGLETON); |
---|
94 | SINGLETON = this; |
---|
95 | } |
---|
96 | ~PH_root() { |
---|
97 | ph_assert(this == SINGLETON); |
---|
98 | SINGLETON = NULp; |
---|
99 | free(use); |
---|
100 | } |
---|
101 | |
---|
102 | GB_ERROR open(const char *db_server); |
---|
103 | GBDATA *get_gb_main() const { ph_assert(gb_main); return gb_main; } |
---|
104 | }; |
---|
105 | |
---|
106 | |
---|
107 | class PHDATA : virtual Noncopyable { |
---|
108 | // connection to database |
---|
109 | // pointers to all elements and important values of the database |
---|
110 | |
---|
111 | struct PHENTRY : virtual Noncopyable { |
---|
112 | unsigned int key; |
---|
113 | char *name; |
---|
114 | char *full_name; |
---|
115 | GBDATA *gb_species_data_ptr; |
---|
116 | PHENTRY *next; |
---|
117 | PHENTRY *prev; |
---|
118 | |
---|
119 | PHENTRY() : |
---|
120 | key(0), |
---|
121 | name(NULp), |
---|
122 | full_name(NULp), |
---|
123 | gb_species_data_ptr(NULp), |
---|
124 | next(NULp), |
---|
125 | prev(NULp) |
---|
126 | {} |
---|
127 | |
---|
128 | ~PHENTRY() { |
---|
129 | ph_assert(0); // @@@ why not called? |
---|
130 | } |
---|
131 | }; |
---|
132 | |
---|
133 | unsigned int last_key_number; |
---|
134 | long seq_len; |
---|
135 | |
---|
136 | AW_root *aw_root; // only link |
---|
137 | PH_root *ph_root; // only link |
---|
138 | |
---|
139 | PHENTRY *entries; |
---|
140 | |
---|
141 | char *unload(); |
---|
142 | |
---|
143 | public: |
---|
144 | GBDATA *get_gb_main() { return ph_root->get_gb_main(); } |
---|
145 | |
---|
146 | char *use; // @@@ elim (PH_root has same field) |
---|
147 | |
---|
148 | PHENTRY **hash_elements; |
---|
149 | unsigned int nentries; // total number of entries |
---|
150 | |
---|
151 | static PHDATA *ROOT; // 'global' pointer |
---|
152 | |
---|
153 | float *markerline; |
---|
154 | |
---|
155 | PHDATA(AW_root *aw_root_, PH_root *ph_root_) : |
---|
156 | last_key_number(0), |
---|
157 | seq_len(0), |
---|
158 | aw_root(aw_root_), |
---|
159 | ph_root(ph_root_), |
---|
160 | entries(NULp), |
---|
161 | use(NULp), |
---|
162 | hash_elements(NULp), |
---|
163 | nentries(0), |
---|
164 | markerline(NULp) |
---|
165 | {} |
---|
166 | ~PHDATA() { |
---|
167 | unload(); |
---|
168 | } |
---|
169 | |
---|
170 | char *load(char*& use); // open database and get pointers to it |
---|
171 | |
---|
172 | long get_seq_len() { return seq_len; } |
---|
173 | }; |
---|
174 | |
---|
175 | #else |
---|
176 | #error phylo.hxx included twice |
---|
177 | #endif // PHYLO_HXX |
---|