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

Function storeReverse

Common/Kmer.cpp:233–275  ·  view source on GitHub ↗

* Reverse the bytes by storing them in the reverse order of * loading, and reverse the words in the same fashion. */

Source from the content-addressed store, hash-verified

231 * loading, and reverse the words in the same fashion.
232 */
233static void storeReverse(uint8_t *dest, const Seq seq)
234{
235#if MAX_KMER > 96
236# if WORDS_BIGENDIAN
237 const size_t *s = reinterpret_cast<const size_t*>(&seq);
238 size_t *d = reinterpret_cast<size_t*>(dest);
239 copy(s, s + Kmer::NUM_BYTES/sizeof(size_t),
240 reverse_iterator<size_t*>(d + Kmer::NUM_BYTES/sizeof(size_t)));
241 reverse(dest, dest + Kmer::NUM_BYTES);
242# else
243 memcpy(dest, &seq, Kmer::NUM_BYTES);
244# endif
245#else
246 const uint64_t *px = &seq.x[SEQ_WORDS-1];
247# if WORDS_BIGENDIAN
248 for (int i = 0; i < SEQ_FULL_WORDS; i++) {
249 dest[0] = *px >> 0;
250 dest[1] = *px >> 8;
251 dest[2] = *px >> 16;
252 dest[3] = *px >> 24;
253 dest[4] = *px >> 32;
254 dest[5] = *px >> 40;
255 dest[6] = *px >> 48;
256 dest[7] = *px >> 56;
257 dest += 8;
258 px--;
259 }
260# else
261 uint64_t *d = (uint64_t*)dest;
262 for (int i = 0; i < SEQ_FULL_WORDS; i++)
263 *d++ = *px--;
264 dest = (uint8_t*)d;
265# endif
266 if (SEQ_ODD_BYTES > 0) dest[0] = *px >> 0;
267 if (SEQ_ODD_BYTES > 1) dest[1] = *px >> 8;
268 if (SEQ_ODD_BYTES > 2) dest[2] = *px >> 16;
269 if (SEQ_ODD_BYTES > 3) dest[3] = *px >> 24;
270 if (SEQ_ODD_BYTES > 4) dest[4] = *px >> 32;
271 if (SEQ_ODD_BYTES > 5) dest[5] = *px >> 40;
272 if (SEQ_ODD_BYTES > 6) dest[6] = *px >> 48;
273 if (SEQ_ODD_BYTES > 7) dest[7] = *px >> 56;
274#endif
275}
276
277/** Reverse-complement this sequence. */
278void Kmer::reverseComplement()

Callers 1

reverseComplementMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected