Output all atoms within a sphere of 3 A of the center of Trypsine
I'm looking for a simple piece of code. I'm trying to output the atom more than 4A to a separate pdb file. I could do it in pymol but I'm trying to do here in python using pycharm.
I'm stuck with how to calculate the center. I'm new to biopython, do you have any suggestions?
for model in structure:
for chain in model:
chain_E = model['E']
print(chain_E)
for residue in chain_E:
for atom in residue:
ca = residue['CA'].get_vector()
print("the CA atoms ", ca)
• 2,285 views
•
link
1 answer
Can you modify this answer to get what you need? https://bioinformatics.stackexchange.com/a/784/929
from Bio.PDB import PDBParser
# create parser
parser = PDBParser()
# read structure from file
structure = parser.get_structure('PHA-L', '1fat.pdb')
model = structure[0]
chain = model['A']
# this example uses only the first residue of a single chain.
# it is easy to extend this to multiple chains and residues.
for residue1 in chain:
for residue2 in chain:
if residue1 != residue2:
# compute distance between CA atoms
try:
distance = residue1['CA'] - residue2['CA']
except KeyError:
## no CA atom, e.g. for H_NAG
continue
if distance < 6:
print(residue1, residue2, distance)
# stop after first residue
break
Change the identity tests to make sure you identify your specific residue of interest, and print any distances > 4 (instead of < 6 as the script currently is).
• 0 views
•
link
Log in to answer this question.
Hello a4appy23 ,
Please use the formatting bar (especially the

codeoption) to present your post better. I've done it for you this time.Thank you!