<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def happy(args):
 """ %prog happy happy.txt Make bi-directed graph from HAPPY mapping data. JCVI encodes uncertainties in the order of the contigs / scaffolds. : separates scaffolds + means telomere (though the telomere repeats may not show because the telomere-adjacent sequence is missing) - means that the scaffold is in reverse orientation to that shown in the 2003 TIGR scaffolds. Ambiguities are represented as follows, using Paul Dear.s description: [ ] means undetermined orientation. error quite possible (70% confidence?) ( ) means uncertain orientation. small chance of error (90% confidence?) { } means uncertain order. Example: +-8254707:8254647:-8254690:{[8254694]:[8254713]:[8254531]:[8254797]}:8254802:8254788+ """

    p = OptionParser(happy.__doc__)
    p.add_option("--prefix", help="Add prefix to the name [default: %default]")
    opts, args = p.parse_args(args)

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

    happyfile, = args

    certain = "certain.graph"
    uncertain = "uncertain.graph"
    fw1 = open(certain, "w")
    fw2 = open(uncertain, "w")

    fp = open(happyfile)
    for row in fp:
        for e, is_uncertain in happy_edges(row, prefix=opts.prefix):
            fw = fw2 if is_uncertain else fw1
            print(e, file=fw)

    logging.debug("Edges written to `{0}`".format(",".join((certain, uncertain))))