Hi Filippo,

Here is a python script 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.
I hope that helps.

Best,
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$

Filippo Marchioni wrote:
Hi all!
Two questions:
Does anyone know how to read the coordinates (x,y,z) of a selected atom
in a protein?
Or even better
Does anyone know how to visualize the center of mass of the protein,
reset the axis (x,y,z) using the centroid as origin and then calculate
the distance of a resi or an atom from the new origin?
Thanks!

best
Filo


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
PyMOL-users mailing list
PyMOL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pymol-users

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

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



Reply via email to