def computeMappedReadsFromAlignments(total_alignments, nh, max_hi):
    nreads_mapped = total_alignments
    if len(nh) > 0:
        max_nh = max(nh.keys())
        if max_hi > 0:
            for x in xrange(2, min(max_nh + 1, max_hi)):
                nreads_mapped -= (nh[x] / x) * (x - 1)
            for x in xrange(max_hi, max_nh + 1):
                nreads_mapped -= (nh[x] / max_hi) * (max_hi - 1)
        else:
            for x in xrange(2, max(nh.keys()) + 1):
                nreads_mapped -= (nh[x] / x) * (x - 1)

    return nreads_mapped
compute number of reads alignment from total number of alignments.
dataset/ETHPy150Open CGATOxford/cgat/scripts/bam2stats.py/computeMappedReadsFromAlignments