code: def bed(args):
      
      from jcvi.formats.bed import sort
  
      p = OptionParser(bed.__doc__)
      p.add_option("--blockonly", default=False, action="store_true",
                   help="Only print out large blocks, not fragments [default: %default]")
      p.add_option("--point", default=False, action="store_true",
                   help="Print accesssion as single point instead of interval")
      p.add_option("--scale", type="float",
                   help="Scale the OM distance by factor")
      p.add_option("--switch", default=False, action="store_true",
                   help="Switch reference and aligned map elements [default: %default]")
      p.add_option("--nosort", default=False, action="store_true",
                   help="Do not sort bed [default: %default]")
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(not p.print_help())
  
      xmlfile, = args
      bedfile = xmlfile.rsplit(".", 1)[0] + ".bed"
  
      om = OpticalMap(xmlfile)
      om.write_bed(bedfile, point=opts.point, scale=opts.scale,
                            blockonly=opts.blockonly, switch=opts.switch)
  
      if not opts.nosort:
          sort([bedfile, "--inplace"])
docs: %prog bed xmlfile
  
      Print summary of optical map alignment in BED format.