 				WHERE temp_table_functionality_2.event_id IS NULL
 			) AS CDR
 			INNER JOIN sequences
+			INNER JOIN derived_mutations_replacement
 			ON temp_table_K_VJ.seq_id = CDR.seq_id
 				AND temp_table_K_VJ.seq_id = sequences.seq_id
+				AND temp_table_K_VJ.seq_id = derived_mutations_replacement.seq_id
 		) AS temp_kappa
 		ON temp_heavy.event_id = temp_kappa.event_id
 		LEFT OUTER JOIN (
 			SELECT 
 				sequences.event_id,
+				sequences.consensus_rank,
 				temp_table_L_VJ.v_segment_name,
 				temp_table_L_VJ.j_segment_name,
 				CDR.prot_seq AS CDR3,
-				temp_table_L_VJ.c_segment_name
+				temp_table_L_VJ.c_segment_name,
+				derived_mutations_replacement.repl_mutations
 			FROM temp_table_L_VJ
 			INNER JOIN (
 				SELECT

				temp_table_H_VDJ.d_segment_name,
				temp_table_H_VDJ.j_segment_name,
				CDR.prot_seq AS CDR3,
				temp_table_H_VDJ.c_segment_name
			FROM temp_table_H_VDJ
			INNER JOIN (
				# The following query basically returns a seq_id and a CDR3 protein sequence, however it also contains

			temp_heavy.j_segment_name	AS igh_segment_j,
			temp_heavy.CDR3				AS igh_cdr3,
			temp_heavy.c_segment_name	AS igh_segment_c,
			temp_heavy.repl_mutations	AS igh_shm,
			temp_kappa.v_segment_name	AS igk_segment_v,
			temp_kappa.j_segment_name	AS igk_segment_j,
			temp_kappa.CDR3				AS igk_cdr3,
			temp_kappa.c_segment_name	AS igk_segment_c,
			temp_kappa.repl_mutations	AS igk_shm,
			temp_lambda.v_segment_name	AS igl_segment_v,
			temp_lambda.j_segment_name	AS igl_segment_j,
			temp_lambda.CDR3			AS igl_cdr3,
			temp_lambda.c_segment_name	AS igl_segment_c,
			temp_lambda.repl_mutations	AS igl_shm
		FROM (
			SELECT 
				sequences.event_id,
