def pileup_acgt(pileup, quality, depth, reference, qlimit=53, noend=False,
    nostart=False):
    """
    Yet another version of the pileup parser. Used as a template
    for the C implementation, the old function still runs slightly
    faster, to my surprise...
    """
    characters = {'A': 0, 'C': 1, 'G': 2, 'T': 3, 'a': 4, 'c': 5, 'g': 6,
        't': 7, '$': 8, '*': 9, '-': 10, '+': 11}
    nucleot_list = [0, 0, 0, 0]
    strand_list = [0, 0, 0, 0]
    last_base = None
    index = len(pileup)
    n = 0
    q = 0
    while n < index:
        base = pileup[n]
        if base == '^':
            if not nostart:
                n += 2
                base = pileup[n]
            else:
                n += 3
                q += 1
                continue
        if base == '.':
            base = reference
        elif base == ',':
            base = reference.lower()
        base_index = characters[base]
        if base_index < 4:
            if ord(quality[q]) >= qlimit:
                last_base = base_index
                nucleot_list[base_index] += 1
                strand_list[base_index] += 1
            else:
                last_base = None
            n += 1
            q += 1
        elif base_index < 8:
            if ord(quality[q]) >= qlimit:
                last_base = base_index
                nucleot_list[base_index - 4] += 1
            else:
                last_base = None
            n += 1
            q += 1
        elif base_index == 8:
            if not noend:
                pass
            elif last_base:
                if last_base < 4:
                    nucleot_list[last_base] -= 1
                    strand_list[last_base] -= 1
                else:
                    nucleot_list[last_base - 4] -= 1
            last_base = None
            n += 1
        elif base_index == 9:
            last_base = None
            n += 1
            q += 1
        elif base_index > 9:
            offset = n + 1
            while True:
                if pileup[offset].isdigit():
                    offset += 1
                else:
                    break
            step = int(pileup[n + 1:offset])
            n = step + offset
    nucleot_dict = {'A': nucleot_list[0], 'C': nucleot_list[1], 'G':
        nucleot_list[2], 'T': nucleot_list[3]}
    nucleot_dict['Z'] = [strand_list[0], strand_list[1], strand_list[2],
        strand_list[3]]
    return nucleot_dict
