def bed(args):
    p = OptionParser(bed.__doc__)
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    idsfile, = args
    ids = set(x.strip() for x in open(idsfile))
    data = get_bed_from_phytozome(list(ids))

    pf = idsfile.rsplit(".", 1)[0]
    bedfile = pf + ".bed"
    fw = open(bedfile, "w")
    for i, row in enumerate(data):
        row = row.strip()
        if row == "":
            continue

        print >> fw, row

    logging.debug("A total of {0} records written to `{1}`.".format(i + 1, bedfile))
%prog bed genes.ids
dataset/ETHPy150Open tanghaibao/jcvi/apps/biomart.py/bed