| 1 | // ================================================================ // |
|---|
| 2 | // // |
|---|
| 3 | // File : awt_nei.hxx // |
|---|
| 4 | // Purpose : // |
|---|
| 5 | // // |
|---|
| 6 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 7 | // http://www.arb-home.de/ // |
|---|
| 8 | // // |
|---|
| 9 | // ================================================================ // |
|---|
| 10 | |
|---|
| 11 | #ifndef AWT_NEI_HXX |
|---|
| 12 | #define AWT_NEI_HXX |
|---|
| 13 | |
|---|
| 14 | #ifndef ARB_ASSERT_H |
|---|
| 15 | #include <arb_assert.h> |
|---|
| 16 | #endif |
|---|
| 17 | |
|---|
| 18 | #define ph_assert(cond) arb_assert(cond) |
|---|
| 19 | |
|---|
| 20 | class PH_NEIGHBOUR_DIST { |
|---|
| 21 | public: |
|---|
| 22 | PH_NEIGHBOUR_DIST(void); |
|---|
| 23 | long i,j; |
|---|
| 24 | AP_FLOAT val; |
|---|
| 25 | PH_NEIGHBOUR_DIST *next, *previous; |
|---|
| 26 | void remove(void) { |
|---|
| 27 | ph_assert(previous); // already removed |
|---|
| 28 | if (next) {next->previous = previous;} |
|---|
| 29 | previous->next = next;previous = 0; |
|---|
| 30 | }; |
|---|
| 31 | |
|---|
| 32 | void add(PH_NEIGHBOUR_DIST *root) { |
|---|
| 33 | next = root->next; |
|---|
| 34 | root->next = this; |
|---|
| 35 | previous = root; |
|---|
| 36 | if (next) next->previous = this; |
|---|
| 37 | }; |
|---|
| 38 | }; |
|---|
| 39 | |
|---|
| 40 | class PH_NEIGHBOURJOINING { |
|---|
| 41 | PH_NEIGHBOUR_DIST **dist_matrix; |
|---|
| 42 | PH_NEIGHBOUR_DIST *dist_list; // array of dist_list lists |
|---|
| 43 | long dist_list_size; |
|---|
| 44 | AP_FLOAT dist_list_corr; |
|---|
| 45 | AP_FLOAT *net_divergence; |
|---|
| 46 | |
|---|
| 47 | long size; |
|---|
| 48 | long *swap_tab; |
|---|
| 49 | long swap_size; |
|---|
| 50 | |
|---|
| 51 | AP_FLOAT get_max_di(AP_FLOAT **m); |
|---|
| 52 | void remove_taxa_from_dist_list(long i); |
|---|
| 53 | void add_taxa_to_dist_list(long j); |
|---|
| 54 | AP_FLOAT get_max_net_divergence(void); |
|---|
| 55 | void remove_taxa_from_swap_tab(long i); |
|---|
| 56 | |
|---|
| 57 | public: |
|---|
| 58 | |
|---|
| 59 | PH_NEIGHBOURJOINING(AP_FLOAT **m, long size); |
|---|
| 60 | ~PH_NEIGHBOURJOINING(void); |
|---|
| 61 | |
|---|
| 62 | void join_nodes(long i,long j,AP_FLOAT &leftl,AP_FLOAT& rightlen); |
|---|
| 63 | void get_min_ij(long& i, long& j); |
|---|
| 64 | void get_last_ij(long& i, long& j); |
|---|
| 65 | AP_FLOAT get_dist(long i, long j); |
|---|
| 66 | }; |
|---|
| 67 | |
|---|
| 68 | #else |
|---|
| 69 | #error awt_nei.hxx included twice |
|---|
| 70 | #endif // AWT_NEI_HXX |
|---|