title: Convert String to 64bit integer mapping characters to custom two-bit values mapping
body: <p>I am trying to map a string of characters (A, T, C, G) into a 64 bit integer where each letter is represented as two bits using this mapping:</p>
  
  <pre><code>mapping = {'A': 0b00, 'C': 0b01, 'G': 0b10, 'T': 0b11} 
  </code></pre>
  
  <p>The "sequence" string will not be longer than 28 characters, and I intend for the integer to be zero-padded at the beginning to make it 64 bits. Currently, I use the below function, but it is incredibly slow. I then convert the output using by calling: </p>
  
  <pre><code>int(result, 2)
  </code></pre>
  
  <p>This currently works, but I'd like to make this function incredibly fast. I don't know C++ well so it's hard for me to port to that. I am trying Cython now but I am unfamiliar with that as well. Any help making this more efficient in Python (or even C++ or Cython equivalent) would be greatly appreciated. </p>
  
  <p>Below is my code, again which I call int() on afterwards.</p>
  
  <pre><code>def seq_to_binary(seq):
      values = [mapping[c] for c in seq]
      BITWIDTH = 2
      return "".join(map(lambda x: bin(x)[2:].zfill(BITWIDTH), values)).encode();
  </code></pre>
  
  <p>At typical sequence input would be something like: 'TGTGAGAAGCACCATAAAAGGCGTTGTG'</p>