This is a read-only mirror of pymolwiki.org

Difference between revisions of "Pymolrc"

From PyMOL Wiki
Jump to navigation Jump to search
(technical details)
m (1 revision)
 
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
When Pymol [[Launching PyMOL|launches]], it will read custom settings and functions from a pymolrc file, if it exists. This is simply a script in PyMOL command syntax or in python syntax, depending on the suffix.
+
When Pymol [[Launching PyMOL|launches]], it will read custom settings and functions from a pymolrc file, if it exists. This is simply a script in PyMOL command syntax or in python syntax, depending on the suffix.<br>
 +
Creating pymolrc files is a convenient way of loading individualized settings.
  
The typical location on Windows would be:
+
== Open a pymolrc File for Editing ==
  
C:\Users\YOU\pymolrc.pml
+
<div style="padding: 0.5em 1em; margin-bottom: 1em; background-color: #6f6">
 +
PyMOL 2.0 has a built-in editor: '''File > Edit pymolrc'''
 +
</div>
  
and on a Unix/Linux-type system (including Mac OS X):
+
On Windows: '''Start > Run''' and then paste
  
  /home/YOU/.pymolrc
+
  notepad "%HOMEDRIVE%%HOMEPATH%\pymolrc.pml"
 +
 
 +
On Unix/Linux-type system (including Mac OS X): Open a terminal and type
 +
 
 +
nano ~/.pymolrc
  
 
== Technical Details ==
 
== Technical Details ==
Line 14: Line 21:
 
* Files ending on '''.py''' (or .pym) will be parsed as python scripts, files ending on '''.pml''' or without suffix will be parsed as PyMOL command syntax.
 
* Files ending on '''.py''' (or .pym) will be parsed as python scripts, files ending on '''.pml''' or without suffix will be parsed as PyMOL command syntax.
 
* Several directories are searched, in order:
 
* Several directories are searched, in order:
 +
** current working directory
 
** $HOME
 
** $HOME
** $HOMEPATH + $HOMEDRIVE (on Windows)
+
** $HOMEDRIVE + $HOMEPATH (on Windows)
 
** $PYMOL_PATH
 
** $PYMOL_PATH
* PyMOL will even load multiple pymolrc files, however only either with dot or without dot, and only from the same directory. But you could for example have two scripts ''.pymolrc-settings.py'' and ''.pymolrc-misc.py'' in your home directory.
+
* $PYMOL_PATH/run_on_startup* is loaded before any '''pymolrc''' files
 +
 
 +
===Multiple pymolrc files===
 +
PyMOL will even load '''multiple pymolrc files''', however only either with dot or without dot, and only from the same directory.<br>
 +
You can have multiple scripts: e.g. '''pymolrc-settings.pml''' and '''pymolrc-misc.pml''' in your home directory.
 +
* '''pymolrc-settings.pml''' can e.g. be used to define 'permanent' custom [[Settings]] that you rarely change
 +
* '''pymolrc-misc.pml''' can e.g. be used to define more transient custom [[Settings]], such as [[Cd|Working Directory]] or [[Fetch Path]]
 +
You can query which pymolrc files have been loaded:
 +
 
 +
PyMOL> print invocation.options.deferred
  
 
== Example ==
 
== Example ==
  
 
<source lang="python">
 
<source lang="python">
 +
# simple test: change background color of PyMOL window
 +
bg blue
 +
 
# this will run the script in the specified location
 
# this will run the script in the specified location
 
run /path/to/home/pymol/load_sep.py
 
run /path/to/home/pymol/load_sep.py
  
 +
# your favorite settings
 
set movie_loop, 0
 
set movie_loop, 0
 
set two_sided_lighting, 1
 
set two_sided_lighting, 1
Line 40: Line 61:
 
set stick_radius, 0.3
 
set stick_radius, 0.3
  
# set fetch_path
+
# save fetched PDB files here
 
set fetch_path, /your/fetch/path
 
set fetch_path, /your/fetch/path
 +
 +
# Personal short-cut to color_obj function
 +
import color_obj
 +
cmd.extend("co",color_obj.color_obj)
 
</source>
 
</source>
 +
 +
== Reload a pymolrc File ==
  
 
To reload a pymolrc file (e.g. after editing .pymolrc, or after running [[reinitialize]]), [[Running Scripts|run it]] like any other script:
 
To reload a pymolrc file (e.g. after editing .pymolrc, or after running [[reinitialize]]), [[Running Scripts|run it]] like any other script:
Line 57: Line 84:
  
 
[[Category:Launching]]
 
[[Category:Launching]]
 +
[[Category:Scripting]]

Latest revision as of 05:40, 25 July 2018

When Pymol launches, it will read custom settings and functions from a pymolrc file, if it exists. This is simply a script in PyMOL command syntax or in python syntax, depending on the suffix.
Creating pymolrc files is a convenient way of loading individualized settings.

Open a pymolrc File for Editing

PyMOL 2.0 has a built-in editor: File > Edit pymolrc

On Windows: Start > Run and then paste

notepad "%HOMEDRIVE%%HOMEPATH%\pymolrc.pml"

On Unix/Linux-type system (including Mac OS X): Open a terminal and type

nano ~/.pymolrc

Technical Details

  • The leading dot is optional, so everything that starts with .pymolrc or pymolrc will be found by PyMOL. Files with dot take precedence over files without dot.
  • Files ending on .py (or .pym) will be parsed as python scripts, files ending on .pml or without suffix will be parsed as PyMOL command syntax.
  • Several directories are searched, in order:
    • current working directory
    • $HOME
    • $HOMEDRIVE + $HOMEPATH (on Windows)
    • $PYMOL_PATH
  • $PYMOL_PATH/run_on_startup* is loaded before any pymolrc files

Multiple pymolrc files

PyMOL will even load multiple pymolrc files, however only either with dot or without dot, and only from the same directory.
You can have multiple scripts: e.g. pymolrc-settings.pml and pymolrc-misc.pml in your home directory.

You can query which pymolrc files have been loaded:

PyMOL> print invocation.options.deferred

Example

# simple test: change background color of PyMOL window
bg blue

# this will run the script in the specified location
run /path/to/home/pymol/load_sep.py

# your favorite settings
set movie_loop, 0
set two_sided_lighting, 1

set label_size, 60
set label_outline_color, 1
set label_color, 0
set label_position, [0, 0, 10]

# for images:
#   antialias =1 smooths jagged edges, 0 turns it off
set antialias, 1

#   stick_radius -adjust thickness of atomic bonds
set stick_radius, 0.3

# save fetched PDB files here
set fetch_path, /your/fetch/path

# Personal short-cut to color_obj function
import color_obj
cmd.extend("co",color_obj.color_obj)

Reload a pymolrc File

To reload a pymolrc file (e.g. after editing .pymolrc, or after running reinitialize), run it like any other script:

@~/.pymolrc

or

run ~/.pymolrc.py

See Also