<div dir="ltr"><div><div><div>I want to calculate the average structure from multiple frames in a pdb file and save it to another pdb file.<br><br></div>I wrote the code to calculate the average co-ordinates successfully like below:<br><br>#!/usr/bin/python<br><br>from Bio.PDB.PDBParser import PDBParser<br><br>import numpy as np<br><br>parser=PDBParser(PERMISSIVE=1)<br><br>structure_id="mode_7"<br>filename="mode_7.pdb"<br>structure=parser.get_structure(structure_id, filename)<br>model1=structure[0]<br>s=(124,3)<br>newc=np.zeros(s,dtype=np.float32)<br>counter=1<br>fincoord=[]<br>for i in range(0,29):<br> coord=[] <br> model=structure[i]<br> for chain in model.get_list():<br> for residue in chain.get_list():<br> ca=residue["CA"]<br> coord.append(ca.get_coord())<br><br> newc=np.add(newc,coord)<br> counter+=1<br><br>fincoord=np.divide(newc,counter)<br><br>print fincoord<br><br>print "END"<br><br></div>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?<br><br></div>Thanks<br clear="all"><div><div><div><div><div><div class="gmail_signature"><div dir="ltr"><br></div><div>Souparno Adhikary,<br></div><div>CHPC Lab,<br></div><div>University of Calcutta.<br></div></div></div>
</div></div></div></div></div>