Question: Output all atoms within a sphere of 3 A of the center of Trypsine
0
gravatar for a4appy23
10 weeks ago by
a4appy2310
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']
        print(chain_E)
        for residue in chain_E:
            for atom in residue:
                ca = residue['CA'].get_vector()
                print("the CA atoms ", ca)
ADD COMMENTlink modified 10 weeks ago by finswimmer11k • written 10 weeks ago by a4appy2310
1

Hello a4appy23 ,

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

Thank you!

ADD REPLYlink written 10 weeks ago by finswimmer11k
1
gravatar for jrj.healey
10 weeks ago by
jrj.healey11k
United Kingdom
jrj.healey11k wrote:

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

ADD COMMENTlink modified 10 weeks ago • written 10 weeks ago by jrj.healey11k
Please log in to add an answer.

Help
Access

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