title: Python - Print horizontally two strings, with |
body: <p>I'm having a small formatting issue that I can't seem to solve. I have some long strings, in the form of DNA sequences. I added each to a separate list, with the letters each an individual item in either list. They are of unequal length, so I appended "N's" to the shorter of the two. </p>
  
  <p>Ex:</p>
  
  <p>seq1 = ['A', 'T', 'G', 'G', 'A', 'C', 'G', 'C', 'A']
  seq2 = ['A', 'T', 'G', 'G', 'C', 'T', 'G']</p>
  
  <p>seq2 became: ['A', 'T', 'G', 'G', 'C', 'T', 'G', 'N', 'N']</p>
  
  <p>Currently, after comparing the letter in each list I get:</p>
  
  <p>ATGG--G--</p>
  
  <p>where '-' is a mismatch in the letters (includings "N's"). </p>
  
  <p>Ideally what I would like to print is:</p>
  
  <pre><code>  seq1  ATGGACGCA
          |||||||||
    seq2  ATGG--G--
  </code></pre>
  
  <p>I've been playing around with new line characters commas at the end of print statements, however I can't get it to work. I would like to print an identifier for each one on the same line as it's sequence. </p>
  
  <p>Here's the function used to compare the two seqs:</p>
  
  <pre><code>def align_seqs(orf, query):
          orf_base = list(orf)
          query_base = list(query)
  
          if len(query_base) &gt; len(orf_base):
                  N = (len(query_base) - len(orf_base))
                  for i in range(N):
                          orf_base.append("N")
          elif len(query_base) &lt; len(orf_base):
                  N = (len(orf_base) - len(query_base))
                  for i in range(N):
                          query_base.append("N")
          align = []
  
          for i in range(0, len(orf_base)):
                  if orf_base[i] == query_base[i]:
                          align.append(orf_base[i])
                  else:
                          align.append("-")
  
          print ''.join(align)
  </code></pre>
  
  <p>At the present time, I'm just printing the "bottom" portion of what I want to print. </p>
  
  <p>All help is appreciated.</p>