Launching PyMOL: Difference between revisions

From PyMOLWiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
=Launching PyMOL=
PyMOL can be started from the command line or from a Python script.  Also, PyMOL has lots of [[Command_Line_Options|command line options]] that one can pass in to affect PyMOL's behavior.  For example, one can load a few proteins and even execute a script all from the commandline.  Also, there's a '''.pymolrc''' file that initializes PyMOL each time PyMOL is executed (for more information on the .pymolrc file, just search the wiki for "pymolrc", or see an [[Inchoates_pymolrc|example .pymolrc]]).


[[Command Line Options]]
* More on launching PyMOL
**[[Command Line Options]]
**[[Launching From a Script]]


[[Launching From a Script]]
=Invoking PyMOL and reading startup commands from a file=
==Linux==
Assuming the executable is in your '''$PATH''', simply issue
<source lang="python">
pymol
</source>
together with any [[Command_Line_Options]] and arguments (pdb files, pse files, map files and so forth) you require.


==Invoking PyMOL and reading startup commands from a file==
Whenever PyMol starts, a user-created '~/.pymolrc' file containing commands is run. All you need to do is create ".pymolrc" and place it in your home directory. Alternatively, you can instead create ".pymolrc.py" which contains actual Python code instead of just PyMOL commands.  See an [[Inchoates_pymolrc|example .pymolrc]]).


===<b>Linux:</b>===
Assuming the executable is in your $PATH, simply issue


  pymol
==Windows==
On Windows, use 'pymolrc', 'pymolrc.py' or 'pymolrc.pym'. For global defaults (all users), you can place a .pymolrc file in C:\Program Files\DeLano Scientific\PyMOL.  You can launch PyMOL from the applications menu or from the icon on your desktop (if you placed one there).


together with any [[Command Line Options]] and arguments (pdb files, pse files, map files and so forth) you require.
==MacOS X==
===Launching===
* Double-click the application's icon
* Issue the unix command <source lang="bash">open -a MacPyMOL</source>
* Directly invoking the unix executable <source lang="bash">/Applications/MacPyMOL.app/Contents/MacOS/MacPyMOL</source>
* If MacPyMOL is set as the default application to open pdb, pse and other such files, double-clicking any of those files (or issuing the unix open command) will start also pymol and load the file you clicked on.


Whenever PyMol starts, a user-created '~/.pymolrc' file containing commands is run. All you need to do is create ".pymolrc" and place it in your home directory. Alternatively, you can instead create ".pymolrc.py" which contains actual Python code instead of just PyMOL commands.


===<b>Windows:</b>===
The third one assumes the application has been placed in '''/Applications''', so adjust the absolute path if you have it elsewhereIf you directly invoke the unix executable to launch pymol, it has the advantage that you can pass [[Command_Line_Options]] and arguments to it in the usual way.  You might wish to '''make an alias''':
On Windows, use 'pymolrc', 'pymolrc.py' or 'pymolrc.pym'.  For global defaults (all users), you can place a .pymolrc file in C:\Program Files\DeLano Scientific\PyMOL
 
===<b>MacOS X:</b>===
 
====Launching the Application====
You can launch MacPyMOL by
 
* Double-clicking the application's icon, or by
* Issuing the unix command
<source lang="bash">
<source lang="bash">
open -a MacPyMOL
alias pymol=/Applications/Xtal/MacPyMOL.app/Contents/MacOS/MacPyMOL
</source>
</source>
or by
(leave out the equal sign for tcsh) '''or [http://en.wikipedia.org/wiki/Symbolic_link symbolic link]'''
* Directly invoking the unix executable
<source lang="bash">
/Applications/MacPyMOL.app/Contents/MacOS/MacPyMOL
sudo ln -s /Applications/Xtal/MacPyMOL.app/Contents/MacOS/MacPyMOL /usr/local/bin/pymol
 
</bash>
The latter assumes the application has been placed in /Applications, so adjust the absolute path if you have it elsewhere.  If you directly invoke the unix executable to launch pymol, it has the advantage that you can pass [[Command Line Options]] and arguments to it in the usual way.  You might wish to '''make an alias'''
 
alias pymol=/Applications/Xtal/MacPyMOL.app/Contents/MacOS/MacPyMOL
 
(leave out the equal sign for tcsh) '''or symbolic link'''
 
sudo ln -s /Applications/Xtal/MacPyMOL.app/Contents/MacOS/MacPyMOL /usr/local/bin/pymol
 
or '''use this shell script''' [[User:Wgscott|I]] wrote: [http://xanana.ucsc.edu/Library/init/zsh/local-functions/xtal/pymol pymol] shell script (and zsh function) to invoke pymol on the command line. It uses OS X 10.4's mdfind to locate the executable.
or '''use this shell script''' [[User:Wgscott|I]] wrote: [http://xanana.ucsc.edu/Library/init/zsh/local-functions/xtal/pymol pymol] shell script (and zsh function) to invoke pymol on the command line. It uses OS X 10.4's mdfind to locate the executable.


* If MacPyMOL is set as the default application to open pdb, pse and other such files, double-clicking any of those files (or issuing the unix open command) will start also pymol and load the file you clicked on.
===IDLE===
<br>
MacPyMOL can also be run from within [http://www.python.org/idle/doc/idle2.html IDLE].  Make sure you use Fink's IDLE, not Mac IDLE:
 
====IDLE====
MacPyMOL can also be run from within IDLE.  Make sure you use Fink's IDLE, not Mac IDLE:
<source lang="bash">
<source lang="bash">
which idle2.5    # should return the following
which idle2.5    # should return the following
Line 54: Line 45:




====Reading the pymolrc file====
===Reading the pymolrc file===
In each case, pymol will read the contents of the user's ~/.pymolrc file and/or ~/.pymolrc.py file (as with Linux).  
In each case, PyMol will read the contents of the user's ~/.pymolrc file and/or ~/.pymolrc.py file (as with Linux). Here is one example of a [[MacOSX-specific .pymolrc file]] with a script enabling interaction via the [[MAC_Install#PowerMate_Dial |PowerMate Dial]]A couple of simple lines to put in your .pymolrc might be to respectively change to your favorite directory and increase the window size:
 
<source lang="bash">
Here is one example of a [[MacOSX-specific .pymolrc file]] with a script enabling interaction via the [[MAC_Install#PowerMate_Dial |PowerMate Dial]]
 
A couple of simple lines to put in your .pymolrc might be to respectively change to your favourite directory and increase the window size:
<pre>
cd ~/Documents/structures/
cd ~/Documents/structures/
viewport 750,750
viewport 750,750
</pre>
</source>


==Launching PyMOL from an external application==
==Launching PyMOL from an external application==
 
If '''PYMOL_PATH''', '''LD_LIBRARY_PATH''', and '''TCL_LIBRARY''' are correctly defined, then you can launch PyMOL from an external Python program as shown in ''examples/devel/start_pymol.py''. '''nb.''': This approach is not recommended, since the PyMOL launching process is subject to change without warning. The recommended approach is to just use PyMOL as your python interpreter:
If PYMOL_PATH, LD_LIBRARY_PATH, and TCL_LIBRARY are correctly defined, then you can launch PyMOL from an external Python program as shown in ''examples/devel/start_pymol.py''.
 
NOTE: This approach is not recommended, since the PyMOL launching process is subject to change without warning. The recommended approach is to just use PyMOL as your python interpreter:
<source lang="python">
<source lang="python">
pymol -r <script.py>
pymol -r <script.py>
Line 75: Line 59:
</source>
</source>


 
==Running PyMOL in batch mode==
==Running PyMOL in batch mode==
 
To perform PyMOL commands from stdin (file, pipe) without opening an OpenGL window use the following [[Command_Line_Options]]:
To perform PyMOL commands from stdin (file, pipe) without opening an OpenGL window, try:
<source lang="python">
<source lang="python">
pymol -qc
pymol -cq
</source>
</source>
   
   
==Suppressing PyMOL output==
==Suppressing PyMOL output==
To suppress most of PyMOL's normal chatter, just type on the Cmd line:
To suppress most of PyMOL's normal chatter, just type on the PyMOL command line:
<source lang="python">
<source lang="python">
feedback disable,all,actions
feedback disable,all,actions
feedback disable,all,results
feedback disable,all,results
</source>
</source>
or, from Python:
or, from Python (API):
<source lang="python">
<source lang="python">
cmd.feedback("disable","all","actions")
cmd.feedback("disable","all","actions")
Line 101: Line 84:
run script.py
run script.py
</source>
</source>
Is enough. Of course, the file script.py needs to be in the working directory.
Is enough. Of course, the file script.py needs to be in the working directory. For more detailed examples, see the commands to launch Python scripts when starting PyMOL. Asynchronous means, that a new Python thread is started:
For more detailed examples, see the commands to launch Python scripts when starting PyMOL. Asynchronous means, that a new Python thread is started:
 
<source lang="python">
<source lang="python">
pymol example.py    # synchronous, in PyMOL module
pymol example.py    # synchronous, in PyMOL module
Line 126: Line 107:


Windows users can do this with a pymolrc file.
Windows users can do this with a pymolrc file.
[[Category:Launching]]

Revision as of 13:13, 12 September 2008

PyMOL can be started from the command line or from a Python script. Also, PyMOL has lots of command line options that one can pass in to affect PyMOL's behavior. For example, one can load a few proteins and even execute a script all from the commandline. Also, there's a .pymolrc file that initializes PyMOL each time PyMOL is executed (for more information on the .pymolrc file, just search the wiki for "pymolrc", or see an example .pymolrc).

Invoking PyMOL and reading startup commands from a file

Linux

Assuming the executable is in your $PATH, simply issue

pymol

together with any Command_Line_Options and arguments (pdb files, pse files, map files and so forth) you require.

Whenever PyMol starts, a user-created '~/.pymolrc' file containing commands is run. All you need to do is create ".pymolrc" and place it in your home directory. Alternatively, you can instead create ".pymolrc.py" which contains actual Python code instead of just PyMOL commands. See an example .pymolrc).


Windows

On Windows, use 'pymolrc', 'pymolrc.py' or 'pymolrc.pym'. For global defaults (all users), you can place a .pymolrc file in C:\Program Files\DeLano Scientific\PyMOL. You can launch PyMOL from the applications menu or from the icon on your desktop (if you placed one there).

MacOS X

Launching

  • Double-click the application's icon
  • Issue the unix command
    open -a MacPyMOL
    
  • Directly invoking the unix executable
    /Applications/MacPyMOL.app/Contents/MacOS/MacPyMOL
    
  • If MacPyMOL is set as the default application to open pdb, pse and other such files, double-clicking any of those files (or issuing the unix open command) will start also pymol and load the file you clicked on.


The third one assumes the application has been placed in /Applications, so adjust the absolute path if you have it elsewhere. If you directly invoke the unix executable to launch pymol, it has the advantage that you can pass Command_Line_Options and arguments to it in the usual way. You might wish to make an alias:

alias pymol=/Applications/Xtal/MacPyMOL.app/Contents/MacOS/MacPyMOL

(leave out the equal sign for tcsh) or symbolic link

sudo ln -s /Applications/Xtal/MacPyMOL.app/Contents/MacOS/MacPyMOL /usr/local/bin/pymol
</bash>
or '''use this shell script''' [[User:Wgscott|I]] wrote: [http://xanana.ucsc.edu/Library/init/zsh/local-functions/xtal/pymol pymol] shell script (and zsh function) to invoke pymol on the command line. It uses OS X 10.4's mdfind to locate the executable.

===IDLE===
MacPyMOL can also be run from within [http://www.python.org/idle/doc/idle2.html IDLE].  Make sure you use Fink's IDLE, not Mac IDLE:
<source lang="bash">
which idle2.5     # should return the following
/sw/bin/idle2.5   # Fink's IDLE.


Reading the pymolrc file

In each case, PyMol will read the contents of the user's ~/.pymolrc file and/or ~/.pymolrc.py file (as with Linux). Here is one example of a MacOSX-specific .pymolrc file with a script enabling interaction via the PowerMate Dial. A couple of simple lines to put in your .pymolrc might be to respectively change to your favorite directory and increase the window size:

cd ~/Documents/structures/
viewport 750,750

Launching PyMOL from an external application

If PYMOL_PATH, LD_LIBRARY_PATH, and TCL_LIBRARY are correctly defined, then you can launch PyMOL from an external Python program as shown in examples/devel/start_pymol.py. nb.: This approach is not recommended, since the PyMOL launching process is subject to change without warning. The recommended approach is to just use PyMOL as your python interpreter:

pymol -r <script.py>
pymol -qcr <script.py>


Running PyMOL in batch mode

To perform PyMOL commands from stdin (file, pipe) without opening an OpenGL window use the following Command_Line_Options:

pymol -cq

Suppressing PyMOL output

To suppress most of PyMOL's normal chatter, just type on the PyMOL command line:

feedback disable,all,actions
feedback disable,all,results

or, from Python (API):

cmd.feedback("disable","all","actions")
cmd.feedback("disable","all","results")


Launching Python scripts

Running a Python script from PyMOL, usually the command:

run script.py

Is enough. Of course, the file script.py needs to be in the working directory. For more detailed examples, see the commands to launch Python scripts when starting PyMOL. Asynchronous means, that a new Python thread is started:

pymol example.py     # synchronous, in PyMOL module
pymol -r example.py  # synchronous in __main__ module
pymol -l example.py  # asychronous in a new module

You can also launch python programs from within PyMOL with the commands:

run example.py        # synchronous in pymol module
run example.py,main   # synchronous in __main__ module

spawn example.py        # asychronous in a new module
spawn example.py,global # asychronous in the PyMOL module
spawn example.py,main   # asychronous in the __main__ module


Overwriting Default Settings

If you don't like the cartoon default color and want to change default settings for it, from green to slate, you add the command line to do this in $HOME/.pymolrc. Here, 'set cartoon_color, slate'

Windows users can do this with a pymolrc file.