MCPcopy Create free account
hub / github.com/BirolLab/abyss / load

Function load

Common/Kmer.cpp:186–227  ·  view source on GitHub ↗

Load with appropriate endianness for shifting. */

Source from the content-addressed store, hash-verified

184
185/** Load with appropriate endianness for shifting. */
186static Seq load(const uint8_t *src)
187{
188 Seq seq;
189#if MAX_KMER > 96
190# if WORDS_BIGENDIAN
191 const size_t *s = reinterpret_cast<const size_t*>(src);
192 size_t *d = reinterpret_cast<size_t*>(&seq + 1);
193 copy(s, s + Kmer::NUM_BYTES/sizeof(size_t), reverse_iterator<size_t*>(d));
194# else
195 uint8_t *d = reinterpret_cast<uint8_t*>(&seq);
196 memcpy(d, src, sizeof seq);
197 reverse(d, d + sizeof seq);
198# endif
199#else
200 uint64_t *px = seq.x;
201 const uint8_t *p = src;
202 for (int i = 0; i < SEQ_FULL_WORDS; i++) {
203 *px++ = (uint64_t)p[0] << 56
204 | (uint64_t)p[1] << 48
205 | (uint64_t)p[2] << 40
206 | (uint64_t)p[3] << 32
207 | (uint64_t)p[4] << 24
208 | (uint64_t)p[5] << 16
209 | (uint64_t)p[6] << 8
210 | (uint64_t)p[7] << 0;
211 p += 8;
212 }
213 if (SEQ_ODD_BYTES > 0) {
214 uint64_t x = 0;
215 if (SEQ_ODD_BYTES > 0) x |= (uint64_t)p[0] << 56;
216 if (SEQ_ODD_BYTES > 1) x |= (uint64_t)p[1] << 48;
217 if (SEQ_ODD_BYTES > 2) x |= (uint64_t)p[2] << 40;
218 if (SEQ_ODD_BYTES > 3) x |= (uint64_t)p[3] << 32;
219 if (SEQ_ODD_BYTES > 4) x |= (uint64_t)p[4] << 24;
220 if (SEQ_ODD_BYTES > 5) x |= (uint64_t)p[5] << 16;
221 if (SEQ_ODD_BYTES > 6) x |= (uint64_t)p[6] << 8;
222 if (SEQ_ODD_BYTES > 7) x |= (uint64_t)p[7] << 0;
223 *px = x;
224 }
225#endif
226 return seq;
227}
228
229/**
230 * Reverse the bytes by storing them in the reverse order of

Callers 1

reverseComplementMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected