Skip to content

Commit fa608d8

Browse files
committed
feat: extract adjSeq to be configurable
1 parent 1533a91 commit fa608d8

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

src/linclust/kmermatcher.h

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,37 @@ struct SequencePosition{
4747
}
4848
};
4949

50-
template <typename T>
51-
struct __attribute__((__packed__))KmerPosition {
50+
template <bool Include>
51+
struct AdjacentSeqArray {
52+
void setAdjacentSeq(int index, const unsigned char val) {
53+
adjacentSeq[index] = val;
54+
}
55+
unsigned char getAdjacentSeq(int index) {
56+
return adjacentSeq[index];
57+
}
58+
59+
private:
60+
unsigned char adjacentSeq[6];
61+
};
62+
63+
// save memory when adjacent sequence is unused
64+
template <>
65+
struct AdjacentSeqArray<false> {
66+
void setAdjacentSeq(const int index, const unsigned char val) {
67+
Debug(Debug::ERROR) << "Invalid write attempt at adjacent sequence array";
68+
};
69+
unsigned char getAdjacentSeq(int index) {
70+
Debug(Debug::ERROR) << "Invalid read attempt at adjacent sequence array";
71+
return '\0';
72+
}
73+
};
74+
75+
template <typename T, bool IncludeAdjacentSeq>
76+
struct __attribute__((__packed__))KmerPosition : public AdjacentSeqArray<IncludeAdjacentSeq> {
5277
size_t kmer;
5378
unsigned int id;
5479
T seqLen;
5580
T pos;
56-
unsigned char adjacentSeq[6];
5781

5882
static bool compareRepSequenceAndIdAndPos(const KmerPosition<T> &first, const KmerPosition<T> &second){
5983
if(first.kmer < second.kmer )

0 commit comments

Comments
 (0)