How do I convert GUI operations to CUI operations in pymol?
1
1
Entering edit mode
13 months ago
FT ▴ 10

The following operations were performed to display the surface charge density for the target pdb file in pymol.

  1. Load pdb file
  2. Click on the "Plugin"
  3. Click on the "APBS Electrostatistics"
  4. Click on the "Options" button on the main tab
  5. Change method to "use formal_charge and vdw"

How can I make this operation available as a command? Is there a way to check the command log for GUI operations?

pymol pdb • 1.2k views
ADD COMMENT
1
Entering edit mode
13 months ago
Wayne ★ 2.0k

Working backwards from the end of your post...
I believe you have to opt into it before you start your process so that you can collect the operaions. Go to 'Getting Started with Commands' here and look at the sections, 'Recording Your Work (Optional)' and 'Saving Your Work', particularly the subsection, 'Scripts and Log Files'. Below there talks about running the commands as scripts.

However, there is another way to interact with PyMOL rather than the simpler text-based, direct PyMOL scripting language commands. Since it is Python based and an 'Application Programming Interface' (API) has been built in, you can actually use Python to control it and issue commands via the API. You may have seen some of these in the documentation. (I'll suggest illustrating the use of cmd.zoom() below, which has the simpler PyMOL scripting language equivalent of zoom.) I have links to the PyMOL API documentation here under 'Resources'. The Python version can be tricky to write but it opens up more complex programmatic control to do things if you know a little Python. So the investment can be worth. To give you a better sense of using the PyMOL API , click on the 'launch binder' badge, towards the top of that pymol-binder page I directed you to. That will launch a temporary session on a remote computer provided via the MyBinder service. When it starts up, a page will come up with a list of notebooks; however, the quick-start basic example is down on that page that first comes and so scroll down to 'Basic Example'. Now you wouldn't use it that way probably since you are using the GUI right now, but you can actually paste in the PyMOL API commands on either line that says 'PyMOL>', usually above and below the structure view. (That is the PyMOL command line you may have already used. You can also paste the simpler PyMOL scripting commands there for running them in the GUI without them being an an external script file.) For example if you load a structure and zoom way out, pasting in cmd.zoom() will zoom it back to feature the structure prominently. (That isn't a great example because you can just type the PyMOL scripting language version zoom on that command line and accomplish the same thing; however, the PyMOL API commands would more likely be embedded in Python as part of a larger effort.) You can paste blocks of Python code although it can be tricky because of the indentation. And executing processes as a Python script like that session demonstrates may be more useful. (The GUI can run Python scripts as well.) I have an example of making functions using Python in the example notebook 'demo_palette.ipynb' that is one of the ones you can work through. In static form, look for the define function set_my_view() here for an example. (It's in the code cell presently indicted with 'In[5]' under 'Iterating over combinations applied to chains from a set color palette'.)

Why is this person going on about Python and an API? I'm not planning to use that. Sometimes when looking into the documentation it isn't readily apparent why there's seemingly two versions of commands. And it can be more confusing when people post solutions because it may not be stated what interface they are using. Hopefully know there can be two versions of most commands will allow you to better translate suggestions to your chosen approach.

Getting back to your question ...
And then once you have the commands you can either use the script or make it a Python function that you can run or call, respectively.

ADD COMMENT
0
Entering edit mode

Thanks for the reply.

I tried logging using the log_open command, but it did not log the process like clicking a button. (Commands like cd and ls could be logged.) Is there another way to command operations by clicking buttons?

By the way, I have already been able to run commands such as cmd.zoom() as you have presented in another program. (pymol.cmd.do("reinitialize"), pymol.cmd.load(), pymol.cmd.do("bg_color white"), etc.)

ADD REPLY
1
Entering edit mode

What buttons are you speaking of that aren't being logged? I just tested adjusting the view using the "Action / Show / Hide / Label/ Color"-panel by selecting 'File' > 'Log File' > 'Open' doing operations using that panel and then closing the log file ('File' > 'Log File' > 'Close'). When I view the file in the text editor the steps I did are indicated in the contents.

ADD REPLY
0
Entering edit mode

Thank you for your kind reply. I'm sorry that my explanation is not clear.

I'm speaking of 'Plugin' tab you see in the attached image. image

The operation I want to do, written in the format you have indicated, would look like this.

'Plugin' > 'APBS Electrostatics' > 'options(Prepare Molecule)' > 'use formal_charge and vdw(Method)' > 'Run'

I was also able to record the operations you indicated like "Action / Show / Hide / Label/ Color", but not the operations done with 'Plugin'.

ADD REPLY
0
Entering edit mode

I haven't used those with the log. I wonder if the plugins have different levels of integration into the log command system because as a plugin, they are third-party?
Closest reference I found was from here:

'3) Click "Run" If you are curious how PyMOL fills in the other fields in the APBS Template, check "Don't delete temporary files" in the Advanced Configuration tab. PyMOL will print something like "Notice: not deleting /tmp/tmpGMpmWQ" to the log window. In that directory, you'll find "apbs.in".'

It does seem like only two years ago they were really overhauling the APBS stuff.

ADD REPLY

Login before adding your answer.

Traffic: 3873 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

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

Powered by the version 2.3.6