def _trim_quality(seq, qual, to_trim, min_length):
    """Trim bases of the given quality from 3' read ends.
    """
    removed = 0
    while qual.endswith(to_trim):
        removed += 1
        qual = qual[:-1]
    if len(qual) >= min_length:
        return seq[:len(seq) - removed], qual
    else:
        return None, None