Pymol freezes when opened and closed with python
1
0
Entering edit mode
11 months ago

I need to process a lot of proteins (around 100) and part of that processing requires pymol. Since for each protein I load up to 20 PDBs I decided to write a python script that runs pymol and then closes it (to free memory space) but every time I try to close pymol it freezes, no matter how I try to close it (using pymol.cmd.quit(), manually or even using pyautogui and pressing Alt+F4). If I use the command line to run pymol I don't have any problem, but if I use python the freeze happens, does anyone have any suggestion?

I'm using both Win10 and Debian 9. In both cases pymol 2.4.1 and it is installed in a conda environment

A sample of the script:

import pymol
pymol.finish_launching()
pymol.cmd.quit()

pymol • 622 views
0
Entering edit mode

Good morning,

I have exactly the same problem ... have you found a solution?

0
Entering edit mode
4 months ago
Theo • 0

Hello again,

OK, I found a solution ... it's not very pretty but it works! :) So, the "pymol.cmd.quit()" seems to work but only if it is at the end of the "script". I had put it in a "for" loop to be able to iterate the job on all my files and it didn't work ! I tried with only one file and with "pymol.cmd.quit()" in the last command. and it works! Well, as I wasn't going to do all my files by hand, I found a trick that wasn't too bad: I'm not going to do all my files by hand, so I came up with a trick: call a second script with my pymol part in my "for" loop. Again, python doesn't seem to be designed for communication between scripts (knowing that import wasn't working) and I had to communicate the name of the files to process to my pytmol part. I'm not sure if it's a good idea to use a temporary txt file in my "for" loop to do this. my script 1 edits a txt, opens my script 2 which reads the txt with the information to pass then supresses the txt file. (all this in my "for" loop).

to make it more clearer :

file 1 :

file 2:

the function of this script is to select all the .cif's in my folder then add the hydrogens before saving them as a .pdb file

I apologize in advance for the quality of the code ^^ I'm self-taught and as if that wasn't enough I mix English and French ^^.

but if it can help!

good continuation

0
Entering edit mode

eratum : file 1 line 44 : subprocess.call