code: def bed(args):
      
      p = OptionParser(bed.__doc__)
      p.set_outfile()
  
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(not p.print_help())
  
      pslfile, = args
      fw = must_open(opts.outfile, "w")
  
      psl = Psl(pslfile)
      for p in psl:
          print(p.bed12line, file=fw)
docs: %prog bed pslfile
  
      Convert to bed format.