<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def summary(args):
 """ %prog summary agpfile print a table of scaffold statistics, number of BACs, no of scaffolds, scaffold N50, scaffold L50, actual sequence, PSMOL NNNs, PSMOL-length, % of PSMOL sequenced. """

    from jcvi.utils.table import write_csv

    p = OptionParser(summary.__doc__)
    opts, args = p.parse_args(args)

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

    agpfile, = args
    header = "Chromosome #_Distinct #_Components #_Scaffolds " \
             "Scaff_N50 Scaff_L50 Length".split()

    agp = AGP(agpfile)
    data = list(agp.summary_all())
    write_csv(header, data, sep=" ")