[Biopython] Editing Structure and Replacing Coordinates with new set
Patrick Kunzmann
padix.kleber at gmail.com
Tue May 23 12:21:23 UTC 2017
Using my subpackage, this might work for you:
import Biopython.Bio.Structure as struc
from Bio.PDB import PDBParser
from Bio.PDB import PDBIO
from Bio.PDB.Structure import Structure
parser = PDBParser(PERMISSIVE=True)
structure = parser.get_structure("", "1l2y.pdb")
stack = struc.stack([struc.to_array(model) for model in structure])
average_atom_array = struc.average(stack)
structure_new = Structure("result")
structure_new.add(struc.to_model(average_atom_array))
io = PDBIO()
io.set_structure(structure_new)
io.save("result.pdb")
Am 23.05.2017 um 13:03 schrieb Souparno Adhikary:
> Oh, got it. It's only a dot problem.
>
> Souparno Adhikary,
> CHPC Lab,
> Department of Microbiology,
> University of Calcutta.
>
> On Tue, May 23, 2017 at 4:31 PM, Souparno Adhikary
> <souparnoa91 at gmail.com <mailto:souparnoa91 at gmail.com>> wrote:
>
> The page shows a 404 error. Can you please check the link again?
>
> Regards,
>
> Souparno Adhikary,
> CHPC Lab,
> Department of Microbiology,
> University of Calcutta.
>
> On Tue, May 23, 2017 at 4:01 PM, Patrick Kunzmann
> <padix.kleber at gmail.com <mailto:padix.kleber at gmail.com>> wrote:
>
> 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
> <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
>> <mailto:Biopython at mailman.open-bio.org>
>> http://mailman.open-bio.org/mailman/listinfo/biopython
>> <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/21987951/attachment.html>
More information about the Biopython
mailing list