code: def bed(args):
      
      p = OptionParser(main.__doc__)
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(not p.print_help())
  
      contigfile, = args
      bedfile = contigfile.rsplit(".", 1)[0] + ".bed"
      fw = open(bedfile, "w")
      c = ContigFile(contigfile)
  
      for rec in c.iter_records():
          for r in rec.reads:
              print(r.bedline, file=fw)
  
      logging.debug("File written to `{0}`.".format(bedfile))
  
      return bedfile
docs: %prog bed contigfile
  
      Prints out the contigs and their associated reads.