def iterate_tracking(infile):
    '''parse .tracking output file from cuffcompare

    returns iterator with list of loci.
    '''
    for line in infile:
        data = line[:-1].split("\t")
        try:
            transfrag_id, locus_id, transcript_id, code = [
                x.strip() for x in data[:4]]
        except ValueError:
            raise ValueError(
                "parsing error: expected transfrag_id, locus_id, transcript_id, code, got %s" % str(data))

        if transcript_id == "-":
            ref_gene_id, ref_transcript_id = "", ""
        else:
            ref_gene_id, ref_transcript_id = transcript_id.split("|")

        transcripts = []
        for c in data[4:]:
            if c == "-":
                transcripts.append(None)
            else:
                # there can be multiple transcripts
                for cc in c.split(","):
                    try:
                        (gene_id, transcript_id, fmi, fpkm, conf_lo,
                         conf_hi, cov, length) = cc.split("|")
                    except ValueError:
                        raise ValueError("parsing error for field '%s'" % cc)
                    (fpkm, conf_lo, conf_hi, cov) = map(
                        float, (fpkm, conf_lo, conf_hi, cov))
                    if length == "-":
                        length = 0
                    (fmi, length) = map(int, (fmi, length))

                    transcripts.append(TranscriptInfo._make(
                        (gene_id, transcript_id, fmi, fpkm, conf_lo, conf_hi, cov, length)))

        yield Tracking._make((transfrag_id, locus_id, ref_gene_id, ref_transcript_id, code, transcripts))
dataset/ETHPy150Open CGATOxford/cgat/CGAT/Tophat.py/iterate_tracking/original