The final post in this series has been published as a screen cast on YouTube.
The final code used in the video is
from Bio.PDB import * import numpy as np import warnings warnings.filterwarnings('ignore')</pre> p = PDBParser() structure = p.get_structure('A', '1hv4.pdb') model = structure chain = model['A'] # Access all atom coordinates x,y,z,AtomCount = 0,0,0,0 Rcen, Rname = , for residue in chain: res_x,res_y,res_z,resAtomCount = 0,0,0,0 for atom in residue: # Collect Stuff for Structure centre x += atom.coord y += atom.coord z += atom.coord AtomCount += 1 # res_x += atom.coord res_y += atom.coord res_z += atom.coord resAtomCount += 1 rX_cen = res_x/resAtomCount rY_cen = res_y/resAtomCount rZ_cen = res_z/resAtomCount Rcen.append([rX_cen,rY_cen,rZ_cen]) Rname.append(residue.get_resname()) x_cen = x/AtomCount y_cen = y/AtomCount z_cen = z/AtomCount #print(x_cen,y_cen,z_cen) dist =  for i in Rcen: dx = i - x_cen dy = i - y_cen dz = i - z_cen d2 = dx**2 + dy**2 + dz**2 d = np.sqrt(d2) dist.append(d) for i in range(len(dist)): print(Rname[i],dist[i]) Rname = np.asarray(Rname) dist = np.asarray(dist) # Get unique AA AA = np.unique(Rname) for i in AA: print(i,dist[np.where(i == Rname)])
Please keep in mind that the research question was phrased in this way to make it easy to understand and develop code to answer it. In the end of the video I do talk about real and better ways in which this question can be answered, instead of the method used. Again, this video is more about phrasing a research question surrounding protein structures and writing a simple program to answer it. So this video should not be used for any other purpose then as an example.