<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def seqids(args):
 """ %prog seqids bedfile Print out all seqids on one line. Useful for graphics.karyotype. """

    p = OptionParser(seqids.__doc__)
    p.add_option("--maxn", default=100, type="int",
                 help="Maximum number of seqids")
    p.add_option("--prefix", help="Seqids must start with")
    p.add_option("--exclude", default="random", help="Seqids should not contain")
    opts, args = p.parse_args(args)

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

    bedfile, = args
    pf = opts.prefix
    exclude = opts.exclude
    bed = Bed(bedfile)
    s = bed.seqids
    if pf:
        s = [x for x in s if x.startswith(pf)]
    if exclude:
        s = [x for x in s if not exclude in x]
    s = s[:opts.maxn]
    print(",".join(s))