#ifndef SEQEXT_H #define SEQEXT_H 1 #include "Common/Options.h" // for opt::colourSpace #include "Common/Sequence.h" // for codeToBase #include #include #include static const unsigned NUM_BASES = 4; /** Return the complement of the specified base. * The reverse of a single base is a no-op. * If the assembly is in colour space, this is a no-op. */ static inline uint8_t reverseComplement(uint8_t base) { return opt::colourSpace ? base : ~base & 0x3; } /** The adjacent vertices of a Kmer. */ class SeqExt { public: typedef uint8_t Symbol; /** The number of symbols. */ static const unsigned NUM = NUM_BASES; SeqExt() : m_record(0) { }; explicit SeqExt(uint8_t base) : m_record(1< 0; } /** Return whether this kmer has more than one adjacent kmer. */ bool isAmbiguous() const { bool powerOfTwo = (m_record & (m_record - 1)) > 0; return m_record > 0 && powerOfTwo; } /** Return the complementary adjacency. * If the assembly is in colour space, this is a no-op. */ SeqExt complement() const { static const uint8_t complements[16] = { 0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe, 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf }; assert(m_record < 1 << NUM); return opt::colourSpace ? *this : mask(complements[m_record]); } friend std::ostream& operator <<(std::ostream& out, const SeqExt& o) { assert(o.m_record < 1 << NUM); for (unsigned i = 0; i << NUM; ++i) if (o.checkBase(i)) out << codeToBase(i); return out; } private: uint8_t m_record; }; #endif