code: def bed(args):
      
      p = OptionParser(bed.__doc__)
      opts, args = p.parse_args(args)
  
      if len(args) < 2:
          sys.exit(not p.print_help())
  
      bedfile = args[0]
      bamfiles = args[1:]
      for bamfile in bamfiles:
          cmd = "bamToBed -i {0}".format(bamfile)
          sh(cmd, outfile=bedfile, append=True)
docs: %prog bed bedfile bamfiles
  
      Convert bam files to bed.