I have a list of residue numbers saved in centerResidueList = [100, 140, 170, 53]
and I am trying to get all the neighboring residues from this set of residues.
Currently I am using the script below, were I process the whole PDB file and generate a list of atom pairs with a distances of 10.0 and then iterate through the list and check if the residues number in the all_neighbors
list correspond to a residue number in centerResidueList
.
from Bio.PDB import *
centerResidueList = [100, 140, 170, 53]
neighbours_resi_number = []
structure = PDBParser().get_structure('X', "1xxx.pdb")
atom_list = Selection.unfold_entities(structure, 'A')
ns = NeighborSearch(atom_list)
all_neighbors = ns.search_all(10.0, "R")
for residuepair in all_neighbors:
resi_number = residuepair[0].id[1]
if resi_number in centerResidueList:
resi_number_partner = residuepair[1].id[1]
neighbours_resi_number.append(resi_number_partner)
First, how can I just create the atom_list
using CA atoms only?
Second, is residuepair[0].id[1]
the correct way of generating the residue numbers (it works but is there a method to get this)?
Finally, are there any better solutions to achieve this?