<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Glad you were able to figure it out!  I'm surprised that coordset requires a 'wait' to work, but not totally shocked I guess. :-)<div class=""><br class=""></div><div class="">--Eric<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Dec 24, 2020, at 3:02 AM, Lorena Roldán Martín <<a href="mailto:lorena.roldan@uab.cat" class="">lorena.roldan@uab.cat</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Finally solved!<div class="">runCommand("coordset #0 " + line.strip().split()[0] + “<b class="">; wait 1”</b>)<b class=""> </b>did the trick.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Thank you so much, Merry Christmas and Happy New Year</div><div class="">Lorena<br class=""><div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div class=""><div class=""></div></div></div></blockquote><br class=""><blockquote type="cite" class=""><div class="">El 23 dic 2020, a las 19:31, Eric Pettersen <<a href="mailto:pett@cgl.ucsf.edu" class="">pett@cgl.ucsf.edu</a>> escribió:</div><br class="Apple-interchange-newline"><div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Lorena,<div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>I don't think a per-frame script is really the approach you want.  What you want to do is open your trajectory, use "coordset" commands to go to the representative frames, and then write them out.  Here's a possible script (that you would run simply be opening it with the "open" command [make sure the file name ends in '.py']):</div><div class=""><br class=""></div><div class="">from chimera import runCommand</div><div class="">with open("/HDD/lroldan/Master/Metals_bA/Template/2LFM/MD/GaMD/clusters_frame.txt", "r") as f:<br class="">    cluster_number = 1</div><div class="">    for line in f:</div><div class="">        if line.startswith('#'): #comment line</div><div class="">            continue</div><div class=""><div class="">        runCommand("coordset #0 " + line.strip().split()[0])</div></div><div class="">        name = "/HDD/lroldan/Master/Metals_bA/Template/2LFM/MD/GaMD/Clusters/_" + str(cluster_number)<br class=""><div class="">        runCommand("write format pdb 0 " + name)</div></div><div class="">        cluster_number += 1</div><div class=""><br class=""></div><div class=""><div class="">--Eric</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Eric Pettersen</div><div class=""><span class="Apple-tab-span" style="white-space:pre">    </span>UCSF Computer Graphics Lab</div></div><div class=""><br class=""></div><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Dec 23, 2020, at 8:20 AM, Lorena Roldán <<a href="mailto:Lorena.Roldan@uab.cat" class="">Lorena.Roldan@uab.cat</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">

  
  <div class=""><p class="">Good afternoon, <br class="">
    </p><p class="">I contact you as I would really appreciate your help. I have a MD
      trajectory which I have processed into Clusters with the Analysis
      ... Cluster tool. I have saved the resulting file with the members
      and the representative frame, but now I would like to save those
      representative frames in separate PDB files. This process is
      extremely tedious if manually done, so I have tried to perform a
      script:</p><p class=""><br class="">
    </p><p class="">with
open("/HDD/lroldan/Master/Metals_bA/Template/2LFM/MD/GaMD/clusters_frame.txt",
      "r") as f:<br class="">
          lines=f.readlines()<br class="">
          cluster_number = 1<br class="">
          for i in range(len(lines)):<br class="">
              frame = i<br class="">
              if mdInfo["frame number"] == frame:<br class="">
                  name =
      "/HDD/lroldan/Master/Metals_bA/Template/2LFM/MD/GaMD/Clusters/_" +
      str(cluster_number)<br class="">
                  runCommand('write format pdb 0 $name)</p><p class=""><br class="">
    </p><p class="">which would be run in the "Per-frame Commands", in order to 1)
      encounter the frames of the cluster and 2) save each frame in a
      PDB file, correctly numbered.</p><p class=""><br class="">
    </p><p class="">However, this script is not working, and I would greatly thank
      any help you could provide me with.</p><p class=""><br class="">
    </p><p class="">Lorena.<br class="">
    </p>
    <div class="moz-signature">-- <br class="">
      <table style="width:500px;color:#222;border-collapse:collapse;" width="500" cellspacing="0" cellpadding="0" border="0" class="">
        <tbody class="">
          <tr class="">
            <td style="width:130px;vertical-align:top;" width="130" valign="top" class="">
              <a href="http://www.uab.cat/" class=""><img max-width="100" src="https://www.uab.cat/vcard/logo-uab-signatura.png" width="100" height="100" class=""></a>
            </td>
            <td style="width:370px;vertical-align:top;font-family:arial;font-size:12px;line-height:18px;" width="370" valign="top" class="">
              <span style="font-size:14px;font-weight:bold;color:#A54B04;" class="">Lorena
                Roldán Martín</span><br class="">
              <b class="">PhD Student in Bioinformatics</b><br class="">
              <br class="">
              Departament de Química<br class="">
              Unitat de Química Física<br class="">
              <br class="">
              Campus de la UAB · 08193 Bellaterra<br class="">
              (Cerdanyola del Vallès) · Barcelona · Spain<br class="">
              <br class="">
              +34 690799431<br class="">
              <a style="color:#A54B04;" href="http://www.uab.cat/" ?="" class="">www.uab.cat</a><br class="">
              <br class="">
            </td>
          </tr>
        </tbody>
      </table>
      <table style="width:500px;border-collapse:collapse;" width="500" cellspacing="0" cellpadding="0" border="0" class="">
        <tbody class="">
          <tr class="">
            <td style="width:120px;vertical-align:top;" width="120" class="">
              <br class="">
            </td>
            <td style="width:380px;padding-bottom:10px" width="380" class="">
              <a href="https://orcid.org/0000-0002-6902-8285" class=""><img max-width="40" src="https://www.uab.cat/vcard/ixs-id.png" width="40" height="40" class=""></a><a href="https://www.linkedin.com/in/lorena-roldan-biomedica/" class=""><img max-width="40" src="https://www.uab.cat/vcard/ixs-lin.png" width="40" height="40" class=""></a>
            </td>
          </tr>
          <tr class="">
            <td style="border-top:2px solid #e5e5e5" colspan="2" class="">
              <br class="">
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>

_______________________________________________<br class="">Chimera-users mailing list: <a href="mailto:Chimera-users@cgl.ucsf.edu" class="">Chimera-users@cgl.ucsf.edu</a><br class="">Manage subscription: <a href="https://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users" class="">https://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users</a><br class=""></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></div></div>_______________________________________________<br class="">Chimera-users mailing list: <a href="mailto:Chimera-users@cgl.ucsf.edu" class="">Chimera-users@cgl.ucsf.edu</a><br class="">Manage subscription: <a href="https://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users" class="">https://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users</a><br class=""></div></blockquote></div><br class=""></div></body></html>