Here you can find the source of unpackKmer(final long value)
public static byte[] unpackKmer(final long value)
//package com.java2s; //License from project: Open Source License public class Main { private static int BITS_PER_BASE = 4; private static int SINGLE_BASE_MASK = 0xf; public static byte[] unpackKmer(final long value) { final int highest = (int) Long.numberOfTrailingZeros(Long .highestOneBit(value));/* w w w.ja va2 s . c o m*/ final int n = highest / BITS_PER_BASE + ((highest % BITS_PER_BASE) > 0 ? 1 : 0); byte[] result = new byte[n]; // Fill right-to-left for (int i = 0; i < n; i++) { // This nastiness just extracts a specific base (4 bits) by // masking and shifting. final int bitOffset = i * BITS_PER_BASE; result[n - 1 - i] = (byte) ((value & (SINGLE_BASE_MASK << bitOffset)) >> bitOffset); } return result; } }