Hi Jouko,

You were writing a python script. Now Pymol API can handle basic
Python, but it's not a one-to-one Python interpreter. To include
blocks you have to do more than indentation. You have to put a slash
in front of the for statement and end all but the of the blocks with a
backslash. When trying to do programming, better stick to Python. Save
the following as script.py and use run script.py from within Pymol or
just issue 'pymol script.py':

from pymol import cmd

z=-7.653
inc=0.5
Sections=100
FirstToLast=range(100)
for j in FirstToLast:
        pdb="/home/jouko/DensityCube_Lysozyme2-4a/DensityCube_Lysozyme2-4a_"
+ str(z) + ".pdb"
        cmd.load(pdb)
        cmd.do("@/home/jouko/b_color8.plm")
        cmd.png(pdb+".png")
        cmd.delete(pdb)
        z=z+inc
        print z

###

Cheers,

Tsjerk

On Tue, Jul 7, 2009 at 5:47 PM, <jo...@uchicago.edu> wrote:
> Thanks to you and Gregori Gerebtzoff, I can now load the pdb,
> color the image, and save it as a picture.  However I can only
> do that for the first cross section.  I am still getting the
> unexpected EOF error.  I did have the line indented after the
> loop.  I think that maybe when I copied and pasted the script
> to the email the tab was lost, so this time I am adding the
> script file as an attachment.
>
> Thanks,
>
> Jouko
>
> P.S.  I found that @/home/jouko/b_color8.plm and
> cmd.do("@/home/jouko/b_color8.plm")  both work.
>
> ---- Original message ----
>>Date: Tue, 7 Jul 2009 09:17:53 +0200
>>From: Tsjerk Wassenaar <tsje...@gmail.com>
>>Subject: Re: [PyMOL] unexpected EOF while parsing
>>To: jo...@uchicago.edu
>>Cc: pymol-users@lists.sourceforge.net
>>
>>Hi Jouko,
>>
>>I think you went through the Python and Pymol tutorials a bit
> too fast
>>;) You're writing a Python script to be loaded with 'run'.
> That means
>>you have to adhere to Python API and can't use the Pymol specific
>>language. E.g. you can't use 'png pdb', but have to use
> 'cmd.png(pdb)'
>>in which case pdb will be treated as a variable rather than a
> string.
>>And you definitely can't use '@something.pml'.
>>
>>The EOF is because you violated one of the basic rules of
> Python: it
>>uses indentation to structure programming. Thus after a for
> loop you
>>have to start an indented line.
>>
>>Furthermore:
>>- range by default starts from 0: range(0,Sections) is equal
> to range(Sections)
>>- load will strip .pdb from the filename, so you wouldn't be
> able to
>>use the variable pdb to point to it; better specify a name
>>- png probably adds .png to the name, but it's good to make
> sure it does
>>
>>###
>>
>>from pymol.cgo import *
>>import colorsys,sys,re
>>from pymol import cmd
>>
>>z=-8.153
>>inc=0.5
>>Sections=100
>>for j in range(0, Sections):
>>
> pdb="c:/Users/jouko/Desktop/Research/Lysozyme/DensityCube_Lysozyme2-4a/DensityCube_Lysozyme2-4a_"+
>>str(z) + ".pdb"
>>    load(pdb,pdb)
>>    cmd.do("@c:/b_color8.plm")
>>    cmd.png(pdb+".png")
>>    cmd.delete(pdb)
>>    z=z+inc
>>
>>Hope it helps,
>>
>>Tsjerk
>>
>>On Tue, Jul 7, 2009 at 3:17 AM, <jo...@uchicago.edu> wrote:
>>> I am new to pymol and python.  I have a number of cross
>>> sections of lysozyme.  I want to display them one by one,
>>> color them using a script file that I have written earlier,
>>> and save the image.  I have written a script file that I had
>>> hoped would do this.  I have a couple problems with script
>>> file, but the one that is frustrating me the most is that
>>> immediately after the beginning of for loop pymol says that
>>> there in an unexpected EOF.  The other problem is that when I
>>> try to use the variable pdb, pymol does not use the value of
>>> the variable, but the variable name itself.  I have pasted my
>>> script file below and part of the log file.
>>>
>>> from pymol.cgo import *
>>> import colorsys,sys,re
>>> from pymol import cmd
>>>
>>> z=-8.153
>>> inc=0.5
>>> Sections=100
>>> for j in range(0, Sections):
>>>
>>>
> pdb="c:/Users/jouko/Desktop/Research/Lysozyme/DensityCube_Lysozyme2-4a/DensityCube_Lysozyme2-4a_"
>>> + str(z) + ".pdb"
>>>      load pdb
>>>     �...@c:/b_color8.plm
>>>      png pdb
>>>      delete pdb
>>>      z=z+inc
>>>
>>>
>>> PyMOL>@c:/Users/jouko/CrossSections.plm
>>> PyMOL>from pymol.cgo import *
>>> PyMOL>import colorsys,sys,re
>>> PyMOL>from pymol import cmd
>>> PyMOL>z=-8.153
>>> PyMOL>inc=0.5
>>> PyMOL>Sections=100
>>> PyMOL>for j in range(o, Sections):
>>> Traceback (most recent call last):
>>>  File "C:\Program Files\DeLano
>>> Scientific\PyMOL/modules\pymol\parser.py", line 256, in parse
>>>   exec(layer.com2+"\n",self.pymol_names,self.pymol_names)
>>>  File "<string>", line 1
>>>    for j in range(o, Sections):
>>>                                ^
>>> SyntaxError: unexpected EOF while parsing
>>>
> PyMOL>pdb="c:/Users/jouko/Desktop/Research/Lysozyme/DensityCube_Lysozyme2-4a/DensityCube_Lysozyme2-4a_"
>>> + str(z) + ".pdb"
>>> PyMOL>load pdb
>>> ExecutiveProcessPDBFile-Error: Unable to open file 'pdb'.
>>>
>>> Thanks in advance for your advice.
>>>
>>>
>>> Jouko
>>>
>>>
> ------------------------------------------------------------------------------
>>> Enter the BlackBerry Developer Challenge
>>> This is your chance to win up to $100,000 in prizes! For a
> limited time,
>>> vendors submitting new applications to BlackBerry App
> World(TM) will have
>>> the opportunity to enter the BlackBerry Developer
> Challenge. See full prize
>>> details at: http://p.sf.net/sfu/blackberry
>>> _______________________________________________
>>> 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

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have 
the opportunity to enter the BlackBerry Developer Challenge. See full prize 
details at: http://p.sf.net/sfu/blackberry
_______________________________________________
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

Reply via email to