ARB
ed4_seq_colors.hxx
Go to the documentation of this file.
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;
34 class ED4_species_manager;
35 
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  GBDATA *gb_main;
56  char nodiff;
57  bool mindcase;
58  bool is_gap[256];
59 
60  // current reference:
61  int ref_len;
62  char *reference;
63 
64  const ED4_sequence_terminal *ref_term;
65 
66  void update_data();
67  void reset_gap_table();
68 
69 public:
70  ED4_reference(GBDATA *gb_main);
72 
73  void set_nodiff_indicator(char ind) { nodiff = ind; }
74  void set_case_sensitive(bool mindcase_) { mindcase = mindcase_; }
75  void set_gap_handling(bool mindgaptype_, const char *gaptypes);
76 
77  void clear();
78  void define(const ED4_sequence_terminal *rterm);
79 
80  bool is_set() const { return reference; }
81  void expand_to_length(int len); // make sure that reference is at least len long
82 
83  int convert(char c, int pos) const {
84  char r = reference[pos];
85  if (c != r) {
86  if (!is_gap[safeCharIndex(c)] || !is_gap[safeCharIndex(r)]) {
87  if (mindcase) return c;
88  if (tolower(c) != tolower(r)) return c;
89  }
90  }
91  return nodiff;
92  }
93  bool reference_species_is(const ED4_sequence_terminal *term) const {
94  e4_assert(is_set()); // otherwise check makes no sense
95  return term == ref_term;
96  }
97  bool only_show_diff_for(const ED4_sequence_terminal *term) const {
98  return is_set() && !reference_species_is(term);
99  }
100  bool reference_is_a_consensus() const;
101 
102  void data_changed_cb(ED4_species_manager *calledFrom);
103 };
104 
111 
112 
113 #else
114 #error ed4_seq_colors.hxx included twice
115 #endif // AWT_SEQ_COLORS_HXX
AW_window * ED4_create_viewDifferences_window(AW_root *awr)
#define e4_assert(bed)
void ED4_viewDifferences_announceTerminalChange()
bool only_show_diff_for(const ED4_sequence_terminal *term) const
ED4_seq_colors(int baseGC, void(*changed_cb)())
CONSTEXPR_INLINE unsigned char safeCharIndex(char c)
Definition: dupstr.h:73
bool is_set() const
char char_2_char_aa[256]
int convert(char c, int pos) const
char char_2_char[256]
void run_cb() const
void expand_to_length(int len)
void data_changed_cb(ED4_species_manager *calledFrom)
char char_2_gc[256]
void set_nodiff_indicator(char ind)
AW_window * ED4_create_seq_colors_window(AW_root *awr, ED4_seq_colors *sc)
void ED4_viewDifferences_setNewReference()
bool reference_species_is(const ED4_sequence_terminal *term) const
bool reference_is_a_consensus() const
char char_2_gc_aa[256]
ED4_reference(GBDATA *gb_main)
void ED4_toggle_viewDifferences(AW_root *awr)
void ED4_viewDifferences_disable()
void set_case_sensitive(bool mindcase_)
void define(const ED4_sequence_terminal *rterm)
void set_gap_handling(bool mindgaptype_, const char *gaptypes)