| 1 | // ================================================================ // |
|---|
| 2 | // // |
|---|
| 3 | // File : MostLikelySeq.hxx // |
|---|
| 4 | // Purpose : // |
|---|
| 5 | // // |
|---|
| 6 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 7 | // http://www.arb-home.de/ // |
|---|
| 8 | // // |
|---|
| 9 | // ================================================================ // |
|---|
| 10 | |
|---|
| 11 | #ifndef MOSTLIKELYSEQ_HXX |
|---|
| 12 | #define MOSTLIKELYSEQ_HXX |
|---|
| 13 | |
|---|
| 14 | #ifndef AP_SEQUENCE_HXX |
|---|
| 15 | #include <AP_sequence.hxx> |
|---|
| 16 | #endif |
|---|
| 17 | |
|---|
| 18 | extern class DNA_Table { |
|---|
| 19 | char char_to_enum_table[256]; |
|---|
| 20 | public: |
|---|
| 21 | DNA_Base char_to_enum(char i) { |
|---|
| 22 | return (DNA_Base)char_to_enum_table[(unsigned char)i]; |
|---|
| 23 | } |
|---|
| 24 | DNA_Table(); |
|---|
| 25 | } dna_table; |
|---|
| 26 | |
|---|
| 27 | const size_t ST_MAX_SEQ_PART = 256; /* should be greater than the editor width (otherwise extrem performance penalties) |
|---|
| 28 | * (Please note: this value has as well a small influence on the calculated results) |
|---|
| 29 | */ |
|---|
| 30 | |
|---|
| 31 | const int ST_BUCKET_SIZE = 16; // at minimum ST_BUCKET_SIZE characters are calculated per call |
|---|
| 32 | const int LD_BUCKET_SIZE = 4; // log dualis of ST_BUCKET_SIZE |
|---|
| 33 | |
|---|
| 34 | class ST_ML; |
|---|
| 35 | |
|---|
| 36 | class MostLikelySeq : public AP_sequence { // derived from a Noncopyable |
|---|
| 37 | /*! contains existing sequence or ancestor sequence |
|---|
| 38 | * as max. likelihood vectors |
|---|
| 39 | */ |
|---|
| 40 | public: |
|---|
| 41 | static ST_base_vector *tmp_out; // len = alignment length (@@@ could be member of ST_ML ? ) |
|---|
| 42 | |
|---|
| 43 | private: |
|---|
| 44 | ST_ML *st_ml; // link to a global ST object (@@@ could be static) |
|---|
| 45 | ST_base_vector *sequence; // A part of the sequence |
|---|
| 46 | bool up_to_date; |
|---|
| 47 | public: |
|---|
| 48 | // @@@ move the 2 following members into one new class and put one pointer here |
|---|
| 49 | ST_ML_Color *color_out; |
|---|
| 50 | int *color_out_valid_till; // color_out is valid up to |
|---|
| 51 | |
|---|
| 52 | private: |
|---|
| 53 | AP_FLOAT count_weighted_bases() const; |
|---|
| 54 | |
|---|
| 55 | void set(const char *sequence); |
|---|
| 56 | void unset(); |
|---|
| 57 | |
|---|
| 58 | public: |
|---|
| 59 | |
|---|
| 60 | MostLikelySeq(const AliView *aliview, ST_ML *st_ml_); |
|---|
| 61 | ~MostLikelySeq(); |
|---|
| 62 | |
|---|
| 63 | bool is_up_to_date() const { return up_to_date; } |
|---|
| 64 | |
|---|
| 65 | AP_sequence *dup() const; |
|---|
| 66 | AP_FLOAT combine(const AP_sequence* lefts, const AP_sequence *rights, char *mutation_per_site = 0); |
|---|
| 67 | void partial_match(const AP_sequence* part, long *overlap, long *penalty) const; |
|---|
| 68 | |
|---|
| 69 | GB_ERROR bind_to_species(GBDATA *gb_species); |
|---|
| 70 | void unbind_from_species(bool remove_callbacks); |
|---|
| 71 | GBDATA *get_bound_species_data() const { return AP_sequence::get_bound_species_data(); } |
|---|
| 72 | |
|---|
| 73 | void sequence_change(); // sequence has changed in db |
|---|
| 74 | void set_sequence(); // start at st_ml->base |
|---|
| 75 | |
|---|
| 76 | void calculate_ancestor(const MostLikelySeq *lefts, double leftl, const MostLikelySeq *rights, double rightl); |
|---|
| 77 | void forget_sequence() { up_to_date = false; } |
|---|
| 78 | |
|---|
| 79 | void calc_out(const MostLikelySeq *sequence_of_brother, double dist); |
|---|
| 80 | void print(); |
|---|
| 81 | }; |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | #else |
|---|
| 85 | #error MostLikelySeq.hxx included twice |
|---|
| 86 | #endif // MOSTLIKELYSEQ_HXX |
|---|