[Biopython] Editing Structure and Replacing Coordinates with new set

Souparno Adhikary souparnoa91 at gmail.com
Tue May 23 10:04:48 UTC 2017


I want to calculate the average structure from multiple frames in a pdb
file and save it to another pdb file.

I wrote the code to calculate the average co-ordinates successfully like
below:

#!/usr/bin/python

from Bio.PDB.PDBParser import PDBParser

import numpy as np

parser=PDBParser(PERMISSIVE=1)

structure_id="mode_7"
filename="mode_7.pdb"
structure=parser.get_structure(structure_id, filename)
model1=structure[0]
s=(124,3)
newc=np.zeros(s,dtype=np.float32)
counter=1
fincoord=[]
for i in range(0,29):
    coord=[]
    model=structure[i]
    for chain in model.get_list():
        for residue in chain.get_list():
            ca=residue["CA"]
            coord.append(ca.get_coord())

    newc=np.add(newc,coord)
    counter+=1

fincoord=np.divide(newc,counter)

print fincoord

print "END"

Now I want to write the coordinates in fincoord to a new pdb file i.e.
everything will be the same like the structure[0] except the coordinates.
Can you tell me how can I edit the coordinates of a specific model or
replace it with my array and save it to another file?

Thanks

Souparno Adhikary,
CHPC Lab,
University of Calcutta.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython/attachments/20170523/af922946/attachment-0001.html>


More information about the Biopython mailing list