Closed Aster-the-Med-Stu closed 1 year ago
For Python 2+3 compatibility, this line should be:
pose_list.sort(key=lambda a: a.energy)
The crash on resizing is unfortunately an unsolved problem on Windows (doesn't affect Linux and Mac) with the new PyQt interface. It's a threading issue between Tk and Python. Workarounds are to not resize the window, or to run PyMOL with the old Tcl/Tk interface (not available anymore in PyMOL 2.3).
@Aster-the-Med-Stu I also had some problems on Windows. We use a patched version, I'll get into that computer to check if was only the one @speleo3 mentioned. No resizing althrought.
Pending fix for resizing bug: https://github.com/python/cpython/pull/22453
@speleo3 I know this thread is over a year old, but the fix to the syntax in the AD plugin (to go from python 2 to python 3) as suggested doesn't work for me. There are three instances of pose_list.sort in the plugin:
pose_list.sort(lambda a, b: cmp(a.energy, b.energy))
pose_list.sort(lambda a, b: cmp(a.energy, b.energy))
pose_list.sort(lambda a, b: cmp(int(a.split('::')[1]), int(b.split('::')[1])))
Changing the first instance to
pose_list.sort(key=lambda a: a.energy)
produced the following error when attempting to load a docked result from AD Vina:
AttributeError Exception in Tk callback
Function: <bound method Autodock.load_ligand_file of <pmg_tk.startup.autodock_plugin.Autodock object at 0x7f45c4109e80>> (type: <class 'method'>)
Args: ()
Traceback (innermost last):
File "/usr/local/lib/python3.9/dist-packages/Pmw.py", line 1823, in __call__
return self.func(*args)
File "/home/blake/.pymol/startup/autodock_plugin.py", line 2491, in load_ligand_file
self.load_pdbqt(filename)
File "/home/blake/.pymol/startup/autodock_plugin.py", line 2574, in load_pdbqt
self.update_combo(name)
File "/home/blake/.pymol/startup/autodock_plugin.py", line 2585, in update_combo
pose_list.sort(key=lambda a: a.energy)
File "/home/blake/.pymol/startup/autodock_plugin.py", line 2585, in <lambda>
pose_list.sort(key=lambda a: a.energy)
AttributeError: 'str' object has no attribute 'energy'
I'm not well-versed in python, but I'm assuming we needed to have defined energy beforehand in order to append it to the pose_list?
@blakemertz can you try this file? https://github.com/Pymol-Scripts/Pymol-script-repo/blob/autodock-plugin-cmp/plugins/autodock_plugin.py
Thomas, thanks for the quick response -- it appears that the revised plugin works as it should. Thank you for this help, it's much appreciated.
I see that the third occurrence of pose_list.sort is where I had made a mistake in my syntax. So int(a.split('::')[1]) is essentially splitting the docked results into separate items for display in the plugin? I'm curious why the older version of the plugin had a reference to both 'a' and 'b'. Again, thanks for your help.
I'm curious why the older version of the plugin had a reference to both 'a' and 'b'.
The new pattern basically calls something like cmp(key(a), key(b))
under the hood.
First, PyMol would crash if I move/resize the plugin window. Then, if I load a dlg produced by Autodock4 it throws the following error:
It seems that this could be reproduceable on other machines, haven't tested under Python 2...