code: def bed(args):
      
      p = OptionParser(bed.__doc__)
      p.add_option("--switch", default=False, action="store_true",
                   help="Switch reference and aligned map elements [default: %default]")
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(not p.print_help())
  
      mapout, = args
      pf = mapout.split(".")[0]
      mapbed = pf + ".bed"
      bm = BinMap(mapout)
      bm.print_to_bed(mapbed, switch=opts.switch)
  
      return mapbed
docs: %prog fasta map.out
  
      Convert MSTMAP output into bed format.