Output all atoms within a sphere of 3 A of the center of Trypsine
1
0
Entering edit mode
5.9 years ago
a4appy23 ▴ 50

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)
biopython protein python pdb • 1.9k views
ADD COMMENT
1
Entering edit mode

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 REPLY
1
Entering edit mode
5.9 years ago
Joe 21k

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 COMMENT

Login before adding your answer.

Traffic: 1688 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6