title: Python; DNA Sequence to AscII Text
body: <p>My aim is to discover a piece of text hidden through AscII 8bits in a very long (>115,000) sequence of DNA.</p>
  
  <p>I've written code to open the file with the DNA in, convert all <strong>C's and A's</strong> to <em>0</em> and all <strong>T's and G's</strong> to <em>1</em>. I've then converted this string into AscII characters. Below is my code.</p>
  
  <pre><code>with open("DNAseq.txt") as mydnaseq:
      sequence = mydnaseq.read().replace('\n','')
  
  DNAa = sequence.replace('A','0').replace('C','0').replace('G','1').replace('T','1')
  DNAb = ''.join(DNAa)
  
  DNAc = [DNAb[i:i+8] for i in range(0, len(DNAb), 8)]
  
  DNAd = []
  for i in DNAc:
      j = int(i,2)
      DNAd.append(j)
  
  
  DNA1 = []
  for i in DNAd:
      if i &gt;= 32 and i &lt;=127:
          DNA1.append(i)
  
  text = []
  for i in DNAd:
      j = chr(i)
      text.append(j)
  
  Answer = open("textanswer.txt", 'w')
  Answer.writelines(text)
  Answer.close()
  </code></pre>
  
  <p>However I am getting an error;</p>
  
  <p><code>UnicodeEncodeError: 'charmap' codec can't encode character '\x9e' in position 0: character maps to &lt;undefined&gt;</code></p>
  
  <p>And I have no clue what this could be. My DNA sequence apparently has a mix of random characters within but a snippet of a play/poem.</p>
  
  <p>I've tested my code with <strong>testDNA.txt</strong> containing the following;</p>
  
  <pre><code>ATAGCCTTAGTGCTACATTAATCGCGGACAAGAGGAGCT
  TAAGCCCACCGACCCGAAGGAAACTCGGAGATTCGGAAGCG
  </code></pre>
  
  <p>This returns (as expected);</p>
  
  <p><code>Steak Bake</code></p>
  
  <p>Can anyone shed any light why I'm getting this error with my DNA sequence?</p>