thank you so much for your time, in advance. I want to calculate the distances of one atom from chain A against multiple atoms from chain B. for Exp:
My PDB file has these entries
Chain A ATOM 32 CZ ARG A 89 -9.472 17.209 -4.849 1.00 49.73 C
Chain B ATOM 538 O4' DG B 2 -6.257 16.810 11.821 1.00 71.16 O ATOM 539 C3' DG B 2 -4.271 15.614 11.464 1.00 73.87 C
Chain C ATOM 830 O3' DC C 2 -8.757 5.249 -25.109 1.00 30.80 O ATOM 831 C2' DC C 2 -6.307 4.905 -25.202 1.00 32.20 C
better:
ATOM 32 CZ ARG A 89 -9.472 17.209 -4.849 1.00 49.73 C
ATOM 538 O4' DG B 2 -6.257 16.810 11.821 1.00 71.16 O
ATOM 539 C3' DG B 2 -4.271 15.614 11.464 1.00 73.87 C
ATOM 830 O3* DC C 2 -8.757 5.249 -25.109 1.00 30.80 O
ATOM 831 C2* DC C 2 -6.307 4.905 -25.202 1.00 32.20 C
Now I want to calculate the distances between chain A CZ atom against chain B&C following atoms O4', C3', O3', C2' etc.
Please guide me. Thanks
here my attempt:
from Bio import PDB
parser = PDB.PDBParser()
pdb1 ='pdb_test.pdb'
structure = parser.get_structure("pdb_test", pdb1)
atom1 = structure[0]["A"][89]["CZ"]
for model in structure:
for chain in model:
for residue in chain:
for atom in residue:
if chain.id !='A':
print(atom1 , ' - ',atom , ' = ',atom1 - atom)
output:
<Atom CZ> - <Atom O4'> = 16.981882
<Atom CZ> - <Atom C3'> = 17.196173
<Atom CZ> - <Atom O3'> = 23.537636
<Atom CZ> - <Atom C2'> = 23.992712
Should work as well as using NumPy:
from Bio import PDB
import numpy as np
parser = PDB.PDBParser()
# parser = PDB.PDBParser(QUIET=True) #---> serve se ho errori bypassa warnings errors
pdb1 ='pdb_test.pdb'
structure = parser.get_structure("pdb_test", pdb1)
atom1 = structure[0]["A"][89]["CZ"]
for model in structure:
for chain in model:
for residue in chain:
for atom in residue:
if chain.id !='A':
print(atom1 , ' - ',atom , ' = ',np.linalg.norm(atom1.coord - atom.coord),' come ', atom1 -atom)
Output:
<Atom CZ> - <Atom O4'> = 16.981882 come 16.981882
<Atom CZ> - <Atom C3'> = 17.196173 come 17.196173
<Atom CZ> - <Atom O3'> = 23.537636 come 23.537636
<Atom CZ> - <Atom C2'> = 23.992712 come 23.992712