Pymol Scripting Help
Entering edit mode
5.4 years ago
wakimchris ▴ 10

I am new to scripting for Pymol. I have a bunch of steps that needs to be done to several .pse files.

I know that if I write the command in Pymol itself like:

hide lines, *original_ligand

It will execute. But I wanted to have a script for Pymol to run because the steps are numerous and for decreasing the variability in my experiment all the pse files need to be treated the exact same way.

So my question is: Can someone provide me with a file example and how to run the script in Pymol ?

Some of the commands I need to execute

show sticks, *original_ligand
hide lines, *original_ligand

color yellow, *original_protein
color green, *original_ligand
Pymol Script Examples needed Python • 3.8k views
Entering edit mode
5.3 years ago
Felix_Sim ▴ 250

In my experience, you have two different approaches to your problem.

1. PyMOL .pml script

This type contains basically a set of commands, just like you would manually type in a running PyMOL session, to read, write and manipulate structure objects. Typically, these files have the .pml extension and are invoked in a running session using @<FILENAME>.pml.

An example would literally be your own set of commands saved to a file and invoked with the command syntax explained in the paragraph above. However, I think your best option is to have a look at the following part of the PyMOL documentation explaining the different options.

In my opinion, this is the easier option but less automatic.

2. Python pymol script

Your second option focuses on using the Python API. This requires you to have a basic understanding of the Python programming language and how to script in it. If you are already familier with the Python language, you will love the pymol package. This is already shipped with your PyMOL and can be used in the following manner.

Using the PyMOL python, invoked the following script using /path/to/pymol/python The script contains something along the following lines.

from pymol import cmd
cmd.load("example.pdb")"sticks", "*original_ligand")
cmd.hide("lines", "*original_ligand")"final.pse")

You can, of course, extend this and instead of having a fixed PDB filename, such as example.pdb, parse a name from the command line or define them in a list. Your imagination, needs or knowledge of Python are the limit, just like any other programming challenge.

Some further examples and explanations can be found again in the documentation under the Simple Scripting section.


Login before adding your answer.

Traffic: 2189 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6