27 #define ct_assert(bed) arb_assert(bed)
33 #if defined(DEBUG) && !defined(DEVEL_RELEASE)
34 # define TEST_CHAR_TABLE_INTEGRITY
37 #define MAXCHARTABLE 256
38 #define SHORT_TABLE_ELEM_SIZE 1
39 #define SHORT_TABLE_MAX_VALUE 0xff
40 #define LONG_TABLE_ELEM_SIZE 4
42 #define MAX_INDEX_TABLES 128 // max number of different non-ambiguous indices (into BaseFrequencies::bases_table)
43 #define MAX_TARGET_INDICES 4 // max number of non-ambiguous indices affected by one ambiguous code (4 for 'N' in RNA/DNA, 2 for amino-acids)
44 #define MAX_AMBIGUITY_CODES (1+4+6) // for RNA/DNA (3 for amino-acids)
46 #define MAX_USED_BASES_TABLES 256
74 int legal(
int offset)
const {
return offset>=0 && offset<no_of_entries; }
76 void set_elem_long(
int offset,
int value) {
77 #ifdef TEST_BASES_TABLE
81 no_of_bases.longTable[
offset] = value;
84 void set_elem_short(
int offset,
int value) {
85 #ifdef TEST_BASES_TABLE
90 no_of_bases.shortTable[
offset] = value;
93 int get_elem_long(
int offset)
const {
94 #ifdef TEST_BASES_TABLE
98 return no_of_bases.longTable[
offset];
101 int get_elem_short(
int offset)
const {
102 #ifdef TEST_BASES_TABLE
106 return no_of_bases.shortTable[
offset];
115 int size()
const {
return no_of_entries; }
124 int old = get_elem_short(offset);
126 set_elem_short(offset, old+incr);
129 int old = get_elem_short(offset);
131 set_elem_short(offset, old-decr);
134 int old = get_elem_long(offset);
135 set_elem_long(offset, old+incr);
138 int old = get_elem_long(offset);
140 set_elem_long(offset, old-decr);
153 #if defined(TEST_CHAR_TABLE_INTEGRITY) || defined(ASSERTION_USED)
155 #endif // TEST_CHAR_TABLE_INTEGRITY
173 SepBaseFreqPtr *bases_table;
180 static bool initialized;
182 static uint8_t unitsPerSequence;
186 static int used_bases_tables;
189 static inline void set_char_to_index(
unsigned char c,
int index);
194 void expand_tables();
195 int get_table_entry_size()
const {
198 void prepare_to_add_elements(
int new_sequences) {
200 if (linear_table(0).bigger_table_entry_size_needed(sequenceUnits+new_sequences*unitsPerSequence)) {
206 SepBaseFreq& linear_table(
int c) {
ct_assert(c<used_bases_tables);
return *bases_table[c]; }
207 const SepBaseFreq& linear_table(
int c)
const {
ct_assert(c<used_bases_tables);
return *bases_table[c]; }
210 SepBaseFreq& table(
int c) {
ct_assert(c>0 && c<
MAXCHARTABLE);
return linear_table(char_to_index_tab[c]); }
211 const SepBaseFreq& table(
int c)
const {
ct_assert(c>0 && c<
MAXCHARTABLE);
return linear_table(char_to_index_tab[c]); }
213 static unsigned char index_to_upperChar(
int index) {
return upper_index_chars[index]; }
215 void incr_short(
unsigned char c,
int offset);
216 void decr_short(
unsigned char c,
int offset);
217 void incr_long(
unsigned char c,
int offset);
218 void decr_long(
unsigned char c,
int offset);
220 #if defined(TEST_CHAR_TABLE_INTEGRITY)
228 #if defined(TEST_CHAR_TABLE_INTEGRITY) || defined(ASSERTION_USED)
241 void init(
int maxseqlength);
242 int size()
const {
return bases_table[0]->
size(); }
257 void add(
const char *
string,
int len);
258 void sub(
const char *
string,
int len);
269 #error chartable.h included twice
270 #endif // CHARTABLE_H
#define SHORT_TABLE_MAX_VALUE
void add(const SepBaseFreq &other, int start, int end)
char * build_consensus_string(const ConsensusBuildParams &cbp) const
BaseFrequencies(int maxseqlength=0)
CONSTEXPR_INLINE unsigned char safeCharIndex(char c)
void change_table_length(int new_length, int default_entry)
bool bigger_table_entry_size_needed(int new_max_count)
char * build_consensus_string(PosRange r, const ConsensusBuildParams &cbp) const
void change_table_length(int new_length)
int firstDifference(const SepBaseFreq &other, int start, int end, int *firstDifferentPos) const
double max_frequency_at(int column, bool ignore_gaps) const
void dec_short(int offset, int decr)
#define MAX_TARGET_INDICES
uint8_t index[MAX_TARGET_INDICES]
static HelixNrInfo * start
void inc_short(int offset, int incr)
static void setup(const char *gap_chars, GB_alignment_type ali_type_)
void init(int maxseqlength)
void sub_and_add(const BaseFrequencies &Sub, const BaseFrequencies &Add, PosRange range)
void inc_long(int offset, int incr)
static bool isGap(char c)
unsigned char * shortTable
const PosRange * changed_range(const BaseFrequencies &other) const
SepBaseFreq(int maxseqlength)
void bases_and_gaps_at(int column, int *bases, int *gaps) const
void dec_long(int offset, int decr)
#define LONG_TABLE_ELEM_SIZE
void expand_table_entry_size()
#define SHORT_TABLE_ELEM_SIZE
int lastDifference(const SepBaseFreq &other, int start, int end, int *lastDifferentPos) const
void sub(const SepBaseFreq &other, int start, int end)
int get_table_entry_size() const
#define MAX_USED_BASES_TABLES
int operator[](int offset) const
void sub_and_add(const SepBaseFreq &Sub, const SepBaseFreq &Add, PosRange range)
void build_consensus_string_to(char *consensus_string, ExplicitRange range, const ConsensusBuildParams &BK) const
#define MAX_AMBIGUITY_CODES
int added_sequences() const