| 1 |
\hypertarget{Kmer_8hpp_source}{}\doxysection{Kmer.\+hpp} |
| 2 |
\label{Kmer_8hpp_source}\index{src/Kmer.hpp@{src/Kmer.hpp}} |
| 3 |
\mbox{\hyperlink{Kmer_8hpp}{Go to the documentation of this file.}} |
| 4 |
\begin{DoxyCode}{0} |
| 5 |
\DoxyCodeLine{1 \textcolor{preprocessor}{\#ifndef BIFROST\_KMER\_HPP}} |
| 6 |
\DoxyCodeLine{2 \textcolor{preprocessor}{\#define BIFROST\_KMER\_HPP}} |
| 7 |
\DoxyCodeLine{3 } |
| 8 |
\DoxyCodeLine{4 \textcolor{preprocessor}{\#ifndef MAX\_KMER\_SIZE}} |
| 9 |
\DoxyCodeLine{5 \textcolor{preprocessor}{\#define MAX\_KMER\_SIZE 32}} |
| 10 |
\DoxyCodeLine{6 \textcolor{preprocessor}{\#endif}} |
| 11 |
\DoxyCodeLine{7 } |
| 12 |
\DoxyCodeLine{8 \textcolor{preprocessor}{\#ifndef MAX\_GMER\_SIZE}} |
| 13 |
\DoxyCodeLine{9 \textcolor{preprocessor}{\#define MAX\_GMER\_SIZE MAX\_KMER\_SIZE}} |
| 14 |
\DoxyCodeLine{10 \textcolor{preprocessor}{\#endif}} |
| 15 |
\DoxyCodeLine{11 } |
| 16 |
\DoxyCodeLine{12 \textcolor{preprocessor}{\#include <stdint.h>}} |
| 17 |
\DoxyCodeLine{13 \textcolor{preprocessor}{\#include <stdio.h>}} |
| 18 |
\DoxyCodeLine{14 } |
| 19 |
\DoxyCodeLine{15 \textcolor{preprocessor}{\#include <bitset>}} |
| 20 |
\DoxyCodeLine{16 \textcolor{preprocessor}{\#include <cassert>}} |
| 21 |
\DoxyCodeLine{17 \textcolor{preprocessor}{\#include <cstring>}} |
| 22 |
\DoxyCodeLine{18 \textcolor{preprocessor}{\#include <iostream>}} |
| 23 |
\DoxyCodeLine{19 \textcolor{preprocessor}{\#include <string>}} |
| 24 |
\DoxyCodeLine{20 } |
| 25 |
\DoxyCodeLine{21 \textcolor{preprocessor}{\#include "{}Common.hpp"{}}} |
| 26 |
\DoxyCodeLine{22 } |
| 27 |
\DoxyCodeLine{32 \textcolor{keyword}{class }CompressedSequence;} |
| 28 |
\DoxyCodeLine{33 } |
| 29 |
\DoxyCodeLine{42 \textcolor{keyword}{class }\mbox{\hyperlink{classKmer}{Kmer}} \{} |
| 30 |
\DoxyCodeLine{43 } |
| 31 |
\DoxyCodeLine{44 \textcolor{keyword}{friend} \textcolor{keyword}{class }CompressedSequence;} |
| 32 |
\DoxyCodeLine{45 } |
| 33 |
\DoxyCodeLine{46 \textcolor{keyword}{public}:} |
| 34 |
\DoxyCodeLine{47 } |
| 35 |
\DoxyCodeLine{50 \mbox{\hyperlink{classKmer_a5ab9d401261a8bd25968b7be5554bf45}{Kmer}}();} |
| 36 |
\DoxyCodeLine{51 } |
| 37 |
\DoxyCodeLine{56 \mbox{\hyperlink{classKmer_a8b6222680b4b2c7ba854f59bdbddc5b6}{Kmer}}(\textcolor{keyword}{const} \mbox{\hyperlink{classKmer}{Kmer}}\& o);} |
| 38 |
\DoxyCodeLine{57 } |
| 39 |
\DoxyCodeLine{62 \textcolor{keyword}{explicit} \mbox{\hyperlink{classKmer_a1fb825d0a9444de791c5bba652d69f1d}{Kmer}}(\textcolor{keyword}{const} \textcolor{keywordtype}{char}* s);} |
| 40 |
\DoxyCodeLine{63 } |
| 41 |
\DoxyCodeLine{68 \mbox{\hyperlink{classKmer}{Kmer}}\& \mbox{\hyperlink{classKmer_a2b254500deed375ec60bc4588e44050e}{operator=}}(\textcolor{keyword}{const} \mbox{\hyperlink{classKmer}{Kmer}}\& o);} |
| 42 |
\DoxyCodeLine{69 } |
| 43 |
\DoxyCodeLine{72 BFG\_INLINE \textcolor{keywordtype}{void} \mbox{\hyperlink{classKmer_aed7e4989323e49f78e3b0ceeaedc21b4}{set\_deleted}}() \{} |
| 44 |
\DoxyCodeLine{73 } |
| 45 |
\DoxyCodeLine{74 \textcolor{keywordflow}{for} (\textcolor{keywordtype}{size\_t} i = 0; i < MAX\_K/32; ++i) longs[i] = 0xffffffffffffffffULL;} |
| 46 |
\DoxyCodeLine{75 \}} |
| 47 |
\DoxyCodeLine{76 } |
| 48 |
\DoxyCodeLine{79 BFG\_INLINE \textcolor{keywordtype}{void} \mbox{\hyperlink{classKmer_a13f76eacb925e986280191035788bc03}{set\_empty}}() \{} |
| 49 |
\DoxyCodeLine{80 } |
| 50 |
\DoxyCodeLine{81 \textcolor{keywordflow}{for} (\textcolor{keywordtype}{size\_t} i = 0; i < MAX\_K/32; ++i) longs[i] = 0xfffffffffffffffeULL;} |
| 51 |
\DoxyCodeLine{82 \}} |
| 52 |
\DoxyCodeLine{83 } |
| 53 |
\DoxyCodeLine{87 BFG\_INLINE \textcolor{keywordtype}{bool} \mbox{\hyperlink{classKmer_a1bc247ae3a78c166657e2f87a03ab717}{isDeleted}}()\textcolor{keyword}{ const }\{} |
| 54 |
\DoxyCodeLine{88 } |
| 55 |
\DoxyCodeLine{89 \textcolor{keywordflow}{return} (longs[(MAX\_K/32)-\/1] == 0xffffffffffffffffULL);} |
| 56 |
\DoxyCodeLine{90 \}} |
| 57 |
\DoxyCodeLine{91 } |
| 58 |
\DoxyCodeLine{95 BFG\_INLINE \textcolor{keywordtype}{bool} \mbox{\hyperlink{classKmer_a165d359c1eb24ed3d227ffd5b38e458f}{isEmpty}}()\textcolor{keyword}{ const }\{} |
| 59 |
\DoxyCodeLine{96 } |
| 60 |
\DoxyCodeLine{97 \textcolor{keywordflow}{return} (longs[(MAX\_K/32)-\/1] == 0xfffffffffffffffeULL);} |
| 61 |
\DoxyCodeLine{98 \}} |
| 62 |
\DoxyCodeLine{99 } |
| 63 |
\DoxyCodeLine{100 \textcolor{keywordtype}{bool} operator<(\textcolor{keyword}{const} \mbox{\hyperlink{classKmer}{Kmer}}\& o) \textcolor{keyword}{const};} |
| 64 |
\DoxyCodeLine{101 } |
| 65 |
\DoxyCodeLine{107 \textcolor{keywordtype}{bool} \mbox{\hyperlink{classKmer_a7d0f2060f9bda7c9b29a40e1b991ce85}{operator==}}(\textcolor{keyword}{const} \mbox{\hyperlink{classKmer}{Kmer}}\& o) \textcolor{keyword}{const};} |
| 66 |
\DoxyCodeLine{108 } |
| 67 |
\DoxyCodeLine{114 \textcolor{keywordtype}{bool} \mbox{\hyperlink{classKmer_ab859842b0a779eae64aace119eec9244}{operator!=}}(\textcolor{keyword}{const} \mbox{\hyperlink{classKmer}{Kmer}}\& o) \textcolor{keyword}{const};} |
| 68 |
\DoxyCodeLine{115 } |
| 69 |
\DoxyCodeLine{120 BFG\_INLINE uint64\_t \mbox{\hyperlink{classKmer_a11645c016419fec967ab50743cf4c83e}{hash}}(\textcolor{keyword}{const} uint64\_t seed = 0)\textcolor{keyword}{ const }\{} |
| 70 |
\DoxyCodeLine{121 } |
| 71 |
\DoxyCodeLine{122 \textcolor{keywordflow}{return} wyhash(bytes, MAX\_K/4, seed, \_wyp);} |
| 72 |
\DoxyCodeLine{123 \}} |
| 73 |
\DoxyCodeLine{124 } |
| 74 |
\DoxyCodeLine{128 \mbox{\hyperlink{classKmer}{Kmer}} \mbox{\hyperlink{classKmer_a82924425f6f6bd3e1d746f600936781c}{twin}}() \textcolor{keyword}{const};} |
| 75 |
\DoxyCodeLine{129 } |
| 76 |
\DoxyCodeLine{133 \mbox{\hyperlink{classKmer}{Kmer}} \mbox{\hyperlink{classKmer_a2b86fe792388a910a073d9fc4a811779}{rep}}() \textcolor{keyword}{const};} |
| 77 |
\DoxyCodeLine{134 } |
| 78 |
\DoxyCodeLine{141 \mbox{\hyperlink{classKmer}{Kmer}} \mbox{\hyperlink{classKmer_ad21155c7aa0e25973bc8c95047cee78d}{forwardBase}}(\textcolor{keyword}{const} \textcolor{keywordtype}{char} b) \textcolor{keyword}{const};} |
| 79 |
\DoxyCodeLine{142 } |
| 80 |
\DoxyCodeLine{149 \mbox{\hyperlink{classKmer}{Kmer}} \mbox{\hyperlink{classKmer_a7670003b3027c3401454dc700ca5b3c5}{backwardBase}}(\textcolor{keyword}{const} \textcolor{keywordtype}{char} b) \textcolor{keyword}{const};} |
| 81 |
\DoxyCodeLine{150 } |
| 82 |
\DoxyCodeLine{155 \textcolor{keywordtype}{void} \mbox{\hyperlink{classKmer_a605ec250880652507ae279f348046936}{selfForwardBase}}(\textcolor{keyword}{const} \textcolor{keywordtype}{char} b);} |
| 83 |
\DoxyCodeLine{156 } |
| 84 |
\DoxyCodeLine{161 \textcolor{keywordtype}{char} \mbox{\hyperlink{classKmer_af23c636ad07801e49b09565513da451c}{getChar}}(\textcolor{keyword}{const} \textcolor{keywordtype}{size\_t} offset) \textcolor{keyword}{const};} |
| 85 |
\DoxyCodeLine{162 } |
| 86 |
\DoxyCodeLine{169 \textcolor{keywordtype}{bool} \mbox{\hyperlink{classKmer_acd1e99defb65ea71c7cf804d3f1e3dc4}{setChar}}(\textcolor{keyword}{const} \textcolor{keywordtype}{size\_t} offset, \textcolor{keyword}{const} \textcolor{keywordtype}{char} b);} |
| 87 |
\DoxyCodeLine{170 } |
| 88 |
\DoxyCodeLine{174 \textcolor{keywordtype}{void} \mbox{\hyperlink{classKmer_a69125d95f234312a670b970cd14d9ef3}{toString}}(\textcolor{keywordtype}{char} *s) \textcolor{keyword}{const};} |
| 89 |
\DoxyCodeLine{175 } |
| 90 |
\DoxyCodeLine{179 std::string \mbox{\hyperlink{classKmer_ae394adf5587405c5204a07df6b95cebb}{toString}}() \textcolor{keyword}{const};} |
| 91 |
\DoxyCodeLine{180 } |
| 92 |
\DoxyCodeLine{187 \textcolor{keywordtype}{bool} \mbox{\hyperlink{classKmer_afeabfe32515eb278bdab47d5434e8a92}{write}}(std::ostream\& stream\_out) \textcolor{keyword}{const};} |
| 93 |
\DoxyCodeLine{188 } |
| 94 |
\DoxyCodeLine{195 \textcolor{keywordtype}{bool} \mbox{\hyperlink{classKmer_ad7e63cd4337067ac247a52f4b8235204}{read}}(std::istream\& stream\_in);} |
| 95 |
\DoxyCodeLine{196 } |
| 96 |
\DoxyCodeLine{201 \textcolor{keyword}{static} \textcolor{keywordtype}{void} \mbox{\hyperlink{classKmer_ae76504dbc6fe791fadc50667852a62c8}{set\_k}}(\textcolor{keyword}{const} \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} \_k);} |
| 97 |
\DoxyCodeLine{202 } |
| 98 |
\DoxyCodeLine{203 \textcolor{keyword}{static} \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} k;} |
| 99 |
\DoxyCodeLine{204 } |
| 100 |
\DoxyCodeLine{205 \textcolor{keyword}{private}:} |
| 101 |
\DoxyCodeLine{206 } |
| 102 |
\DoxyCodeLine{207 \textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} MAX\_K = MAX\_KMER\_SIZE;} |
| 103 |
\DoxyCodeLine{208 } |
| 104 |
\DoxyCodeLine{209 \textcolor{keyword}{union }\{} |
| 105 |
\DoxyCodeLine{210 } |
| 106 |
\DoxyCodeLine{211 uint8\_t bytes[MAX\_K/4];} |
| 107 |
\DoxyCodeLine{212 uint64\_t longs[MAX\_K/32];} |
| 108 |
\DoxyCodeLine{213 \};} |
| 109 |
\DoxyCodeLine{214 } |
| 110 |
\DoxyCodeLine{215 \textcolor{keywordtype}{void} set\_kmer(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *s);} |
| 111 |
\DoxyCodeLine{216 } |
| 112 |
\DoxyCodeLine{217 \mbox{\hyperlink{classKmer}{Kmer}} getLink(\textcolor{keyword}{const} \textcolor{keywordtype}{size\_t} index) \textcolor{keyword}{const};} |
| 113 |
\DoxyCodeLine{218 } |
| 114 |
\DoxyCodeLine{219 std::string getBinary() \textcolor{keyword}{const};} |
| 115 |
\DoxyCodeLine{220 \};} |
| 116 |
\DoxyCodeLine{221 } |
| 117 |
\DoxyCodeLine{222 } |
| 118 |
\DoxyCodeLine{223 \textcolor{keyword}{struct }\mbox{\hyperlink{structKmerHash}{KmerHash}} \{} |
| 119 |
\DoxyCodeLine{224 } |
| 120 |
\DoxyCodeLine{225 \textcolor{keyword}{inline} \textcolor{keywordtype}{size\_t} operator()(\textcolor{keyword}{const} \mbox{\hyperlink{classKmer}{Kmer}}\& km)\textcolor{keyword}{ const }\{} |
| 121 |
\DoxyCodeLine{226 } |
| 122 |
\DoxyCodeLine{227 \textcolor{keywordflow}{return} km.\mbox{\hyperlink{classKmer_a11645c016419fec967ab50743cf4c83e}{hash}}();} |
| 123 |
\DoxyCodeLine{228 \}} |
| 124 |
\DoxyCodeLine{229 \};} |
| 125 |
\DoxyCodeLine{230 } |
| 126 |
\DoxyCodeLine{232 \textcolor{keyword}{class }Minimizer \{} |
| 127 |
\DoxyCodeLine{233 } |
| 128 |
\DoxyCodeLine{234 \textcolor{keyword}{public}:} |
| 129 |
\DoxyCodeLine{235 } |
| 130 |
\DoxyCodeLine{236 Minimizer();} |
| 131 |
\DoxyCodeLine{237 Minimizer(\textcolor{keyword}{const} Minimizer\& o);} |
| 132 |
\DoxyCodeLine{238 \textcolor{keyword}{explicit} Minimizer(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *s);} |
| 133 |
\DoxyCodeLine{239 } |
| 134 |
\DoxyCodeLine{240 Minimizer\& operator=(\textcolor{keyword}{const} Minimizer\& o);} |
| 135 |
\DoxyCodeLine{241 } |
| 136 |
\DoxyCodeLine{242 \textcolor{keywordtype}{bool} operator<(\textcolor{keyword}{const} Minimizer\& o) \textcolor{keyword}{const};} |
| 137 |
\DoxyCodeLine{243 \textcolor{keywordtype}{bool} operator==(\textcolor{keyword}{const} Minimizer\& o) \textcolor{keyword}{const};} |
| 138 |
\DoxyCodeLine{244 \textcolor{keywordtype}{bool} operator!=(\textcolor{keyword}{const} Minimizer\& o) \textcolor{keyword}{const};} |
| 139 |
\DoxyCodeLine{245 } |
| 140 |
\DoxyCodeLine{246 \textcolor{keywordtype}{void} set\_minimizer(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *s);} |
| 141 |
\DoxyCodeLine{247 } |
| 142 |
\DoxyCodeLine{248 BFG\_INLINE uint64\_t hash(\textcolor{keyword}{const} uint64\_t seed = 0)\textcolor{keyword}{ const }\{} |
| 143 |
\DoxyCodeLine{249 } |
| 144 |
\DoxyCodeLine{250 \textcolor{keywordflow}{return} wyhash(bytes, MAX\_G/4, seed, \_wyp);} |
| 145 |
\DoxyCodeLine{251 \}} |
| 146 |
\DoxyCodeLine{252 } |
| 147 |
\DoxyCodeLine{253 BFG\_INLINE \textcolor{keywordtype}{void} set\_deleted() \{} |
| 148 |
\DoxyCodeLine{254 } |
| 149 |
\DoxyCodeLine{255 \textcolor{keywordflow}{for} (\textcolor{keywordtype}{size\_t} i = 0; i < MAX\_G/32; ++i) longs[i] = 0xffffffffffffffffULL;} |
| 150 |
\DoxyCodeLine{256 \}} |
| 151 |
\DoxyCodeLine{257 } |
| 152 |
\DoxyCodeLine{258 BFG\_INLINE \textcolor{keywordtype}{void} set\_empty() \{} |
| 153 |
\DoxyCodeLine{259 } |
| 154 |
\DoxyCodeLine{260 \textcolor{keywordflow}{for} (\textcolor{keywordtype}{size\_t} i = 0; i < MAX\_G/32; ++i) longs[i] = 0xfffffffffffffffeULL;} |
| 155 |
\DoxyCodeLine{261 \}} |
| 156 |
\DoxyCodeLine{262 } |
| 157 |
\DoxyCodeLine{263 BFG\_INLINE \textcolor{keywordtype}{bool} isDeleted()\textcolor{keyword}{ const }\{} |
| 158 |
\DoxyCodeLine{264 } |
| 159 |
\DoxyCodeLine{265 \textcolor{keywordflow}{return} (longs[(MAX\_G/32)-\/1] == 0xffffffffffffffffULL);} |
| 160 |
\DoxyCodeLine{266 \}} |
| 161 |
\DoxyCodeLine{267 } |
| 162 |
\DoxyCodeLine{268 BFG\_INLINE \textcolor{keywordtype}{bool} isEmpty()\textcolor{keyword}{ const }\{} |
| 163 |
\DoxyCodeLine{269 } |
| 164 |
\DoxyCodeLine{270 \textcolor{keywordflow}{return} (longs[(MAX\_G/32)-\/1] == 0xfffffffffffffffeULL);} |
| 165 |
\DoxyCodeLine{271 \}} |
| 166 |
\DoxyCodeLine{272 } |
| 167 |
\DoxyCodeLine{273 Minimizer twin() \textcolor{keyword}{const};} |
| 168 |
\DoxyCodeLine{274 Minimizer rep() \textcolor{keyword}{const};} |
| 169 |
\DoxyCodeLine{275 } |
| 170 |
\DoxyCodeLine{276 Minimizer getLink(\textcolor{keyword}{const} \textcolor{keywordtype}{size\_t} index) \textcolor{keyword}{const};} |
| 171 |
\DoxyCodeLine{277 } |
| 172 |
\DoxyCodeLine{278 Minimizer forwardBase(\textcolor{keyword}{const} \textcolor{keywordtype}{char} b) \textcolor{keyword}{const};} |
| 173 |
\DoxyCodeLine{279 Minimizer backwardBase(\textcolor{keyword}{const} \textcolor{keywordtype}{char} b) \textcolor{keyword}{const};} |
| 174 |
\DoxyCodeLine{280 } |
| 175 |
\DoxyCodeLine{281 std::string getBinary() \textcolor{keyword}{const};} |
| 176 |
\DoxyCodeLine{282 } |
| 177 |
\DoxyCodeLine{283 \textcolor{keywordtype}{void} toString(\textcolor{keywordtype}{char} *s) \textcolor{keyword}{const};} |
| 178 |
\DoxyCodeLine{284 std::string toString() \textcolor{keyword}{const};} |
| 179 |
\DoxyCodeLine{285 } |
| 180 |
\DoxyCodeLine{286 \textcolor{comment}{// static functions}} |
| 181 |
\DoxyCodeLine{287 \textcolor{keyword}{static} \textcolor{keywordtype}{void} set\_g(\textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} \_g);} |
| 182 |
\DoxyCodeLine{288 } |
| 183 |
\DoxyCodeLine{289 \textcolor{keyword}{static} \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} g;} |
| 184 |
\DoxyCodeLine{290 } |
| 185 |
\DoxyCodeLine{291 \textcolor{keyword}{private}:} |
| 186 |
\DoxyCodeLine{292 } |
| 187 |
\DoxyCodeLine{293 \textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} MAX\_G = MAX\_GMER\_SIZE;} |
| 188 |
\DoxyCodeLine{294 } |
| 189 |
\DoxyCodeLine{295 \textcolor{comment}{// data fields}} |
| 190 |
\DoxyCodeLine{296 \textcolor{keyword}{union }\{} |
| 191 |
\DoxyCodeLine{297 } |
| 192 |
\DoxyCodeLine{298 uint8\_t bytes[MAX\_G/4];} |
| 193 |
\DoxyCodeLine{299 uint64\_t longs[MAX\_G/32];} |
| 194 |
\DoxyCodeLine{300 \};} |
| 195 |
\DoxyCodeLine{301 } |
| 196 |
\DoxyCodeLine{302 \textcolor{comment}{// By default MAX\_K == 64 so the union uses 16 bytes}} |
| 197 |
\DoxyCodeLine{303 \textcolor{comment}{// However sizeof(Kmer) == 24}} |
| 198 |
\DoxyCodeLine{304 \textcolor{comment}{// Are the 8 extra bytes alignment?}} |
| 199 |
\DoxyCodeLine{305 \};} |
| 200 |
\DoxyCodeLine{306 } |
| 201 |
\DoxyCodeLine{307 } |
| 202 |
\DoxyCodeLine{308 \textcolor{keyword}{struct }MinimizerHash \{} |
| 203 |
\DoxyCodeLine{309 } |
| 204 |
\DoxyCodeLine{310 \textcolor{keyword}{inline} \textcolor{keywordtype}{size\_t} operator()(\textcolor{keyword}{const} Minimizer\& minz)\textcolor{keyword}{ const }\{} |
| 205 |
\DoxyCodeLine{311 } |
| 206 |
\DoxyCodeLine{312 \textcolor{keywordflow}{return} minz.hash();} |
| 207 |
\DoxyCodeLine{313 \}} |
| 208 |
\DoxyCodeLine{314 \};} |
| 209 |
\DoxyCodeLine{316 } |
| 210 |
\DoxyCodeLine{317 \textcolor{preprocessor}{\#endif }\textcolor{comment}{// BFG\_KMER\_HPP}} |
| 211 |
|
| 212 |
\end{DoxyCode} |