Hey :)<br><br>As there seems to be interest :)<br>Below is the diff between native and my version of gmx_trjconv.c 4.5, the complete source file is attached. I&#39;d fancy comments and suggestions.<br><br>Hope it helps,<br>
<br>Tsjerk<br><br>###<br><br>82a83,208<br>&gt; static void taw_pbc_cluster(int nrefat,t_topology *top,rvec *x, atom_id *ndx,<br>&gt;                 matrix box,real cutoff)<br>&gt; {<br>&gt;   int i,j,id,na,nc,cid,nr,m,*cluster;<br>
&gt;   atom_id *active,*done,*rest;<br>&gt;   matrix S,T,A;<br>&gt;   rvec *y,rd;<br>&gt;   real ax2,ay2,az2,axy,axz,ayz,d,cut2;<br>&gt;   gmx_bool bClustered;<br>&gt; <br>&gt;   cut2 = cutoff*cutoff;<br>&gt; <br>&gt;   transpose(box,S);<br>
&gt;   m_inv(S,T);<br>&gt;   ax2 =   iprod( S[0], S[0] );<br>&gt;   ay2 =   iprod( S[1], S[1] );<br>&gt;   az2 =   iprod( S[2], S[2] );<br>&gt;   axy = 2*iprod( S[0], S[1] );<br>&gt;   axz = 2*iprod( S[0], S[2] );<br>&gt;   ayz = 2*iprod( S[1], S[2] );<br>
&gt; <br>&gt;   snew(rest,   nrefat);<br>&gt;   snew(active, nrefat);<br>&gt;   snew(done,   nrefat);<br>&gt;   snew(cluster,nrefat);<br>&gt;   snew(y,      nrefat);<br>&gt; <br>&gt;   nr = nrefat;<br>&gt;   nc = m = 0;<br>
&gt;   cid = 0;<br>&gt;   for (i=0; i&lt;nr; i++)<br>&gt;   {<br>&gt;     rest[i] = i;<br>&gt;     /* Transform to box coordinates */<br>&gt;     mvmul(T,x[ndx[i]],y[i]);<br>&gt;   }<br>&gt;   while (nr)<br>&gt;   {<br>&gt;     if (nr&lt;0)<br>
&gt;       exit(1);<br>&gt; <br>&gt;     /* <br>&gt;        If we get here we have _nc_ clustered atoms, <br>&gt;        but none which has neighbours in the rest group:<br>&gt;        Time for a new cluster.<br>&gt;        Pick one atom from the rest group and add it to the clustered ones.<br>
&gt;        Rest counter nr is decremented.<br>&gt;        The new active atom is not counted as clustered yet.<br>&gt;        The cluster id was already set.<br>&gt;        When entering the following while loop we have exactly one active atom.<br>
&gt;     */<br>&gt;     done[nc] = rest[--nr];<br>&gt;     cluster[nc] = cid;<br>&gt;     na = 1;<br>&gt;     m  = 0;<br>&gt;     while (na)<br>&gt;     {<br>&gt;       /*<br>&gt;     Run over active atoms.<br>&gt;     The active atoms run from nc to nc+na<br>
&gt;       */<br>&gt; <br>&gt;       /* Iterate over atoms in rest group */<br>&gt;       for (i=0; i&lt;nr; i++)<br>&gt;       {<br>&gt;     bClustered = FALSE;<br>&gt; <br>&gt;     /* For each atom in rest group check distance from active group */<br>
&gt;     for (j=nc; j&lt;nc+na; j++)<br>&gt;     {<br>&gt;       /* Distance in periodic system in box coordinates */<br>&gt;       rvec_sub( y[rest[i]], y[done[j]], rd );<br>&gt;       /* Truncate coordinates for minimial distances */<br>
&gt;       rd[0] -= floor( rd[0] + 0.5 );<br>&gt;       rd[1] -= floor( rd[1] + 0.5 );<br>&gt;       rd[2] -= floor( rd[2] + 0.5 );<br>&gt;       /* Distance follows from d = r&#39;S&#39;Sr = r&#39;Ar = */<br>&gt;       d = rd[0]*(rd[0]*ax2+rd[1]*axy+rd[2]*axz)+rd[1]*(rd[1]*ay2+rd[2]*ayz)+rd[2]*rd[2]*az2;<br>
&gt;       <br>&gt;       /* If atom i is within the cutoff distance of j, it is part of the same cluster */ <br>&gt;       if (d&lt;cut2)<br>&gt;       {<br>&gt;         /* Add the atom to the active cluster group */ <br>
&gt;         id          = nc+na+m;<br>&gt;         done[id]    = rest[i];<br>&gt;         cluster[id] = cid;<br>&gt;         m++;<br>&gt;         /* Relocate the atoms such that it is positioned properly */<br>&gt;         rvec_add(rd,y[done[j]],y[done[id]]);<br>
&gt;         /* Now pass on to the next atom in the rest group */<br>&gt;         break;<br>&gt;       }<br>&gt; <br>&gt;       /* <br>&gt;          We only get here if the atom could not be assigned to a cluster.<br>&gt;          Then we shift the atom down in the rest array. <br>
&gt;       */<br>&gt;       rest[i-m] = rest[i];<br>&gt;     }<br>&gt;       }<br>&gt;       /* Subtract the number of atoms taken from the rest group */<br>&gt;       nr -= m;<br>&gt;       /* Now mark all previously active atoms clustered */<br>
&gt;       nc = nc + na;<br>&gt;       /* And mark all atoms added active */<br>&gt;       na = m;<br>&gt;       m  = 0;<br>&gt;     } /* while (na) */<br>&gt;     cid++;<br>&gt;   } /* while (nr) */<br>&gt;   fprintf(stderr,&quot;Found %d clusters&quot;,cid);<br>
&gt; <br>&gt; <br>&gt;   sfree(rest);<br>&gt;   sfree(active);<br>&gt;   sfree(done);<br>&gt;   sfree(cluster);<br>&gt; <br>&gt;   for (i=0; i&lt;nrefat; i++)<br>&gt;   {<br>&gt;     mvmul(S,y[i],x[ndx[i]]);<br>&gt;   }<br>
&gt; <br>&gt;   sfree(y);<br>&gt; }<br>&gt; <br>638c764<br>&lt;     static real  dropunder=0,dropover=0;<br>---<br>&gt;     static real  dropunder=0,dropover=0,dclus=0.5;<br>722c848,851<br>&lt;                         &quot;coarse grained ones&quot; } };<br>
---<br>&gt;                         &quot;coarse grained ones&quot; },<br>&gt;                     { &quot;-dclus&quot;, FALSE, etREAL,<br>&gt;                         { &amp;dclus },<br>&gt;                         &quot;Cutoff distance for clustering&quot; } };<br>
932c1061,1062<br>&lt;             if (0 == <a href="http://top.mols.nr">top.mols.nr</a> &amp;&amp; (bCluster || bPBCcomMol))<br>---<br>&gt; /*            if (0 == <a href="http://top.mols.nr">top.mols.nr</a> &amp;&amp; (bCluster || bPBCcomMol))*/<br>
&gt;             if (0 == <a href="http://top.mols.nr">top.mols.nr</a> &amp;&amp; bPBCcomMol)<br>1197c1327,1328<br>&lt; <br>---<br>&gt;             taw_pbc_cluster(ifit,&amp;top,fr.x,ind_fit,fr.box,dclus);<br>&gt;             /*<br>
1198a1330<br>&gt;             */<br><br><br><br><br><div class="gmail_quote">On Fri, Apr 15, 2011 at 3:16 AM, Jianguo Li <span dir="ltr">&lt;<a href="mailto:ljggmx@yahoo.com.sg">ljggmx@yahoo.com.sg</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div>Hi Tsjerk,<br>
<br>I am doing protein-micelle simultions and could you also send me your modified trjconv code?<br>Thank  you very much!<br><br>best regards,<br>Jianguo<br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">
<br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2"><hr size="1"><div class="im"><b><span style="font-weight: bold;">From:</span></b> Tsjerk Wassenaar &lt;<a href="mailto:tsjerkw@gmail.com" target="_blank">tsjerkw@gmail.com</a>&gt;<br>
</div><div class="im"><b><span style="font-weight: bold;">To:</span></b> Discussion list for GROMACS users &lt;<a href="mailto:gmx-users@gromacs.org" target="_blank">gmx-users@gromacs.org</a>&gt;<br></div><b><span style="font-weight: bold;">Sent:</span></b> Thursday, 14 April 2011 23:44:07<br>
<b><span style="font-weight: bold;">Subject:</span></b> Re: [gmx-users] micelles and trjconv -pbc
 cluster<br></font><div><div></div><div class="h5"><br>Hi George,<br><br>Recently I wrote an alternative, non-iterative clustering routine, that does not suffer from convergence failures. If you want, I can send you the modified trjconv source code. Note that it does not bother about the center of mass of the cluster, but just builds a network of neighbours, until there are no more. If you&#39;re clusters are not periodic, it won&#39;t matter.<br>

<br>Let me know...<br><br>Cheers,<br><br>Tsjerk<br><br><div class="gmail_quote">On Thu, Apr 14, 2011 at 4:48 PM, Erik Marklund <span dir="ltr">&lt;<a rel="nofollow" href="mailto:erikm@xray.bmc.uu.se" target="_blank">erikm@xray.bmc.uu.se</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

  
    
  
  <div>
    jim jack skrev 2011-04-14 16.42:
    <div><div></div><div><blockquote type="cite">
      <table border="0" cellpadding="0" cellspacing="0">
        <tbody>
          <tr>
            <td style="font: inherit;" valign="top">Dear GROMACS users,
              <br>
              <br>
                 I am trying to simulate an SDS micelle in water. As
              simulation time goes by, the micelle approaches the edge
              of the box and consequently some of these molecules get in
              from the other side. This leads to incorrect radius of
              gyration, eccentricity, etc. A solution to this problem is
              the option <span style="font-style: italic;">trjconv -pbc
                cluste</span>r as described in the page <a rel="nofollow">http://www.gromacs.org/Documentation/How-tos/Micelle_Clustering</a>.
              In this case, the problem is that it takes a lot of time
              and a huge file (several GB) is created due to this
              procedure. Is there any other alternative?<br>
              <br>
              Thanks in advance<br>
              <br>
              George Koros<br>
              <br>
            </td>
          </tr>
        </tbody>
      </table>
    </blockquote></div></div>
    I don&#39;t think that the cluster option always converges. You could,
    if your micelle is intact at frame 0, first do trjconv -pbc nojump,
    then optionally trjconv -center. That should give a trajectory from
    which you could calculate the radius of gyration. If SDS molecules
    occationally leave the micelle and recombine with a priodic, then
    you might have a problem with the suggested approach.<br>
    <br>
    <pre>-- <br>-----------------------------------------------<br>Erik Marklund, PhD student<br>Dept. of Cell and Molecular Biology, Uppsala University.<br>Husargatan 3, Box 596,    75124 Uppsala, Sweden<br>phone:    <a rel="nofollow">+46 18 471 4537</a>        fax: <a rel="nofollow">+46 18 511 755</a>
<a rel="nofollow" href="mailto:erikm@xray.bmc.uu.se" target="_blank">erikm@xray.bmc.uu.se</a>    <a rel="nofollow" href="http://folding.bmc.uu.se/" target="_blank">http://folding.bmc.uu.se/</a>
</pre>
  </div>

<br>--<br>
gmx-users mailing list    <a rel="nofollow" href="mailto:gmx-users@gromacs.org" target="_blank">gmx-users@gromacs.org</a><br>
<a rel="nofollow" href="http://lists.gromacs.org/mailman/listinfo/gmx-users" target="_blank">http://lists.gromacs.org/mailman/listinfo/gmx-users</a><br>
Please search the archive at <a rel="nofollow" href="http://www.gromacs.org/Support/Mailing_Lists/Search" target="_blank">http://www.gromacs.org/Support/Mailing_Lists/Search</a> before posting!<br>
Please don&#39;t post (un)subscribe requests to the list. Use the<br>
www interface or send it to <a rel="nofollow" href="mailto:gmx-users-request@gromacs.org" target="_blank">gmx-users-request@gromacs.org</a>.<br>
Can&#39;t post? Read <a rel="nofollow" href="http://www.gromacs.org/Support/Mailing_Lists" target="_blank">http://www.gromacs.org/Support/Mailing_Lists</a><br></blockquote></div><br><br clear="all"><br>-- <br>Tsjerk A. Wassenaar, Ph.D.<br>

<br>post-doctoral researcher<br>Molecular Dynamics Group<br>* Groningen Institute for Biomolecular Research and Biotechnology<br>* Zernike Institute for Advanced Materials<br>University of Groningen<br>The Netherlands<br>


</div></div></div></div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Tsjerk A. Wassenaar, Ph.D.<br><br>post-doctoral researcher<br>Molecular Dynamics Group<br>* Groningen Institute for Biomolecular Research and Biotechnology<br>
* Zernike Institute for Advanced Materials<br>University of Groningen<br>The Netherlands<br>