From: Noel O'B. <bao...@gm...> - 2009-02-18 21:28:30
|
Hello Xavier, Pybel does not allow assignment of coordinate values (the next version will raise an error when you try, instead of failing silently). To set the coordinates you need to use the SetVector() method of the underlying OBAtom, e.g. >>> mol = pybel.readstring("smi", "CCC") >>> mol.make3D() >>> mol.atoms[0].coords (0.9762193757974641, -0.018350366821008612, 0.0057426618097852662) >>> a = mol.atoms[0].OBAtom >>> a.SetVector(1,2,3) >>> mol.atoms[0].coords (1.0, 2.0, 3.0) >>> Perhaps I will add setting coordinates as a feature in a future version of Pybel? - Noel 2009/2/18 Xavier Prat-Resina <xav...@gm...>: > Hi, > > I'm trying to change the coordinates of a molecule using > the coordinates from another file: > > gaussbel = pybel.readfile("g03", "myfile.g03").next() > molbel = pybel.readfile("mol", "myfile.mol").next() > > If I try to change the coordinates directly: > molbel.atoms[0].coords[0] = gaussbel.atoms[0].coords[0] > it gives > TypeError: 'tuple' object does not support item assignment > > I can loop over atoms: > > for atom in molbel: > (assign x,y,z) > atom.coords = numpy.array([x,y,z], "float64") > > but then, how can I update the molbel molecule with the new atom.coords? > > I know I'm missing something very simple. > Sorry for such naive questions :) > > Xavier > > -- > Xavier Prat-Resina > Research Associate > Journal of Chemical Education and University of Wisconsin > 209 N. Brooks St. Madison, WI 53715-1116 > > Tel: 608 8901702 // Fax: 608 2627145 > e-mail: xavier ( ) chem.wisc.edu ; skype: xavierprat > http://x.prat.resina.googlepages.com > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > OpenBabel-scripting mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openbabel-scripting > > |