Hi..Actually I want a script in python that can find distance between one atom of a pdb file to all other atoms in another pdb file.Otherwise I can put all the atoms in one file and find the distance between N of first residue to all N of second protein.if anyone can also guide me how to do this then also I will be highly thankful.
The distance between two atoms can be expressed as:
So your Python script needs a method that implements this for 2 sets of coordinates passed to it. eg:
import math def distance(c1, c2): x_dist = (c1 - c2)**2 y_dist = (c1 - c2)**2 z_dist = (c1 - c2)**2 return math.sqrt(x_dist + y_dist + z_dist)
The rest of what you want to do is just plumbing, and should be simple.
EDIT - All this said, I endorse Michael's comment above, you need to be sure the coordinates of your 2 files are actually comparable before you do any of this.
Assuming you've addressed all the issues @Michael Schubert mentions, I think you can use bio-python to do this. Something like this to find the distance from atom 111 in the B file to all atoms in the A file:
import Bio.PDB import os.path as op a = '1XI4.pdb' b = '1XI4.pdb' ATOM = 111 model_a = Bio.PDB.PDBParser().get_structure(op.splitext(a), a) model_b = Bio.PDB.PDBParser().get_structure(op.splitext(b), b) b_residues = list(model_b.get_residues()) print "a-index a-name distance" for i, r in enumerate(model_a.get_residues()): dist = abs(r['CA'] - b_residues[ATOM]['CA']) print i, r.get_resname(), dist