<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def agp(args):
 """ %prog agp tpffile certificatefile agpfile Build agpfile from overlap certificates. Tiling Path File (tpf) is a file that lists the component and the gaps. It is a three-column file similar to below, also see jcvi.formats.agp.tpf():
 telomere chr1	na AC229737.8 chr1 + AC202463.29 chr1 + Note: the orientation of the component is only used as a guide. If the orientation is derivable from a terminal overlap, it will use it regardless of what the tpf says. See jcvi.assembly.goldenpath.certificate() which generates a list of certificates based on agpfile. At first, it seems counter-productive to convert first agp to certificates then certificates back to agp. The certificates provide a way to edit the overlap information, so that the agpfile can be corrected (without changing agpfile directly). """

    from jcvi.formats.base import DictFile

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

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

    tpffile, certificatefile, agpfile = args
    orientationguide = DictFile(tpffile, valuepos=2)
    cert = Certificate(certificatefile)
    cert.write_AGP(agpfile, orientationguide=orientationguide)