Hi Martin, The temporary namespace for an atom means that variables like 'resn' can be used to refer to the attribute with that name on the atom instance.
You are right that iterate is here used to iterate over a single atom. That does seem a bit odd :p But it seems to be a more straightforward way to get to the properties desired. This is what I would do: residues=set() iterate all, residues.add((chain,resn,resi)) for res in residues: cmd.save("%s-%s-%s.pdb"%res,"chain %s and resn %s and resi %s"%res) Of course that could be easily forged into a nice function :) Hope it helps, Tsjerk On Mon, Nov 28, 2011 at 3:57 PM, Martin Hediger <ma....@bluewin.ch> wrote: > In this example below (from Thomas), the method 'iterate' is used. The > function saves every amino acid of a structure to a separate file. First > of all, I'm not sure of how to understand the docs: > > " "iterate" iterates over an expression within a temporary namespace for > each atom." > > What does temporary namespace for each atom mean? Also, since 'iterate' > is used within the while-loop, are we only iterating over the single > amino acid? Its confusing me because I constantly think of iterate as > somekind of short hand notation of a for-loop, but I guess thats not it. > It would be great if somebody could explain the iterate function a bit > more to me. > > Thanks for your feedback. > Martin > > # ***************************************************************** > # import statements > def seq(state, selection="name ca or resn hoh or resn lig"): > cmd.select("prot", selection) > while cmd.pop("_tmp", "prot"): > cmd.iterate("_tmp", "stored.x=(resn,resv)") > # Special case 1: Waters. > if stored.x[0] == 'HOH': > filename = 'seq-x%s-%s.pdb' % (stored.x[1], state) > # Special case 2: Substrate. > elif stored.x[0] == 'LIG': > filename = 'seq-x%s-%s.pdb' % (stored.x[1], state) > # Other: protein back-bone. > else: > filename = 'seq-%s%d-%s.pdb' % (one_letter[stored.x[0]].lower(), > stored.x[1], state) > cmd.save(filename, "byres _tmp") > cmd.delete('_tmp prot') > > cmd.extend('seq', seq) > # ----------------------------------------------------------------- > > > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure > contains a definitive record of customers, application performance, > security threats, fraudulent activity, and more. Splunk takes this > data and makes sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-novd2d > _______________________________________________ > 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. post-doctoral researcher Molecular Dynamics Group * Groningen Institute for Biomolecular Research and Biotechnology * Zernike Institute for Advanced Materials University of Groningen The Netherlands ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d _______________________________________________ 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