## Re: [PyMOL] center of mass and distances

 Re: [PyMOL] center of mass and distances From: Andreas Henschel - 2007-03-02 17:40:05 ```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") #ah@...:~/Projects/PyMOL\$ pymol -qc centerOfMass4.py #Center of mass: (-1.0,24.5,48.2) #ah@...:~/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@... > 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: ah@... ```

 [PyMOL] center of mass and distances From: Filippo Marchioni - 2007-03-02 15:11:01 ```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 ```
 Re: [PyMOL] center of mass and distances From: Martin - 2007-03-02 15:47:21 ```Am Freitag, 2. M=E4rz 2007 schrieb Filippo Marchioni: > 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? I do this by using gromacs tools, g_traj and then creating a new atom with = the=20 coordinates in the xvg. =2D-=20 Da die vier deutschen U-Bahnen nicht am =F6ffentlichen Stra=DFenverkehr teilnehmen, gen=FCgen sie selbstverst=E4ndlich den Regeln der StVO - n=E4mlich in dem Sinne, da=DF sie ihnen nicht widersprechen. (J=FCrgen Hoffmann in de.etc.bahn.stadtverkehr) ```
 Re: [PyMOL] center of mass and distances From: Andreas Henschel - 2007-03-02 17:40:05 ```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") #ah@...:~/Projects/PyMOL\$ pymol -qc centerOfMass4.py #Center of mass: (-1.0,24.5,48.2) #ah@...:~/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@... > 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: ah@... ```