| 1 | ///////////////////////////////////////////////////////////////// |
|---|
| 2 | ///////////////////////////////////////////////////////////////// |
|---|
| 3 | // // |
|---|
| 4 | // FILENAME: phylo.hxx // |
|---|
| 5 | // // |
|---|
| 6 | ///////////////////////////////////////////////////////////////// |
|---|
| 7 | // // |
|---|
| 8 | // contains: abstract classes and // |
|---|
| 9 | // global needed definitions,declarations and // |
|---|
| 10 | // functions // |
|---|
| 11 | // // |
|---|
| 12 | ///////////////////////////////////////////////////////////////// |
|---|
| 13 | ///////////////////////////////////////////////////////////////// |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | #ifndef _CPP_CSTDIO |
|---|
| 17 | #include <cstdio> |
|---|
| 18 | #endif |
|---|
| 19 | #ifndef ARBDB_H |
|---|
| 20 | #include <arbdb.h> |
|---|
| 21 | #endif |
|---|
| 22 | #ifndef ARBDBT_H |
|---|
| 23 | #include <arbdbt.h> |
|---|
| 24 | #endif |
|---|
| 25 | #ifndef AWT_TREE_HXX |
|---|
| 26 | #include <awt_tree.hxx> |
|---|
| 27 | #endif |
|---|
| 28 | |
|---|
| 29 | #ifndef ARB_ASSERT_H |
|---|
| 30 | #include <arb_assert.h> |
|---|
| 31 | #endif |
|---|
| 32 | |
|---|
| 33 | #ifndef PH_FILTER_HXX |
|---|
| 34 | #include "PH_filter.hxx" |
|---|
| 35 | #endif |
|---|
| 36 | |
|---|
| 37 | #define ph_assert(cond) arb_assert(cond) |
|---|
| 38 | |
|---|
| 39 | enum { |
|---|
| 40 | DONT_COUNT = 0, |
|---|
| 41 | SKIP_COLUMN_IF_MAX = 1, |
|---|
| 42 | SKIP_COLUMN_IF_OCCUR = 2, |
|---|
| 43 | COUNT_DONT_USE_MAX = 3, |
|---|
| 44 | TREAT_AS_UPPERCASE = 4, |
|---|
| 45 | TREAT_AS_REGULAR = 5, |
|---|
| 46 | |
|---|
| 47 | FILTER_MODES, // has to be last! |
|---|
| 48 | }; |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | #define PH_DB_CACHE_SIZE 2000000 |
|---|
| 52 | |
|---|
| 53 | #define AP_F_LOADED ((AW_active)1) |
|---|
| 54 | #define AP_F_NLOADED ((AW_active)2) |
|---|
| 55 | #define AP_F_SEQUENCES ((AW_active)4) |
|---|
| 56 | #define AP_F_MATRIX ((AW_active)8) |
|---|
| 57 | #define AP_F_TREE ((AW_active)16) |
|---|
| 58 | #define AP_F_ALL ((AW_active)-1) |
|---|
| 59 | |
|---|
| 60 | #define PH_CORRECTION_BANDELT_STRING "bandelt" |
|---|
| 61 | |
|---|
| 62 | #define NIL 0 |
|---|
| 63 | |
|---|
| 64 | // matrix definitions |
|---|
| 65 | #define PH_TRANSFORMATION_JUKES_CANTOR_STRING "J+C" |
|---|
| 66 | #define PH_TRANSFORMATION_KIMURA_STRING "KIMURA" |
|---|
| 67 | #define PH_TRANSFORMATION_TAJIMA_NEI_STRING "T+N" |
|---|
| 68 | #define PH_TRANSFORMATION_TAJIMA_NEI_PAIRWISE_STRING "T+N-P" |
|---|
| 69 | #define PH_TRANSFORMATION_BANDELT_STRING "B" |
|---|
| 70 | #define PH_TRANSFORMATION_BANDELT_JC_STRING "B+J+C" |
|---|
| 71 | #define PH_TRANSFORMATION_BANDELT2_STRING "B2" |
|---|
| 72 | #define PH_TRANSFORMATION_BANDELT2_JC_STRING "B2+J+C" |
|---|
| 73 | |
|---|
| 74 | typedef enum { |
|---|
| 75 | PH_CORRECTION_NONE, |
|---|
| 76 | PH_CORRECTION_BANDELT |
|---|
| 77 | } PH_CORRECTION; |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | enum { |
|---|
| 81 | PH_GC_0, |
|---|
| 82 | PH_GC_1, |
|---|
| 83 | PH_GC_0_DRAG |
|---|
| 84 | }; |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | extern GBDATA *GLOBAL_gb_main; |
|---|
| 88 | |
|---|
| 89 | // make awars : |
|---|
| 90 | void PH_create_matrix_variables(AW_root *aw_root, AW_default aw_def); |
|---|
| 91 | void PH_create_filter_variables(AW_root *aw_root, AW_default aw_def); |
|---|
| 92 | |
|---|
| 93 | AW_window *PH_create_matrix_window(AW_root *aw_root); |
|---|
| 94 | AW_window *PH_create_filter_window(AW_root *aw_root); |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | enum display_type {NONE,species_dpy,filter_dpy,matrix_dpy,tree_dpy}; |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | typedef double AP_FLOAT; |
|---|
| 102 | |
|---|
| 103 | typedef enum { |
|---|
| 104 | PH_TRANSFORMATION_NONE, |
|---|
| 105 | PH_TRANSFORMATION_JUKES_CANTOR, |
|---|
| 106 | PH_TRANSFORMATION_KIMURA, |
|---|
| 107 | PH_TRANSFORMATION_TAJIMA_NEI, |
|---|
| 108 | PH_TRANSFORMATION_TAJIMA_NEI_PAIRWISE, |
|---|
| 109 | PH_TRANSFORMATION_BANDELT, |
|---|
| 110 | PH_TRANSFORMATION_BANDELT_JC, |
|---|
| 111 | PH_TRANSFORMATION_BANDELT2, |
|---|
| 112 | PH_TRANSFORMATION_BANDELT2_JC} PH_TRANSFORMATION; |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | // -------------------------- |
|---|
| 116 | // class definitions |
|---|
| 117 | // -------------------------- |
|---|
| 118 | |
|---|
| 119 | class PH_root { |
|---|
| 120 | private: |
|---|
| 121 | char *use; |
|---|
| 122 | |
|---|
| 123 | public: |
|---|
| 124 | class AWT_graphic *display; |
|---|
| 125 | GB_ERROR open(const char *db_server); |
|---|
| 126 | GBDATA *gb_main; |
|---|
| 127 | }; |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | long AP_timer(void); |
|---|
| 133 | |
|---|
| 134 | GBT_TREE *neighbourjoining(char **names, AP_FLOAT **m, long size, size_t structure_size); |
|---|
| 135 | |
|---|
| 136 | ///////////////////////////////////////////////////////////////// |
|---|
| 137 | // // |
|---|
| 138 | // class_name : PHDATA // |
|---|
| 139 | // // |
|---|
| 140 | // description: connection to database: // |
|---|
| 141 | // pointers to all elements and importand values // |
|---|
| 142 | // of the database // |
|---|
| 143 | // // |
|---|
| 144 | // note: // |
|---|
| 145 | // // |
|---|
| 146 | // dependencies: // |
|---|
| 147 | // // |
|---|
| 148 | ///////////////////////////////////////////////////////////////// |
|---|
| 149 | |
|---|
| 150 | struct elem; |
|---|
| 151 | |
|---|
| 152 | class PHDATA { |
|---|
| 153 | private: |
|---|
| 154 | struct PHENTRY |
|---|
| 155 | { |
|---|
| 156 | unsigned int key; |
|---|
| 157 | char *name; |
|---|
| 158 | char *full_name; |
|---|
| 159 | GBDATA *gb_species_data_ptr; |
|---|
| 160 | struct PHENTRY *next; |
|---|
| 161 | struct PHENTRY *prev; |
|---|
| 162 | int group_members; /* >0: this elem is grouphead */ |
|---|
| 163 | struct elem *first_member; /* !=NULL: elem is grouphead */ |
|---|
| 164 | bool selected; |
|---|
| 165 | }; |
|---|
| 166 | unsigned int last_key_number; |
|---|
| 167 | long seq_len; |
|---|
| 168 | |
|---|
| 169 | AW_root *aw_root; // only link |
|---|
| 170 | |
|---|
| 171 | public: |
|---|
| 172 | GBDATA *gb_main; |
|---|
| 173 | char *use; |
|---|
| 174 | struct PHENTRY *entries; |
|---|
| 175 | struct PHENTRY **hash_elements; |
|---|
| 176 | unsigned int nentries; // total number of entries |
|---|
| 177 | static PHDATA *ROOT; // 'global' pointer |
|---|
| 178 | AP_smatrix *distance_table; // weights between different characters |
|---|
| 179 | AP_smatrix *matrix; // calculated matrix |
|---|
| 180 | float *markerline; |
|---|
| 181 | |
|---|
| 182 | PHDATA(AW_root *awr); |
|---|
| 183 | ~PHDATA(void); |
|---|
| 184 | |
|---|
| 185 | char *load(char *use); // open database and get pointers to it |
|---|
| 186 | char *unload(void); |
|---|
| 187 | GB_ERROR save(char *filename); |
|---|
| 188 | void print(void); |
|---|
| 189 | GB_ERROR calculate_matrix(const char *cancel, double alpha, PH_TRANSFORMATION transformation); |
|---|
| 190 | long get_seq_len(void) { return seq_len; }; |
|---|
| 191 | |
|---|
| 192 | }; |
|---|
| 193 | |
|---|
| 194 | |
|---|