<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def orient(args):
 """ %prog orient in.gff3 features.fasta > out.gff3 Change the feature orientations based on translation. This script is often needed in fixing the strand information after mapping RNA-seq transcripts. You can generate the features.fasta similar to this command: $ %prog load --parents=EST_match --children=match_part clc.JCVIv4a.gff JCVI.Medtr.v4.fasta -o features.fasta """

    from jcvi.formats.fasta import longestorf

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

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

    ingff3, fastafile = args
    idsfile = fastafile.rsplit(".", 1)[0] + ".orf.ids"
    if need_update(fastafile, idsfile):
        longestorf([fastafile, "--ids"])

    orientations = DictFile(idsfile)
    gff = Gff(ingff3)
    flipped = 0
    for g in gff:
        id = None
        for tag in ("ID", "Parent"):
            if tag in g.attributes:
                id, = g.attributes[tag]
                break
        assert id

        orientation = orientations.get(id, "+")
        if orientation == '-':
            g.strand = {"+": "-", "-": "+"}[g.strand]
            flipped += 1

        print(g)

    logging.debug("A total of {0} features flipped.".format(flipped))