<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Using my subpackage, this might work for you:</p>
    <p>import Biopython.Bio.Structure as struc<br>
      from Bio.PDB import PDBParser<br>
      from Bio.PDB import PDBIO<br>
      from Bio.PDB.Structure import Structure<br>
      <br>
      parser = PDBParser(PERMISSIVE=True)<br>
      structure = parser.get_structure("", "1l2y.pdb")<br>
      stack = struc.stack([struc.to_array(model) for model in
      structure])<br>
      average_atom_array = struc.average(stack)<br>
      structure_new = Structure("result")<br>
      structure_new.add(struc.to_model(average_atom_array))<br>
      io = PDBIO()<br>
      io.set_structure(structure_new)<br>
      io.save("result.pdb")<br>
    </p>
    <br>
    <div class="moz-cite-prefix">Am 23.05.2017 um 13:03 schrieb Souparno
      Adhikary:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAL6QJ1CeKeBJamCimSTasEu6BWwzJnhaTVycqzvPFQACFSns3w@mail.gmail.com">
      <div dir="ltr">Oh, got it. It's only a dot problem.<br>
      </div>
      <div class="gmail_extra"><br clear="all">
        <div>
          <div class="gmail_signature" data-smartmail="gmail_signature">
            <div dir="ltr">
              <div>
                <div>
                  <div>Souparno Adhikary,<br>
                  </div>
                  CHPC Lab,<br>
                </div>
                Department of Microbiology,<br>
              </div>
              University of Calcutta.<br>
            </div>
          </div>
        </div>
        <br>
        <div class="gmail_quote">On Tue, May 23, 2017 at 4:31 PM,
          Souparno Adhikary <span dir="ltr"><<a
              href="mailto:souparnoa91@gmail.com" target="_blank"
              moz-do-not-send="true">souparnoa91@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">
              <div>The page shows a 404 error. Can you please check the
                link again?<br>
                <br>
              </div>
              Regards,<br>
              <div class="gmail_extra"><br clear="all">
                <div>
                  <div class="m_-4123146997538492146gmail_signature"
                    data-smartmail="gmail_signature">
                    <div dir="ltr">
                      <div>
                        <div>
                          <div>Souparno Adhikary,<br>
                          </div>
                          CHPC Lab,<br>
                        </div>
                        Department of Microbiology,<br>
                      </div>
                      University of Calcutta.<br>
                    </div>
                  </div>
                </div>
                <div>
                  <div class="h5">
                    <br>
                    <div class="gmail_quote">On Tue, May 23, 2017 at
                      4:01 PM, Patrick Kunzmann <span dir="ltr"><<a
                          href="mailto:padix.kleber@gmail.com"
                          target="_blank" moz-do-not-send="true">padix.kleber@gmail.com</a>></span>
                      wrote:<br>
                      <blockquote class="gmail_quote" style="margin:0 0
                        0 .8ex;border-left:1px #ccc
                        solid;padding-left:1ex">
                        <div text="#000000" bgcolor="#FFFFFF">
                          <p>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 <a
class="m_-4123146997538492146m_-8833725069458260617moz-txt-link-freetext"
href="https://github.com/padix-key/biopython/tree/numpy-structure"
                              target="_blank" moz-do-not-send="true">https://github.com/padix-key/b<wbr>iopython/tree/numpy-structure</a>.</p>
                          <p>Best regards,</p>
                          <p>Patrick Kunzmann<br>
                          </p>
                          <div>
                            <div class="m_-4123146997538492146h5"> <br>
                              <div
                                class="m_-4123146997538492146m_-8833725069458260617moz-cite-prefix">Am
                                23.05.2017 um 12:04 schrieb Souparno
                                Adhikary:<br>
                              </div>
                            </div>
                          </div>
                          <blockquote type="cite">
                            <div>
                              <div class="m_-4123146997538492146h5">
                                <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<wbr>(structure_id,
                                      filename)<br>
                                      model1=structure[0]<br>
                                      s=(124,3)<br>
                                      newc=np.zeros(s,dtype=np.float<wbr>32)<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,counte<wbr>r)<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="m_-4123146997538492146m_-8833725069458260617gmail_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>
                                <br>
                                <fieldset
                                  class="m_-4123146997538492146m_-8833725069458260617mimeAttachmentHeader"></fieldset>
                                <br>
                              </div>
                            </div>
                            <pre>______________________________<wbr>_________________
Biopython mailing list  -  <a class="m_-4123146997538492146m_-8833725069458260617moz-txt-link-abbreviated" href="mailto:Biopython@mailman.open-bio.org" target="_blank" moz-do-not-send="true">Biopython@mailman.open-bio.org</a>
<a class="m_-4123146997538492146m_-8833725069458260617moz-txt-link-freetext" href="http://mailman.open-bio.org/mailman/listinfo/biopython" target="_blank" moz-do-not-send="true">http://mailman.open-bio.org/ma<wbr>ilman/listinfo/biopython</a></pre>
                          </blockquote>
                          <br>
                        </div>
                      </blockquote>
                    </div>
                    <br>
                  </div>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>