Hi Tsjerk, use either the global pymol.stored variable or the alter_state 'space' argument.
-------------- #!/usr/bin/env python if __name__ == "__main__": import __main__ __main__.pymol_argv = [ 'pymol', '-cq' ] import pymol pymol.finish_launching() else: import pymol def identity(x,y,z): print "YEAH!" return x,y,z pymol.editor.build_peptide("GGGGG") pymol.cmd.alter_state(1,"all","(x,y,z)=identity(x,y,z)", space={'identity':identity}) # or: # pymol.stored.identity = identity # pymol.cmd.alter_state(1,"all","(x,y,z)=stored.identity(x,y,z)") -------------- Cheers, Thomas On Tue, Mar 29, 2011 at 6:18 PM, Tsjerk Wassenaar <tsje...@gmail.com> wrote: > Hi, > > I'm having some trouble accessing a function defined at top level with > alter_state in a python script launching pymol. Maybe I shouldn't be > wanting to do this, but what I'm trying, and failing to do is > exemplified by this script: > > ### > > #!/usr/bin/env python > > import pymol > > if __name__ == "__main__": > pymol.finish_launching() > > def identity(x,y,z): > print "YEAH!" > return x,y,z > > # Fix: > # setattr(pymol,"identity",identity) > > pymol.editor.build_peptide("GGGGG") > pymol.cmd.alter_state(1,"all","(x,y,z)=identity(x,y,z)") > > ### > > The problem is that the function 'identity' (which may be given a more > sensical form by actually doing something with the coordinates), is > sought in the pymol namespace. I can't really figure out where I > should be looking to directly call the function. Of course, I can > register the function in the pymol module (uncomment the setattr > line), but I don't think it's proper meddling with established modules > like that. Does anyone know a better/cleaner solution? > > In addition, does anyone know how to suppress the GUI stuff when > launching pymol like this? > > Groetjes, > > Tsjerk > > -- > 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 -- Thomas Holder MPI for Developmental Biology Spemannstr. 35 D-72076 Tübingen ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ 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