<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def get_reference_end_from_cigar(reference_start, cigar):
        '''
        This returns the coordinate just past the last aligned base.
        This matches the behavior of pysam's reference_end method
        '''
        reference_end = reference_start
        
        # iterate through cigartuple
        for i in xrange(len(cigar)):
            k, n = cigar[i]
            if k in (0,2,3,7,8): # M, D, N, =, X
                reference_end += n
        return reference_end