[Biopython] Editing Structure and Replacing Coordinates with new set

Patrick Kunzmann padix.kleber at gmail.com
Tue May 23 10:31:50 UTC 2017


I am currently working on a subpackage for Biopython (called 
Bio.Structure), that converts a Bio.PDB.Model.Model into a numpy array 
containing coordinates and annotations for doing easily efficient 
calculations (for example calculating average structure). This array can 
be converted back into a Bio.PDB.Model.Model and than saved as PDB file 
using PDBIO(). Currently docstrings and code comments are missing, so I 
will contribute this code only in a few days, but you can check out the 
source code at https://github.com/padix-key/biopython/tree/numpy-structure.

Best regards,

Patrick Kunzmann


Am 23.05.2017 um 12:04 schrieb Souparno Adhikary:
> 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.
>
>
> _______________________________________________
> Biopython mailing list  -  Biopython at mailman.open-bio.org
> http://mailman.open-bio.org/mailman/listinfo/biopython

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython/attachments/20170523/a3176004/attachment.html>


More information about the Biopython mailing list