title: how to encode char in 2-bits?
body: <p>trying to implement a hash function for k-mers of DNA sequences, DNA sequence usually contains combination of four characters A,C,G,T. </p>
  
  <p>And I found this <a href="https://www.biostars.org/p/8219/#8232" rel="nofollow">thread</a> very interesting, </p>
  
  <blockquote>
    <p>I have used the simple map from A,C,G,T onto {00, 01, 10, 11} (in bits), allowing four bases encoded in a byte. You could then use hash(word) + hash(rc(word)), or any other symmetric function. This approach has the advantage that you can use the current hash to find the next hash; as you shift bases in and out of your k-mer, you shift bits in and out of your hash or hash constituents. This is the approach taken in sylamer, and it's pretty fast.</p>
  </blockquote>
  
  <p>but I couldnt know how to encode a character in 2 bits, My question, is there any tutorial, library, function for mapping characters to bits?</p>