@staticmethod
def split_cigar(cigar, i, consumed):
    """
		Split a CIGAR into two parts. i and consumed describe the split position.
		i is the element of the cigar list that should be split, and consumed says
		at how many operations to split within that element.

		The CIGAR is given as a list of (operation, length) pairs.

		i -- split at this index in cigar list
		consumed -- how many cigar ops at cigar[i] are to the *left* of the
			split position

		Return a tuple (left, right).

		Example:
		Assume the cigar is 3M 1D 6M 2I 4M.
		With i == 2 and consumed == 5, the cigar is split into
		3M 1D 5M and 1M 2I 4M.
		"""
    middle_op, middle_length = cigar[i]
    assert consumed <= middle_length
    if consumed > 0:
        left = cigar[:i] + [(middle_op, consumed)]
    else:
        left = cigar[:i]
    if consumed < middle_length:
        right = [(middle_op, middle_length - consumed)] + cigar[i + 1:]
    else:
        right = cigar[i + 1:]
    return left, right
