NOTE: the following is unix-specific.

This is a common problem with PyMOL.  Right now it is impossible (in
practice) to use PyMOL as merely an imported module within an external
interpreter (i.e. without using "pymol.com" instead of "python" to
invoke the interpreter).  This will be fixed in a later version.

For example:

#!/bin/csh
python <<END
from pymol import cmd
cmd.cls()
END

...will fail.

For now, you need to use the pymol.com script to launch your Python
interpreter if you are going to use PyMOL.

Normal commands are interpreted first by PyMOL and then passed to Python
if PyMOL doesn't recognize the command.  You can skip PyMOL evaluation
with a preceeding /, which is almost equivalent to typing the same
command (without a preceeding slash) in a Python interpreter:

print "hello"
/print "hello"

However, you can run native Python script in external using the run
command:

run myscript.py

...which is almost equivalent to typing:

python myscript.py

...on the unix or windows command shell, or by issuing

execfile("myscript.py") 

...from within an existing Python interpreter.

IMPORTANT CONCEPT:

The key difference between 

python myscript.py    # on command line
pymol.com myscript.py # on commmand line
run myscript.py       # in PyMOL

is that default evaluation in PyMOL currently takes place in the "pymol"
module, not "__main__".  Right now there is no easy way to start a
process in the "__main__" module.  I will remedy this in the next public
release, and probably make __main__ the default namespace for the run
command (so long as that doesn't break anything).

You can however, force evaluation of your script to occur in its own
name-space:

run myscript.py,module

...or in a local namespace:

run myscript.py,local

--
mailto:war...@sunesis.com
Warren L. DeLano, Ph.D.
Informatics Manager
Sunesis Pharmaceuticals, Inc.
341 Oyster Point Blvd.
S. San Francisco, CA 94080
(650)-266-3606  FAX:(650)-266-3501

> From: Ingo Dramburg [mailto:dramb...@mailer.uni-marburg.de]
 
> Hi,
> 
> I want to include my own modules into PyMOL for visualization
> purposes. 
> If I try to use the pymol.cmd module to control a running
> PyMOL process from an external python interpreter
> I always get a segmentation fault. (SuSE 7.2, Python 2.0)
> Everything else works fine.
> 
> Example:
> >> from pymol import cmd
> >> cmd.cls()
> segmentaion fault
> 
> Is it possible to do such things in general or is it possible
> to switch to a 'native' python mode in the PyMOL window to enter 
> python commands directly :-). 
> 
> The next question is how can I pass selections from PyMOL to external 
> scripts to do calculations that are not supported by PyMOL 
> and later back to
> PyMOL for visualization.
> 
> Thanks you for any help,
> 
> Ingo.
> -- 
> ************************************************************
> Ingo Dramburg 
> 
> Institute of Pharmaceutical Chemistry
> Philipps-University Marburg
> Marbacher Weg 6, D 35032 Marburg, Germany
> 
> Tel. + 49 6421 282 1313
> Fax  + 49 6421 282 8994
> e-mail dramb...@mailer.uni-marburg.de
> http://www.agklebe.de/
> 
> _______________________________________________
> PyMOL-users mailing list
> PyMOL-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pymol-users
> 

Reply via email to