Glad is working! Since the script is a Python script (not a PyMOL script) you should be using the PyMOL API syntax. For example:
- “set light_count,8” becomes cmd.set(“light_count”, “8”) - “load filename” becomes cmd.load(“filename”) I hope it helps. Cheers, Osvaldo. On Mon, Jun 8, 2015 at 9:54 AM, Praz Nina <praz...@gmail.com> wrote: Thanks Osvaldo, now it works perfectly. I even managed to figured out how > to load sdf files instead of pdb. > > One question - in the code where there is ### insert your code here ###, I > paste my PyMol settings, but I get an "invalid syntax" error. For example, > I put "set light_count,8" and that results in the before-mentioned error > message. > > On Mon, Jun 8, 2015 at 2:22 PM, Osvaldo Martin <aloctavo...@gmail.com> > wrote: > >> Hi Praz, >> >> Sorry. Please use this new version of the script. >> >> import __main__ >> __main__.pymol_argv = ['pymol','-qc'] >> import pymol >> from pymol import cmd >> pymol.finish_launching() >> import glob >> import os >> >> path = os.path.dirname(pymol.__script__) >> >> cmd.delete('all') >> pdb_files = glob.glob(os.path.join(path, '*.pdb')) >> for pdb in pdb_files: >> cmd.load(pdb) >> ### insert your code here ### >> cmd.png('%s' % pdb.split('.')[0]) >> cmd.delete('all') >> >> >> The last didn’t work because I was expecting you to run the script just >> as any Python program (and not from PyMOL) using one of this two options >> <http://stackoverflow.com/questions/9493086/python-how-do-you-run-a-py-file>. >> Sorry about not explaining this before. The version I am sending you know >> should work with any of the 3 running methods. >> >> Cheers, >> >> Osvaldo. >> >> On Mon, Jun 8, 2015 at 7:27 AM, Praz Nina <praz...@gmail.com> wrote: >> >> Thank you Osvaldo. >>> >>> However, as a beginner, I am having problems with getting this to work. >>> I pasted your script in a file (script.txt) and placed it in the same >>> folder where the pdb files are. Then I ran PyMol and typed "run >>> c:\somefolder\script.txt", but I all get is a black screen and no .png >>> files are generated. >>> >>> On Sat, Jun 6, 2015 at 2:42 AM, Osvaldo Martin <aloctavo...@gmail.com> >>> wrote: >>> >>>> Hi Praz, >>>> >>>> When I want to process several files, do complex or repetitive tasks I >>>> prefer to write a Python script and access the PyMOL functions using the >>>> PyMOL API, as in the code below. >>>> >>>> This example will upload all the pdb files in the folder where the >>>> script is located, one file at a time, save the current image as a png file >>>> and then delete the uploaded molecule. >>>> >>>> import __main__ >>>> __main__.pymol_argv = ['pymol','-qc'] >>>> import pymol >>>> from pymol import cmd >>>> pymol.finish_launching() >>>> import glob >>>> >>>> pdb_files = glob.glob('*.pdb') >>>> for pdb in pdb_files: >>>> cmd.load(pdb) >>>> ### insert your code here ### >>>> cmd.png('%s' % pdb.split('.')[0]) >>>> cmd.delete('all') >>>> >>>> >>>> Cheers, >>>> Osvaldo. >>>> >>>> On Fri, Jun 5, 2015 at 7:50 PM, Praz Nina <praz...@gmail.com> wrote: >>>> >>>>> Hi all, >>>>> >>>>> I'm a beginner at PyMol, but I'm wondering if a batch action like this >>>>> would be possible: If I have a bunch of .sdf and .pdb files in a folder, >>>>> and I want to apply a specific "look" to all of them (I've written the >>>>> parameters regarding light, field of view etc.), is it possible to batch >>>>> process all of them and output a .png file of each of those structures? >>>>> >>>>> Likewise, if I want to make a movie from all of those structures (also >>>>> have written a script, 450 frames, 360 rotation), can I process these >>>>> files >>>>> in a batch? >>>>> >>>>> Thanks, >>>>> Praz >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> >>>>> _______________________________________________ >>>>> 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 >>>>> >>>> >>>> >>> >> > >
------------------------------------------------------------------------------
_______________________________________________ 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