| 1 | // ================================================================ // |
|---|
| 2 | // // |
|---|
| 3 | // File : pt_split.h // |
|---|
| 4 | // Purpose : // |
|---|
| 5 | // // |
|---|
| 6 | // Coded by Ralf Westram (coder@reallysoft.de) in December 2012 // |
|---|
| 7 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 8 | // http://www.arb-home.de/ // |
|---|
| 9 | // // |
|---|
| 10 | // ================================================================ // |
|---|
| 11 | |
|---|
| 12 | #ifndef PT_SPLIT_H |
|---|
| 13 | #define PT_SPLIT_H |
|---|
| 14 | |
|---|
| 15 | #ifndef PROBE_H |
|---|
| 16 | #include "probe.h" |
|---|
| 17 | #endif |
|---|
| 18 | #ifndef PT_COMPLEMENT_H |
|---|
| 19 | #include "PT_complement.h" |
|---|
| 20 | #endif |
|---|
| 21 | |
|---|
| 22 | class Splits { |
|---|
| 23 | bool valid; |
|---|
| 24 | double split[PT_BASES][PT_BASES]; |
|---|
| 25 | |
|---|
| 26 | static double calc_split(const PT_local *locs, char base, char ref) { |
|---|
| 27 | pt_assert(is_valid_base(base) && is_valid_base(ref)); |
|---|
| 28 | |
|---|
| 29 | int complement = get_complement(base); |
|---|
| 30 | double max_bind = locs->bond[(complement-(int)PT_A)*4 + base-(int)PT_A].val; |
|---|
| 31 | double new_bind = locs->bond[(complement-(int)PT_A)*4 + ref-(int)PT_A].val; |
|---|
| 32 | |
|---|
| 33 | if (new_bind < locs->split) |
|---|
| 34 | return new_bind-max_bind; // negative values indicate split |
|---|
| 35 | // this mismatch splits the probe in several domains |
|---|
| 36 | return max_bind-new_bind; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | public: |
|---|
| 40 | Splits() : valid(false) {} |
|---|
| 41 | Splits(const PT_local *locs) : valid(true) { |
|---|
| 42 | for (int base = PT_QU; base < PT_BASES; ++base) { |
|---|
| 43 | for (int ref = PT_QU; ref < PT_BASES; ++ref) { |
|---|
| 44 | split[base][ref] = calc_split(locs, base, ref); |
|---|
| 45 | } |
|---|
| 46 | } |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | double check(char base, char ref) const { |
|---|
| 50 | pt_assert(valid); |
|---|
| 51 | pt_assert(is_valid_base(base) && is_valid_base(ref)); |
|---|
| 52 | return split[safeCharIndex(base)][safeCharIndex(ref)]; |
|---|
| 53 | } |
|---|
| 54 | }; |
|---|
| 55 | |
|---|
| 56 | #else |
|---|
| 57 | #error pt_split.h included twice |
|---|
| 58 | #endif // PT_SPLIT_H |
|---|