1 | // =========================================================== // |
---|
2 | // // |
---|
3 | // File : ed4_seq_colors.hxx // |
---|
4 | // Purpose : Sequence foreground coloring. // |
---|
5 | // Viewing differences only. // |
---|
6 | // // |
---|
7 | // Institute of Microbiology (Technical University Munich) // |
---|
8 | // http://www.arb-home.de/ // |
---|
9 | // // |
---|
10 | // =========================================================== // |
---|
11 | |
---|
12 | #ifndef AWT_SEQ_COLORS_HXX |
---|
13 | #define AWT_SEQ_COLORS_HXX |
---|
14 | |
---|
15 | #ifndef ARBTOOLS_H |
---|
16 | #include <arbtools.h> |
---|
17 | #endif |
---|
18 | #ifndef _GLIBCXX_CSTRING |
---|
19 | #include <cstring> |
---|
20 | #endif |
---|
21 | #ifndef ARB_ASSERT_H |
---|
22 | #include <arb_assert.h> |
---|
23 | #endif |
---|
24 | #ifndef _GLIBCXX_CCTYPE |
---|
25 | #include <cctype> |
---|
26 | #endif |
---|
27 | |
---|
28 | #define e4_assert(bed) arb_assert(bed) |
---|
29 | |
---|
30 | class GBDATA; |
---|
31 | class AW_root; |
---|
32 | class AW_window; |
---|
33 | class ED4_sequence_terminal; |
---|
34 | class ED4_species_manager; |
---|
35 | |
---|
36 | class ED4_seq_colors { |
---|
37 | int base_gc; |
---|
38 | void (*cb)(); |
---|
39 | |
---|
40 | public: |
---|
41 | void run_cb() const { if (cb) cb(); } |
---|
42 | void reload(); |
---|
43 | |
---|
44 | // real public |
---|
45 | char char_2_gc[256]; // translate to gc |
---|
46 | char char_2_char[256]; // translate to char |
---|
47 | char char_2_gc_aa[256]; // translate to gc - for aminoacid sequence |
---|
48 | char char_2_char_aa[256]; // translate to char - for aminoacid sequence |
---|
49 | |
---|
50 | ED4_seq_colors(int baseGC, void (*changed_cb)()); |
---|
51 | }; |
---|
52 | |
---|
53 | class ED4_reference : virtual Noncopyable { |
---|
54 | // general: |
---|
55 | char nodiff; |
---|
56 | bool mindcase; |
---|
57 | bool is_gap[256]; |
---|
58 | |
---|
59 | // current reference: |
---|
60 | int ref_len; |
---|
61 | char *reference; |
---|
62 | |
---|
63 | const ED4_sequence_terminal *ref_term; |
---|
64 | |
---|
65 | void update_data(); |
---|
66 | void reset_gap_table(); |
---|
67 | |
---|
68 | public: |
---|
69 | ED4_reference(); |
---|
70 | ~ED4_reference(); |
---|
71 | |
---|
72 | void set_nodiff_indicator(char ind) { nodiff = ind; } |
---|
73 | void set_case_sensitive(bool mindcase_) { mindcase = mindcase_; } |
---|
74 | void set_gap_handling(bool mindgaptype_, const char *gaptypes); |
---|
75 | |
---|
76 | void clear(); |
---|
77 | void define(const ED4_sequence_terminal *rterm); |
---|
78 | |
---|
79 | bool is_set() const { return reference; } |
---|
80 | void expand_to_length(int len); // make sure that reference is at least len long |
---|
81 | |
---|
82 | int convert(char c, int pos) const { |
---|
83 | char r = reference[pos]; |
---|
84 | if (c != r) { |
---|
85 | if (!is_gap[safeCharIndex(c)] || !is_gap[safeCharIndex(r)]) { |
---|
86 | if (mindcase) return c; |
---|
87 | if (tolower(c) != tolower(r)) return c; |
---|
88 | } |
---|
89 | } |
---|
90 | return nodiff; |
---|
91 | } |
---|
92 | bool reference_species_is(const ED4_sequence_terminal *term) const { |
---|
93 | e4_assert(is_set()); // otherwise check makes no sense |
---|
94 | return term == ref_term; |
---|
95 | } |
---|
96 | bool only_show_diff_for(const ED4_sequence_terminal *term) const { |
---|
97 | return is_set() && !reference_species_is(term); |
---|
98 | } |
---|
99 | bool reference_is_a_consensus() const; |
---|
100 | |
---|
101 | void data_changed_cb(ED4_species_manager *calledFrom); |
---|
102 | }; |
---|
103 | |
---|
104 | AW_window *ED4_create_seq_colors_window(AW_root *awr, ED4_seq_colors *sc); |
---|
105 | AW_window *ED4_create_viewDifferences_window(AW_root *awr); |
---|
106 | void ED4_toggle_viewDifferences(AW_root *awr); |
---|
107 | void ED4_viewDifferences_setNewReference(); |
---|
108 | void ED4_viewDifferences_disable(); |
---|
109 | void ED4_viewDifferences_announceTerminalChange(); |
---|
110 | |
---|
111 | |
---|
112 | #else |
---|
113 | #error ed4_seq_colors.hxx included twice |
---|
114 | #endif // AWT_SEQ_COLORS_HXX |
---|