16 for (
int i = 0; i<256; i++) count[i] = 0;
21 string::const_iterator e = line.end();
22 for (string::const_iterator i = line.begin(); i != e; ++i) {
23 ++count[
static_cast<unsigned char>(*i)];
35 for (
int i = 0; i<
BC_ALL; ++i) all += count[i];
37 if (count[BC_ALL] == 0) {
43 catchUpWithLineCounter();
47 for (
int i = 0; i<
BC_ALL; ++i) all += count[i];
50 if (count[BC_ALL] != all) {
51 throw GBS_global_string(
"Overall bp (=%zu) does not match sum (=%zu) of single bases (Occurrence: '%s')",
52 count[BC_ALL], all, source.c_str());
56 void BaseCounter::catchUpWithLineCounter()
const {
57 if (!char_count.isNull()) {
63 size_t *mucount =
const_cast<size_t*
>(count);
65 static const unsigned char normalChars[] =
"aAcCgGtTuU";
69 for (
unsigned i = 0; normalChars[i]; ++i) {
70 size_t bp = cc.
getCount(normalChars[i]);
71 mucount[normalBase[i]] += bp;
92 catchUpWithLineCounter();
93 other.catchUpWithLineCounter();
95 checkOverallCounter();
99 if (count[i] != other.count[i]) {
100 string error =
"Base counter mismatch";
101 error = error+
"\n "+source+
"<>"+other.source;
104 if (count[i] != other.count[i]) {
107 if (i ==
BC_OTHER) whichCounter =
"other";
108 else if (i ==
BC_ALL) whichCounter =
"overall";
109 else whichCounter =
"ACGT"[i];
111 error = error+
"\n "+whichCounter+
": "+
GBS_global_string(
"%zu <> %zu", count[i], other.count[i]);
129 size_t len = baseCounter.getCount(
BC_ALL);
130 seq =
new char[len+1];
133 stringVectorCIter e = lines.end();
135 for (stringVectorCIter i = lines.begin(); i != e; ++i) {
136 size_t ilen = i->length();
137 memcpy(sp, i->c_str(), ilen);
142 size_t stored = sp-
seq;
void calcOverallCounter()
const char * GBS_global_string(const char *templat,...)
void expectEqual(const BaseCounter &other) const
size_t getCount(unsigned char idx) const
void countChars(const std::string &line)
static void error(const char *msg)
void checkOverallCounter() const
const char * getSequence() const