Question: Output all atoms within a sphere of 3 A of the center of Trypsine
gravatar for a4appy23
8 months ago by
a4appy2310 wrote:

im looking for a simple piece of code. im trying to output the atom more than 4A to a sepate pdb file. i could do it in pymol. but im trying to do here in python using pycharm.

im stuck with how to calculate the center. im new biopython...any suggestions

for model in structure:
    for chain in model:
        chain_E = model['E']
        for residue in chain_E:
            for atom in residue:
                ca = residue['CA'].get_vector()
                print("the CA atoms ", ca)
ADD COMMENTlink modified 8 months ago by finswimmer12k • written 8 months ago by a4appy2310

Hello a4appy23 ,

Please use the formatting bar (especially the code option) to present your post better. I've done it for you this time.

Thank you!

ADD REPLYlink written 8 months ago by finswimmer12k
gravatar for Joe
8 months ago by
United Kingdom
Joe14k wrote:

Can you modify this answer to get what you need?

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
                distance = residue1['CA'] - residue2['CA']
            except KeyError:
                ## no CA atom, e.g. for H_NAG
            if distance < 6:
                print(residue1, residue2, distance)
        # stop after first residue

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).

ADD COMMENTlink modified 8 months ago • written 8 months ago by Joe14k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2557 users visited in the last hour