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)
Only works if the ordering hasn't already been set. Which it hasn't, but...
dataset/ETHPy150Open tanghaibao/jcvi/formats/sam.py/bed--crossover with--dataset/ETHPy150Open sunlightlabs/read_FEC/fecreader/api/filters.py/orderingFilter