title: Using regex to transform data into a dictionary in Python
body: <p>I have a dataset with <a href="http://en.wikipedia.org/wiki/FASTA_format" rel="nofollow">FASTA</a> formatted sequencing, basically like this:</p>
  
  <pre><code>&gt;pc284  
  ATCGCGACTCGAC
  
  &gt;pc293  
  ACCCGACCTCAGC
  </code></pre>
  
  <p>I want to take to use each tag as a key in the dictionary, and store the gene as a value. </p>
  
  <p>This is the code I have, but really isn't doing anything:</p>
  
  <pre><code>import re
  fileData = open('d.fasta', 'r')
  
  myDict = dict()
  
  for line in fileData:
    match = re.search('(\&gt;)(\w+)(\r)(\w+)', line)
    if match: 
      gene = match.group(3)
      myDict[gene[0]] = gene[1]
  
  print myDict
  </code></pre>