Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help
Special pages
SBGrid Resources
SBGrid Consortium
SBGrid Data Bank
Software Webinars
PyMOL Webinar
PyMOL Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Pml
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== PyMOL Script == PyMOL scripts are plain text files containing PyMOL commands, one per line, appearing as they would be entered at the PyMOL command prompt. The standard extension for a PyMOL script is <tt>.pml</tt>. === Basic usage === Save your commands in a plain text file (using e.g. Notepad, TextEdit, or a text editor of your choice) with a <tt>.pml</tt> extension, e.g. <tt>script.pml</tt>. Run the script by either '''File > Run script...''' in the GUI menu bar, or via the command @/path/to/my/script.pml Relative paths are fine, so if PyMOL has been launched in the same directory as your script, you can simplify this to <code>@script.pml</code> === Command syntax === PyMOL commands are typically in the form: command arg1[, arg2[, ...]] For example: color green, chain A which will, as you might expect, color all the atoms of chain A green. There is no comma between the command and the first argument, and in general, no quotation marks are necessary around the arguments. (Exceptions to this rule include situations where you are passing a text string as an argument which contains a comma; in this case the entire string should be quoted.) For commands that take keyword arguments, the syntax is similar to passing keyword arguments to a Python function: fetch 1nmr, async=0 will use the asynchronous version of <code>fetch</code>, waiting to execute any following commands until the <code>fetch</code> command finishes. ==== Python code ==== ''PyMOL'' scripts can also contain ''Python'' code. Single-line Python statements can be written normally and will be handled as expected; <source lang="python"> # imports import this from glob import glob # variable assignments prefix = "structure_" # complex single-line statements like list comprehensions [cmd.load(x) for x in glob(f'{prefix}*.pdb')] # any other arbitrary Python code print(2 + 2) </source> Python code that spans more than one line can be enclosed in a <code>python/python end</code> code block, like this: <source lang="python"> python def hello(name="World"): print("Hello,", name) python end </source> === Handy commands to include in your scripts === * <code>reinitialize</code> - issue this command at the start of your script to allow it to be run multiple times in the same PyMOL session. * <code>log_open log.pml</code> - create a log file to record actions taken in the GUI. Examine this log file to learn new commands, although keep in mind that these are typically formatted as Python function calls. * <code>deselect</code> - place this at the very end of the script to ensure no atoms are selected after the script completes, for a cleaner GUI appearance.
Summary:
Please note that all contributions to PyMOL Wiki are considered to be released under the GNU Free Documentation License 1.2 (see
PyMOL Wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Pml
Add topic