Just to add onto what Tsjerk had to say about running python snippets in a .pml 
script. You can also encapsulate the python code in blocks like this:

python
<your python code here>
python end

This works with all newer version of pymol (>1.0) and enhances readability of 
the code quite a bit.

HTH

        Carsten


> -----Original Message-----
> From: pymol-users-boun...@lists.sourceforge.net
> [mailto:pymol-users-boun...@lists.sourceforge.net]on Behalf Of Tsjerk
> Wassenaar
> Sent: Wednesday, June 11, 2008 3:25 AM
> To: David Goldenberg
> Cc: pymol-users@lists.sourceforge.net
> Subject: Re: [PyMOL] drawing axes
> 
> 
> Hi David,
> 
> Regarding the first part of your question, the way to load a python
> (not a PyMol) script is:
> 
> run axes.py
> 
> .. and not @axes.py. The latter is used for loading PyMol scripts
> (.pml). You _can_ use python code in a .pml script, but then you
> better, or in some cases have to, start with a slash (/) to let the
> command parser know that there's python code coming.
> 
> Hope it helps,
> 
> Tsjerk
> 
> On Wed, Jun 11, 2008 at 12:10 AM, David Goldenberg
> <goldenb...@biology.utah.edu> wrote:
> > Hi,
> >    I would like to make a figure that shows a set of coordinate axes
> > aligned in a particular way with respect to a molecule.  I 
> have found
> > the axes.py script (copied at the bottom of this message) 
> on the PyMol
> > Wiki, but have run into the following problems:
> >
> > 1. I can't get the script to load and run properly in 
> MacPymol.  I get a
> > long string of error messages beginning with:
> >
> > PyMOL>@axes.py
> > PyMOL>from pymol.cgo import *
> > PyMOL>from pymol import cmd
> > PyMOL>from pymol.vfont import plain
> > PyMOL>obj = [
> > Traceback (most recent call last):
> >   File "/Applications/Molecular
> > Graphics/MacPyMOL.app/pymol/modules/pymol/parser.py", line 
> 208, in parse
> >     exec(layer.com2+"\n",self.pymol_names,self.pymol_names)
> >   File "<string>", line 1
> >      obj = [
> >             ^
> >  SyntaxError: unexpected EOF while parsing
> >
> > I can get the script to run with an old version (0.98) of 
> the Mac-X11
> > hybrid.  I can live with this, if necessary.
> >
> > 2. Once I have the axes and the molecule loaded, I would 
> like to place a
> > particular atom at the origin and then rotate the molecule into a
> > particular orientation.  I thought that I could do the first part by
> > using the translate command, by moving the molecule by amounts that
> > correspond to the negative of the initial coordinates of the atom of
> > interest.  That is, if the initial coordinates (from the 
> pdb file) are,
> > 1,-2,2, it seems that if I do
> > translate [-1,2,-2]
> > I should move the molecule so that the atom is at the 
> origin.  But, this
> > doesn't happen; The molecule moves, but not along the expected axes.
> > There is clearly something about the coordinate system and 
> the translate
> > command that I don't understand.
> >
> > Any suggestions for how to go about this would be greatly 
> appreciated!
> >
> > David
> >
> >
> > ----------------
> >
> > The script:
> >
> > # axes.py
> > from pymol.cgo import *
> > from pymol import cmd
> > from pymol.vfont import plain
> >
> > # create the axes object, draw axes with cylinders coloured 
> red, green,
> > #blue for X, Y and Z
> >
> > obj = [
> >    CYLINDER, 0., 0., 0., 10., 0., 0., 0.2, 1.0, 1.0, 1.0, 
> 1.0, 0.0, 0.,
> >    CYLINDER, 0., 0., 0., 0., 10., 0., 0.2, 1.0, 1.0, 1.0, 
> 0., 1.0, 0.,
> >    CYLINDER, 0., 0., 0., 0., 0., 10., 0.2, 1.0, 1.0, 1.0, 
> 0., 0.0, 1.0,
> >    ]
> >
> > # add labels to axes object (requires pymol version 0.8 or 
> greater, I
> > # believe
> >
> > 
> cyl_text(obj,plain,[-5.,-5.,-1],'Origin',0.20,axes=[[3,0,0],[0
> ,3,0],[0,0,3]])
> > 
> cyl_text(obj,plain,[10.,0.,0.],'X',0.20,axes=[[3,0,0],[0,3,0],
> [0,0,3]])
> > 
> cyl_text(obj,plain,[0.,10.,0.],'Y',0.20,axes=[[3,0,0],[0,3,0],
> [0,0,3]])
> > 
> cyl_text(obj,plain,[0.,0.,10.],'Z',0.20,axes=[[3,0,0],[0,3,0],
> [0,0,3]])
> >
> > # then we load it into PyMOL
> > cmd.load_cgo(obj,'axes')
> >
> > --
> > Department of Biology
> > University of Utah
> > 257 South 1400 East
> > Salt Lake City, UT  84112-0840
> >
> > Telephone: (801) 581-3885
> > Fax:  (801) 581-2174
> >
> > E-mail: goldenb...@biology.utah.edu
> > Lab web page: http://www.biology.utah.edu/goldenberg
> >
> > 
> --------------------------------------------------------------
> -----------
> > Check out the new SourceForge.net Marketplace.
> > It's the best place to buy or sell services for
> > just about anything Open Source.
> > http://sourceforge.net/services/buy/index.php
> > _______________________________________________
> > PyMOL-users mailing list
> > PyMOL-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/pymol-users
> >
> 
> 
> 
> -- 
> 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
> 
> --------------------------------------------------------------
> -----------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> PyMOL-users mailing list
> PyMOL-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pymol-users
> 
> 

Reply via email to