The adjacent vertices of a Kmer. */
| 20 | |
| 21 | /** The adjacent vertices of a Kmer. */ |
| 22 | class SeqExt |
| 23 | { |
| 24 | public: |
| 25 | typedef uint8_t Symbol; |
| 26 | |
| 27 | /** The number of symbols. */ |
| 28 | static const unsigned NUM = NUM_BASES; |
| 29 | |
| 30 | SeqExt() : m_record(0) { }; |
| 31 | explicit SeqExt(uint8_t base) : m_record(1<<base) { }; |
| 32 | |
| 33 | /** Return a SeqExt with the specified bits set. */ |
| 34 | static SeqExt mask(uint8_t bits) |
| 35 | { |
| 36 | SeqExt ext; |
| 37 | ext.m_record = bits; |
| 38 | return ext; |
| 39 | } |
| 40 | |
| 41 | /** Return the out degree. */ |
| 42 | unsigned outDegree() |
| 43 | { |
| 44 | assert(m_record < 16); |
| 45 | static const uint8_t popcount[16] = { |
| 46 | 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 |
| 47 | }; |
| 48 | return popcount[m_record]; |
| 49 | } |
| 50 | |
| 51 | /** Set the specified adjacency. */ |
| 52 | void setBase(uint8_t base) |
| 53 | { |
| 54 | m_record |= 1 << base; |
| 55 | } |
| 56 | |
| 57 | /** Clear the specified adjacency. */ |
| 58 | void clearBase(uint8_t base) |
| 59 | { |
| 60 | m_record &= ~(1 << base); |
| 61 | } |
| 62 | |
| 63 | /** Remove the specified edges. */ |
| 64 | void clear(SeqExt ext) |
| 65 | { |
| 66 | m_record &= ~ext.m_record; |
| 67 | } |
| 68 | |
| 69 | /** Return wheter the specified base is adjacent. */ |
| 70 | bool checkBase(uint8_t base) const |
| 71 | { |
| 72 | return m_record & (1 << base); |
| 73 | } |
| 74 | |
| 75 | /** Clear all adjacency. */ |
| 76 | void clear() |
| 77 | { |
| 78 | m_record = 0; |
| 79 | } |
nothing calls this directly
no test coverage detected