Re: [PyMOL] pyMol executing python script: file path

2010-04-15 Thread Petr Benes
Dear Mr. Hall,
thank you very much for your help. This really works (I have tested it
now on windows).
Regards,
Petr Benes

2010/4/15 David Hall :
> I think you'll be saddened to discover that if you try what Petr (the
> original poster) was doing, sys.argv[0] won't work.
>
> $ cat test.py
> print sys.argv[0]
> $ pymol -qrc test.py
> PyMOL>run test.py,main
> /sw/lib/pymol-py26/modules/pymol/__init__.py
>
> This quite clearly gives the behavior that Petr had issues with.
>
> Instead, this is what is needed is a secret variable called
> pymol.__script__ e.g.:
> import pymol
> print pymol.__script__
>
> which can be parsed to give the directory component and such.  For
> example, to get the directory name reliably:
> import pymol
> from os import path
> print path.dirname(path.abspath(pymol.__script__))
>
> I don't have the ability to test this on Windows, but it works on both
> Mac and Linux.
>
> -David
>
> On Thu, Apr 15, 2010 at 1:43 AM, Yerko Escalona  
> wrote:
>> Hi
>> how do I determine the path of the script???
>> the answer is sys.argv[0]
>> for more information see this page
>> http://diveintopython.org/functional_programming/finding_the_path.html
>>
>> PS sorry for the mistake Jason Vertrees
>>
>> --
>> Yerko Ignacio Escalona Balboa
>> Ingeniero en Biotecnología Molecular
>> Universidad de Chile
>> http://zeth.ciencias.uchile.cl/~yescalona/
>>
>> --
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> ___
>> 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
>

--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
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] pyMol executing python script: file path

2010-04-14 Thread Petr Benes
Dear pyMol users,
I am developing a python script for pyMol. If a user clicks File->Run
and selects the script (for example "c:/test/myScript.py"), how do I
determine the path of the script, i.e. ("c:/test/") from inside the
running script?
I tried various python possibilities (os.path.abspath(__file__),
inspect.getfile(sys._getframe(1))), all of them point to the pyMol
__init__.py file which is not what I need.

Thank you. Petr Benes.

--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
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] model refuses to display surface and mesh

2009-03-06 Thread petr benes
Dear pyMol users,
 I am trying to load a simple model using python into pymol using the following 
script. All works perfectly until i click for this new model to display its 
surface or mesh. The other thing is that in older versions 0.99rc the surface 
and mesh were correctly displayed, however this works no longer with 1.1 version
Does anyone know how to fix the issue? Thanks. Petr Benes

from chempy.models import Indexed
from chempy import Bond, Atom
from whrandom import random
from pymol import cmd

model = Indexed()

# create some atoms

for a in range(1,11):
   at = Atom()
   at.name = "X%02d"%a
   at.coord = [random()*5,random()*5,random()*5]
   at.vdw = 2.0
   model.atom.append(at)

# now create some bonds

for a in range(1,10):
   bd = Bond()
   bd.index = [a-1,a] # zero-based indices!
   model.bond.append(bd)

# now load and label

cmd.load_model(model,"example")
cmd.label("example","name")