import math


def ca_rms_only(struct_a,struct_b,residue_list):
	"""calculate the CA rmsd of two structures using the residues in residue_list"""
	residues_a = struct_a.get_residues();
	residues_b = struct_b.get_residues();

	d_2_sum = 0.0
	resn = 0
	for (res_a, res_b) in zip(residues_a, residues_b):
		if res_a.get_id()[1] not in residue_list:
			continue
		CA_a = res_a['CA']
		CA_b = res_b['CA']

		distance_2 = (CA_a-CA_b)**2
		d_2_sum += distance_2
		resn += 1
		
	rmsd = math.sqrt(d_2_sum/resn)
	return rmsd