code: def prepare(args):
      
      from jcvi.formats.fasta import Fasta
  
      p = OptionParser(prepare.__doc__)
      p.set_outfile()
  
      opts, args = p.parse_args(args)
      outfile = opts.outfile
  
      if len(args) == 2:
          pairsfile, cdsfile = args
          pepfile = None
      elif len(args) == 3:
          pairsfile, cdsfile, pepfile = args
      else:
          sys.exit(not p.print_help())
  
      f = Fasta(cdsfile)
      fp = open(pairsfile)
      fw = must_open(outfile, "w")
      if pepfile:
          assert outfile != "stdout", "Please specify outfile name."
          f2 = Fasta(pepfile)
          fw2 = must_open(outfile + ".pep", "w")
      for row in fp:
          if row[0] == '#':
              continue
          a, b = row.split()[:2]
          if a == b:
              logging.debug("Self pairs found: {0} - {1}. Ignored".format(a, b))
              continue
  
          if a not in f:
              a = find_first_isoform(a, f)
              assert a, a
          if b not in f:
              b = find_first_isoform(b, f)
              assert b, b
  
          acds = f[a]
          bcds = f[b]
          SeqIO.write((acds, bcds), fw, "fasta")
          if pepfile:
              apep = f2[a]
              bpep = f2[b]
              SeqIO.write((apep, bpep), fw2, "fasta")
      fw.close()
      if pepfile:
          fw2.close()
docs: %prog prepare pairsfile cdsfile [pepfile] -o paired.cds.fasta
  
      Pick sequences from cdsfile to form pairs, ready to be calculated. The
      pairsfile can be generated from formats.blast.cscore(). The first two
      columns contain the pair.