... This should've gone to the list ... :S TAW
---------- Forwarded message ---------- Hi Warren (e.a.), First, as a side note, your first post had 'for state in cmd.count_states():' whereas it seems it should read 'for state in range(cmd.count_states()):'. I find myself doing something similar to Sean now, accumulating coordinates over different frames for each of the atoms. The question is how to do that fastest. At this moment I'm doing the following, which is painstakingly slow (but it works :)). Aside from that it has a nasty hack adding to globals(), as cmd.alter executes in its own scope. class AtomVar: sum = None ssq = None N = None cov = None var = None def __init__( self ): self.sum = [ 0,0,0 ] # x, y, z self.ssq = [ 0,0,0,0,0,0 ] # xx, yy, zz, xy, xz, yz self.N = 0 def inc( self, x ): self.sum = [ self.sum[i] + x[i] for i in range(3) ] squares = [ x[0]*x[0], x[1]*x[1], x[2]*x[2], x[0]*x[1], x[0]*x[2], x[1]*x[2] ] self.ssq = [ self.ssq[i] + squares[i] for i in range(6) ] self.N = self.N + 1 def purge( self ): s = self.sum squares = [ s[0]*s[0], s[1]*s[1], s[2]*s[2], s[0]*s[1], s[0]*s[2], s[1]*s[2] ] self.cov = [ (squares[i] - self.ssq[i]/self.N)/self.N for i in range(6) ] self.var = self.cov[0] + self.cov[1] + self.cov[2] def molVar( sele="all" ): model = cmd.get_model( sele ) globals()["M"] = {} for i in model.atom: M[ i.id ] = AtomVar() for state in range(cmd.count_states()): cmd.iterate_state( state, sele, "M[ ID ].inc( (x,y,z) )" ) for i in M.keys(): M[ i ].purge() cmd.alter( sele, "b = M[ ID ].var" ) Any suggestions are welcome :) Cheers, Tsjerk On Mon, Sep 28, 2009 at 9:05 PM, Warren DeLano <war...@delsci.com> wrote: > Sean, > > > > Yes, that is an alternate route. cmd.get_model is likely slower than > cmd.iterate_state, but should work regardless. > > > > Cheers > > Warren > > > > ________________________________ > > From: Sean Law [mailto:magic...@hotmail.com] > Sent: Monday, September 28, 2009 11:58 AM > To: pymol-users@lists.sourceforge.net > Subject: Re: [PyMOL] Iterate Script Over States > > > > I think I figured it out (though, it wasn't documented). What I needed was > to use: > > cmd.get_model(selection, STATE) > > I think that's the correct usage? What I needed was to loop through a > selection and then to calculate the sugar pucker information. However, not > all atoms from the selection are required for the calculation so some > pre-parsing of the residue is needed. It appears that I can specify the > state to obtain atom objects from via the get_model command. I hope that is > right? > > Sean > > ________________________________ > > Create a cool, new character for your Windows Live™ Messenger. Check it out > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > 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 > -- Tsjerk A. Wassenaar, Ph.D. Junior UD (post-doc) Biomolecular NMR, Bijvoet Center Utrecht University Padualaan 8 3584 CH Utrecht The Netherlands P: +31-30-2539931 F: +31-30-2537623 -- Tsjerk A. Wassenaar, Ph.D. Junior UD (post-doc) Biomolecular NMR, Bijvoet Center Utrecht University Padualaan 8 3584 CH Utrecht The Netherlands P: +31-30-2539931 F: +31-30-2537623 ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ 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