I can’t see where the exact error is coming from, but from playing with it, it seems that firstResidue and secondResidue aren’t what they seem to be. I think it has something to do with your use of get_list(), which isn’t the ‘normal’ way of dealing with these objects in my experience.
—
This code works (I haven’t checked the maths though). I’m using a dummy structure (1A80). See a similar question/answer here: Creating a distance matrix from PDB file coordinates (Python)
import numpy
from Bio.PDB.PDBParser import PDBParser
parser = PDBParser()
structure = parser.get_structure("1A80", "1A80.pdb")
residues = [r for r in structure.get_residues()] # You don’t need the extensive list traversal you were doing before because there are many get_*() methods
# Calculate the distance between the alpha carbons for a pair of residues
one = residues[0]["CA"].get_coord()
two = residues[1]["CA"].get_coord()
print('{} - {} = {}'.format(one,two, numpy.linalg.norm(one-two)))
A linear algebra ‘normal’ should be equivalent to the Euclidean distance between the arrays, but check my maths by all means.
I get ~4A, which sounds sensible though:
[-3.606 8.443 4.224] - [-3.507 6.781 7.627] = 3.78846311569
Hello lisa,
Please use the formatting bar (especially the

codeoption) to present your post better. I've done it for you this time.Also, post your complete code here with some background information about the input; best way is to host the file somewhere and provide a link for that here at biostars or provide first few/ relevant lines here.
Thank you!
Hello, thank you for your response. I have updated my question to include the complete code.
Can you please post the exact error? I can’t see anything obviously wrong with your approach so far.
Try Pymol
https://pymolwiki.org/index.php/Distance
Within this link above see examples
https://bioinformatics.stackexchange.com/questions/783/how-can-we-find-the-distance-between-all-residues-in-a-pdb-file
Here some authors determined the distance by biopython