Hi Tsjerk,

very nice script! I have added it to the PyMOLWiki at 
http://pymolwiki.org/index.php/Radius_of_gyration

Cheers,
   Thomas

Tsjerk Wassenaar wrote, On 03/31/11 16:07:
> Hi :)
> 
> The radius of gyration is not that tough. Here's a python script to do
> it in pymol. Do note that the hydrodynamic radius is something
> related, but different.
> 
> from pymol import cmd
> import math
> 
> def rgyrate(selection):
>   # Get the atoms for the selection
>   model=cmd.get_model(selection).atom
>   # Extract the coordinates
>   x=[i.coord for i in model]
>   # Get the masses
>   mass=[i.get_mass() for i in model]
>   # Mass-weighted coordinates
>   xm=[(m*i,m*j,m*k) for (i,j,k),m in zip(x,mass)]
>   # Sum of masses
>   tmass=sum(mass)
>   # First part of the sum under the sqrt
>   rr=sum(mi*i+mj*j+mk*k for (i,j,k),(mi,mj,mk) in zip(x,xm))
>   # Second part of the sum under the sqrt
>   mm=sum((sum(i)/tmass)**2 for i in zip(*xm))
>   # Radius of gyration
>   rg=math.sqrt(rr/tmass-mm)
>   # Print it...
>   print "Radius of gyration:", rg
>   return rg
> 
> cmd.extend("rgyrate",rgyrate)
> 
> Hope it helps,
> 
> Tsjerk

-- 
Thomas Holder
MPI for Developmental Biology
Spemannstr. 35
D-72076 Tübingen

------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

Reply via email to