code: def pasteprepare(args):
      
      p = OptionParser(pasteprepare.__doc__)
      p.add_option("--flank", default=5000, type="int",
                   help="Get the seq of size on two ends [default: %default]")
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(not p.print_help())
  
      goodfasta, = args
      flank = opts.flank
      pf = goodfasta.rsplit(".", 1)[0]
      extbed = pf + ".ext.bed"
  
      sizes = Sizes(goodfasta)
      fw = open(extbed, "w")
      for bac, size in sizes.iter_sizes():
          print("\t".join(str(x) for x in \
                                 (bac, 0, min(flank, size), bac + "L")), file=fw)
          print("\t".join(str(x) for x in \
                                 (bac, max(size - flank, 0), size, bac + "R")), file=fw)
      fw.close()
  
      fastaFromBed(extbed, goodfasta, name=True)
docs: %prog pasteprepare bacs.fasta
  
      Prepare sequences for paste.