def tx_stat(transcript_id, exons, threshold=None):
    sums = {'bases': 0, 'mean_coverage': 0}
    incomplete_exons = []

    # for each of the exons (linked to one transcript)
    for exon in exons:
        # go over each of the fields to sum up
        exon_length = (exon['chromEnd'] - exon['chromStart'])
        sums['bases'] += exon_length
        sums['mean_coverage'] += (exon['meanCoverage'] * exon_length)

        # add to the total sum for completeness levels
        for comp_key in [10, 15, 20, 50, 100]:
            if comp_key in exon['thresholds']:
                sums_key = "completeness_{}".format(comp_key)
                if sums_key not in sums:
                    sums[sums_key] = 0
                completeness = exon['thresholds'][comp_key]
                sums[sums_key] += (completeness * exon_length)

                if threshold == comp_key and completeness < 100:
                    exon_obj = Exon(exon['chrom'], exon['chromStart'],
                                    exon['chromEnd'], completeness)
                    incomplete_exons.append(exon_obj)

    fields = {key: (value / sums['bases']) for key, value in iteritems(sums)
              if key != 'bases'}
    fields['incomplete_exons'] = incomplete_exons
    fields['threshold'] = threshold
    return fields
benchmarks : list
dataset/ETHPy150Open robinandeer/chanjo/chanjo/load/txload.py/tx_stat--crossover with--dataset/ETHPy150Open pydata/vbench/vbench/db.py/BenchmarkDB.restrict_to_benchmarks