[PyMOL] building centroids for residues

2007-04-20 Thread Siv Midtun Hollup
Hi, 

I would like to examine the approximate volume of different residues in a
protein. To do this, I would like to add a centroid for each residue, and
visualise the volume by using different sphere-sizes. 

Is there a built-in function to find center of mass for a selection of atoms?
The center command looks promising, can I get the coordinates of the center of
mass using that?  (feks using get_view() or similar?)

Can I add a centroid "atom" to a residue in PYMOL? Would it be translated and
rotated along with the residue if I move the structure around afterwards?

Any pointers much appriciated :) 

Cheers,
Siv

-- 
Siv Midtun Hollup 
PhD Student
Dept. of Informatics
University of Bergen, Norway
s...@ii.uib.no (NOTE: new email adress)
- Blessed are the flexible, for they can be tied into knots. -



Re: [PyMOL] building centroids for residues

2007-04-20 Thread Andreas Henschel

Hi Siv,

below is a python script (I sent earlier to the mailing list) that 
calculates the Center of mass for a given selection
and creates a CGO sphere there. It is is not 100% exact as it only 
weighs C-Alpha atoms.
This is exactly how pymol centers selections: when you run the script, 
the domain is centered and if you rotate the structure with the mouse, 
the CGO will remain centered.
For side chains you could make a selection of the sidechain carbon atoms 
of that residue, or all of the side chain atoms:


centerOfmass("/1n8o//E/41 and not (name c+n+o)").

Also see the ellipsoid script in the wiki.
CGOs and self defined atoms perfectly rotate along (infact you are 
changing the camera view, the coordinates remain - unless you explictely 
use cmd.rotate or cmd.translate).

See e.g.
http://yggdrasil.biotec.tu-dresden.de/abac/b.47.1.2___b.16.1.1___g.4.1.1.html

I hope that helps.

ha det bra,
Andreas


from pymol import cmd
from pymol.cgo import *

def centerOfMass(selection):
  ## assumes equal weights (best called with "and name ca" suffix)
  model = cmd.get_model(selection)
  x,y,z=0,0,0
  for a in model.atom:
  x+= a.coord[0]
  y+= a.coord[1]
  z+= a.coord[2]
  return (x/len(model.atom), y/len(model.atom), z/len(model.atom))

cmd.load("/group/bioinf/Data/PDBLinks/1c7c.pdb")
cmd.select("domain", "/1c7c//A/143-283/ and name ca") ## selecting a domain

domainCenter=centerOfMass("domain")

print "Center of mass: (%.1f,%.1f,%.1f)"% domainCenter
cmd.as("cartoon", "all")
cmd.show("spheres", "domain")

## Creating a sphere CGO
com = [COLOR, 1.0, 1.0, 1.0, SPHERE]+list(domainCenter) + [3.0] ## white 
sphere with 3A radius

cmd.load_cgo(com, "CoM")

cmd.zoom("1c7c", 1.0)
cmd.center("domain")

#...@bioinfws19:~/Projects/PyMOL$ pymol -qc centerOfMass4.py
#Center of mass: (-1.0,24.5,48.2)
#...@bioinfws19:~/Projects/PyMOL$

Siv Midtun Hollup wrote:

Hi, 


I would like to examine the approximate volume of different residues in a
protein. To do this, I would like to add a centroid for each residue, and
visualise the volume by using different sphere-sizes. 


Is there a built-in function to find center of mass for a selection of atoms?
The center command looks promising, can I get the coordinates of the center of
mass using that?  (feks using get_view() or similar?)

Can I add a centroid "atom" to a residue in PYMOL? Would it be translated and
rotated along with the residue if I move the structure around afterwards?

Any pointers much appriciated :) 


Cheers,
Siv

 



--
Andreas Henschel
Bioinformatics Group
TU Dresden
Tatzberg 47-51
01307 Dresden, Germany

Phone: +49 351 463 40063
EMail: a...@biotec.tu-dresden.de