In Pymol, you can make your own script. There is two kind of scripts :
- .py: it’s a python script that allows to add a new function in pymol.
to import a py script on pymol write the command line:run myscript.py
- .pml: it’s a pymol script where you put all pymol command. each lines will be executed one after the other.
To run it on pymol write the command line:@myscript.pml
Be careful with that, it’s very useful but sometimes, when a command take a while (like fetch command) the next one can be executed.
I will explain how to use (and not create) python script on pymol (.py ones).
Usualy when you find a python pymol script, the author specify the command line. If not :
- open the .py script and on the top of the file, see if there is a help comment like:
""" Pymol python script to add a function to color atoms by residues. syntaxe in Pymol : color_by_resname selection """
Here you can see a syntaxe example « color_by_resname selection ». Just write this line on pymol terminal and remplace « selection » by your selection (all, resname ALA, chain A…).
- Search a ligne like « cmd.extend(…..) » (usualy at the end of file). Example :
cmd.extend("color_by_resname",color_by_resname)
the first argument is the name of the function in pymol, the second one is the python function.
So if we take this script example which color amino acids according a color-blind color (download link bellow):
run color_by_resname.py color_by_resname all
[wpdm_file id=4]