title: Using Dictionary to match codons
body: <p>I am trying to make a function <code>codon_pairs(pairs, codonsA, codonsB)</code> that takes in three arguments; a dictionary <code>pairs</code> and two lists, <code>codonsA</code> and <code>codonsB</code>. The dictionary contains the base pairs and the codon lists contain codon sequences. I am trying to find  the complementary codon sequence in <code>codonsB</code> for each codon sequence in <code>codonsA</code>, and return matching pairs like the following:</p>
  
  <pre><code>pairs = {'A':'T', 'C':'G', 'T':'A', 'G':'C'}
  codonsA = ['AAG', 'TAC', 'CGG', 'GAT', 'TTG', 'GTG', 'CAT', 'GGC', 'ATT', 'TCT']
  codonsB = ['TAA', 'CTA', 'AAC', 'TTC', 'AGA', 'CCC', 'CCG', 'GTA']
  
  print(codons_pairs(pairs, condonsA, codonsB))
  
  [('AAG', 'TTC'), ('GAT', 'CTA'), ('TTG', 'AAC'), ('CAT', 'GTA'), ('GGC',   'CCG'), ('ATT', 'TAA'), ('TCT', 'AGA')]
  </code></pre>
  
  <p>The first item in the 2-tuple is a codon from <code>codonsA</code> and the second item is a matching codon from <code>codonsB</code>. For example, the sequences <strong>AAG</strong> (<code>codonsA[0]</code>) and <strong>TCC</strong> (<code>codonsB[3]</code>) are matching pairs, as the base pair of A is T, and the base pair of G is C, highlighted in the <code>pairs</code> dictionary. </p>
  
  <p>On the flip side, if a matching pair cannot be found, it will be omitted from the final result. </p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>pairs = {'A':'T', 'C':'G', 'T':'A', 'G':'C'}
  codonsA = ['AAG', 'TAC', 'CGG', 'GAT', 'TTG', 'GTG', 'CAT', 'GGC', 'ATT', 'TCT']
  codonsB = ['TAA', 'CTA', 'AAC', 'TTC', 'AGA', 'CCC', 'CCG', 'GTA']
  
  def codons_pairs(pairs, codonsA, codonsB):
  
      for A in codonsA:
          for B in codonsB:
              for i in A:
                  for j in B:
  </code></pre>
  
  <p>I'm just not sure how to check pairs between <code>codonsA</code> and <code>codonsB</code>, with regard to a dictionary. Any help would be greatly appreciated.</p>