pymol-scripts / pymol-script-repo Goto Github PK
View Code? Open in Web Editor NEWCollected scripts for Pymol
Home Page: http://www.pymolwiki.org/index.php/Git_intro
Collected scripts for Pymol
Home Page: http://www.pymolwiki.org/index.php/Git_intro
Generating receptors throws the following error:
Error: 2
OSError Exception in Tk callback
Function: <bound method Autodock.generate_receptor of <pmg_tk.startup.autodock_plugin.Autodock object at 0x0000023B982C6CC8>> (type: <class 'method'>)
Args: ()
Traceback (innermost last):
File "C:\Users\lalit\AppData\Local\Schrodinger\PyMOL2\lib\site-packages\Pmw.py", line 1823, in __call__
return self.func(*args)
File "C:\Users\lalit\AppData\Local\Schrodinger\PyMOL2\lib\site-packages\pmg_tk\startup\autodock_plugin.py", line 1940, in generate_receptor
result, output = getstatusoutput(command)
File "C:\Users\lalit\AppData\Local\Schrodinger\PyMOL2\lib\site-packages\pmg_tk\startup\autodock_plugin.py", line 85, in getstatusoutput
p = Popen(args, stdout=PIPE, stderr=STDOUT, stdin=PIPE, env=env)
File "C:\Users\lalit\AppData\Local\Schrodinger\PyMOL2\lib\subprocess.py", line 804, in __init__
restore_signals, start_new_session)
File "C:\Users\lalit\AppData\Local\Schrodinger\PyMOL2\lib\subprocess.py", line 1211, in _execute_child
startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application
Not sure what specifically isn't being read as an application or how to fix it. I have tried setting "USE_SYS_EXECUTABLE" to True and even manually editing to add "python.exe" before .py commands in the plugin in case that is the issue but it did not make any change.
The findSurfaceSequence script does not seem to detect residue ids that have an insertion code, (ex 82A vs 82). Even when 'cutoff' is set to zero, it does not register such residues as being surface exposed. Any suggestions as to how to get around this without manually changing the residue ids?
Thank you
I cteate the cgo object consists of many sphere point, I want to select two point,and use the distance command to label the distance? Is it available?
The pyanm plugin causes MacPyMOL to crash when loaded, due to a bug in the included scipy.linalg module which causes an immediate crash upon importing. This is particularly a problem when automatically importing scripts at startup.
Hello, I'm developing a plugin for PyMol and I would like my users to get the latest version of the plugin whenever it is updated. I was unable to find online whether or not users of PyMol receive messages or have their plugins updated automatically when they are changed in the repository. Could you shed some light on this?
Kind regards.
I can't install Plugin in PyMOL-2.3.2. When I click the Plugin Manager it is always failed.
The Info:
Traceback (most recent call last):
File "C:\ProgramData\PyMOL\lib\site-packages\pymol\plugins\legacysupport.py", line 83, in plugin_manager
plugin_manager_panel = PluginManager(None)
File "C:\ProgramData\PyMOL\lib\site-packages\pymol\plugins\managergui_qt.py", line 58, in __init__
self.reload_plugins()
File "C:\ProgramData\PyMOL\lib\site-packages\pymol\plugins\managergui_qt.py", line 232, in reload_plugins
item.w_version.setText(info.get_version())
File "C:\ProgramData\PyMOL\lib\site-packages\pymol\plugins\__init__.py", line 220, in get_version
v = self.get_metadata().get('Version', '')
File "C:\ProgramData\PyMOL\lib\site-packages\pymol\plugins\__init__.py", line 202, in get_metadata
for line in f:
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa8 in position 165: illegal multibyte sequence
Hi, Thomas,
The current version of extra_fit will not report rms for each alignment result because cealign returns a dict.
In PyMOL version 1.8.4, extra_fit prints only model names (see below). I would like to suggest an improvement because:
current code:
if not quiet:
if _self.is_sequence(x):
print('%-20s RMS = %8.3f (%d atoms)' % (model, x[0], x[1]))
elif isinstance(x, float):
print('%-20s RMS = %8.3f' % (model, x))
else:
print('%-20s' % (model,))
suggested improvement
if not quiet:
if _self.is_sequence(x):
print('%-20s RMS = %8.3f (%d atoms)' % (model, x[0], x[1]))
elif isinstance(x, float):
print('%-20s RMS = %8.3f' % (model, x))
elif _self.is_dict(x):
if 'RMSD' in x:
print('%-20s RMS = %8.3f' % (model, x['RMSD']))
else:
print('%-20s' % (model,))
else:
print('%-20s' % (model,))
I open the pymol, then I revised the plugin in the "pmg/startup" directory, how can I refresh the plugin without closing and reopen the pymol? can you give me some suggestions?
As suggested in #132 , tests would be nice to have, but there's currently no foundation in place in this repository. Perhaps we should start looking into some. I'm creating a quick plugin that I plan on writing tests for but before submitting them, we should probably agree on what those would look like. Couple of points that pop up in my head are:
pytest
(as we're currently trying for pymol-testing
)?pymol-testing
(to cut redundancy if possible)? Using pymol-testing
as a submodule here could be an option to share some of those functions.The PMGApp no longer has an 'initializePlugins' method to bind to in pymol 1.7.
Traceback (most recent call last):
File "/Applications/MacPyMOL.app/pymol/modules/pymol/parser.py", line 260, in parse
exec(layer.com2+"\n",self.pymol_names,self.pymol_names)
File "<string>", line 1, in <module>
File "/Users/blivens/.dotfiles/Pymol-script-repo/pymolplugins/__init__.py", line 22, in <module>
x__initializePlugins = pmg_tk.PMGApp.initializePlugins
AttributeError: class PMGApp has no attribute 'initializePlugins'
(note: plugins/ was renamed to pymolplugins/ to fix #53)
In the PyMol Viewer, every object has'ASHLC', A is shore of 'Action';S is short of 'show';H is short of 'hide';C is short of 'color';
For the molecule object, the color can button color the object with different color.
In my plugin, I create some cgo Objects. But the color button didn't take effect.
Can you give me some suggestions? Thank you.
Hi,
I found tmalign.py not compatible with the 2022/4/12 version of the TM-align source code in C++. Changing line 155 in tmalign.py to:
elif line.lower().startswith(' -------- rotation matrix') or line.lower().startswith('------ the rotation matrix'):
fixed the issue.
Kind regards.
What is the cause of the following error in dssp plugin?
dssp_stride.py", line 113, in <lambda>
command=lambda s=self: DSSPPlugin(s))
File "/home/proteininstitute/.pymol/startup/dssp_stride.py", line 261, in __init__
self.notebook = Pmw.NoteBook(self.dialog.interior())
File "/usr/local/lib/python3.8/dist-packages/Pmw/Pmw_2_0_1/lib/PmwNoteBook.py", line 60, in __init__
Pmw.Color.bordercolors(self, self['hull_background'])
File "/usr/local/lib/python3.8/dist-packages/Pmw/Pmw_2_0_1/lib/PmwColor.py", line 359, in bordercolors
'#%04x%04x%04x' % (lightRGB[0], lightRGB[1], lightRGB[2]),
TypeError: %x format: an integer is required, not float
Optimize plugin gives and takes the data to and from OpenBabel as a PDB file, which for small molecules doesn't work very will due to bonding information not being taken into account well - eg for a nucleotide the output was dearomatized, for a short oligopeptide a tyrosine had been split into a phenylalanine and water molecule and an arginine lost its guanidine as ammonia and a carbodiimide.
This is fixable by changing the input/output file type to MOL:
Line 250 -> mol_string = cmd.get_str('mol',selection)
253 -> obconversion.SetInAndOutFormats('mol', 'mol')
255 -> obconversion.ReadString(mol, mol_string)
256 -> removed
269 -> mol_string = obconversion.WriteString(mol)
273 -> cmd.read_molstr(mol_string, name,state=0,finish=1,discrete=1)
280 -> mol_string = cmd.get_str('mol',selection)
283 -> obconversion.SetInAndOutFormats('mol', 'mol')
285 -> obconversion.ReadString(mol, mol_string)
286 -> removed
320 -> mol_string = obconversion.WriteString(mol)
321 -> cmd.read_molstr(mol_string, name_n,state=0,finish=1,discrete=1)
329 -> mol_string = obconversion.WriteString(mol)
331 -> cmd.read_molstr(mol_string, name,state=0,finish=1,discrete=1)
I am very inexperienced with coding so this may not be formatted particularly clearly, and may not be the optimal way of fixing this, but seems to work for me thus far.
For a Fab PDB file with non-standard numbering, if either the limit_h
or limit_l
residue indicated doesn't exist, the elbow_angle
command fails to print an elbow angle value without a warning or error message.
Ideally the script should check to make sure the indicated residue exists. Currently this is not implemented. However, at the very least, although the module docstring mentions there is no error checking for the limit residues or chain IDs, there should be some kind of error message if the elbow angle cannot be calculated.
Here is a small example of the issue:
reinitialize
fetch 3ghe, async=0
remove all and not (chain H+L and polymer.protein)
elbow_angle 3ghe
## Elbow angle: 194 degrees
alter chain L and resi 107, resi='106A'
elbow_angle 3ghe
## <no output>
Dear developer, I want to mutate all GLN&ASN to LEU of protein files to do some further research, but EVEN THOUGH the python scripts runs well without error, the output file still have all the GLN&ASN left.
import os
from pymol import cmd
source_folder = '/home/lrj/test_dataset'
for pdbid in os.listdir(source_folder):
folder_path = os.path.join(source_folder, pdbid)
if os.path.isdir(folder_path):
for file in os.listdir(folder_path):
if file.endswith('protein.pdb'):
# reinitialize the pymol cmd
cmd.reinitialize()
# load file
protein_file = os.path.join(folder_path, file)
base_name = file.split('.')[0]
cmd.load(protein_file, base_name)
cmd.wizard("mutagenesis")
# define the dict
mut_dict = {"ASN": "LEU", "GLN": "LEU"}
for res in cmd.get_model(base_name).atom:
if res.resn in mut_dict:
res_chain = res.chain
resi = res.resi
cmd.do(f'select res, {base_name} and chain {res_chain} and resi {resi}')
cmd.do(f"cmd.get_wizard().set_mode('{mut_dict[res.resn]}')")
cmd.do('cmd.get_wizard().apply()')
cmd.set_wizard()
object_list = cmd.get_object_list()
target_obj = object_list[-1] # Assuming the target object is the last in the list
# update
cmd.update(target_obj, base_name)
# Save the output
cmd.save(os.path.join(folder_path, f'{pdbid}_mutate0_protein.pdb'), base_name)
cmd.delete(base_name)
AND the command terminal code output is like:
Selector: selection "res" defined with 14 atoms.
PyMOL>cmd.get_wizard().set_mode('LEU')
PyMOL>cmd.get_wizard().apply()
PyMOL>select res, 1aaq_protein and chain B and resi 98
Selector: selection "res" defined with 14 atoms.
PyMOL>cmd.get_wizard().set_mode('LEU')
PyMOL>cmd.get_wizard().apply()
PyMOL>select res, 1aaq_protein and chain B and resi 98
Selector: selection "res" defined with 14 atoms.
PyMOL>cmd.get_wizard().set_mode('LEU')
PyMOL>cmd.get_wizard().apply()
PyMOL>select res, 1aaq_protein and chain B and resi 98
Selector: selection "res" defined with 14 atoms.
PyMOL>cmd.get_wizard().set_mode('LEU')
PyMOL>cmd.get_wizard().apply()
Hi,
I came across an issue of not showing the Vina option in the plugin pop-up (Fig 1) which deviated from Daniel's previous version (Fig 2) Link. Plus, I am using win10.
I would really appreciate it if anyone could help!
Many thanks!
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:
Error: 1
TypeError Exception in Tk callback
Function: <bound method Autodock.load_ligand_file of <pmg_tk.startup.autodock_plugin.Autodock object at 0x0000024DB85D0448>> (type: <class 'method'>)
Args: ()
Traceback (innermost last):
File "C:\Users\Aster\Env\Anaconda3\lib\site-packages\Pmw.py", line 1823, in __call__
return self.func(*args)
File "C:\Users\Aster\Env\Anaconda3\share\pymol\data/startup\autodock_plugin.py", line 2493, in load_ligand_file
self.load_dlg(filename)
File "C:\Users\Aster\Env\Anaconda3\share\pymol\data/startup\autodock_plugin.py", line 2536, in load_dlg
pose_list.sort(lambda a, b: cmp(a.energy, b.energy))
TypeError: sort() takes no positional arguments
It seems that this could be reproduceable on other machines, haven't tested under Python 2...
http://www.pymolwiki.org/index.php/Selection_Algebra
operator distance is ... measured from includes s2 syntax notes
around โค X center never 2
center means one neareast atom in x, not the center of x
for example x=benzene,
iterate every atom in ben ,the get set for every atom,
final combine all the sets.
Hi,
I am hoping you can point me in the right direction. I am reading a PDB as follows:
path = 'TO PATH'
for filename in glob.glob(os.path.join(path, '*.pdb)):
cmd.load(filename) # use the name of your pdb file
stored.residues = []
cmd.iterate('name ca', 'stored.residues.append((resn))')
#print (stored.residues)
Then I want to create a sidechain pseudoatom and save its coordinate in an array along the lines ...
stored_residues_sidechain_PS = []
for i in stored.residues:
cmd.select ('resn %s' % i)
stored_residues_sidechain_PS.append(sidechaincenters [ '(sele)' [2]])
but I am having difficulty with the correct syntax to use for sidechaincenters. Please point me in the right direction.
Thank you
Hi there,
quick question. Is there an api implementation of movie_fade available? cmd.movie_fade(...)
gives me an AttributeError: module 'pymol.cmd' has no attribute 'movie_fade'
Thanks a lot in advance,
mce13
How to fix this issue when running Autodock plugin (Pymol 2.5.0 on macOS 10.13.6)?
Traceback (most recent call last):
File "/Users/xxxxxxxxxxx/.pymol/startup/autodock_plugin.py", line 109, in <lambda>
command=lambda s=self: Autodock(s))
File "/Users/xxxxxxxxxxx/.pymol/startup/autodock_plugin.py", line 590, in __init__
self.notebook = Pmw.NoteBook(self.dialog.interior())
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/Pmw/Pmw_2_0_1/lib/PmwNoteBook.py", line 60, in __init__
Pmw.Color.bordercolors(self, self['hull_background'])
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/Pmw/Pmw_2_0_1/lib/PmwColor.py", line 359, in bordercolors
'#%04x%04x%04x' % (lightRGB[0], lightRGB[1], lightRGB[2]),
TypeError: %x format: an integer is required, not float
Hi,
I downloaded cyspka and tried the 4AKE-A example on the pymol wiki. I got the following error:
Traceback (most recent call last):
File "/Applications/PyMOL.app/Contents/lib/python2.7/site-packages/pymol/parser.py", line 256, in parse
self.result=layer.kw[0](*layer.args, **layer.kw_args)
File "/Users/JW/cheminfo/basechem/chemistry/3D_modeling/conformation_generator/cyspka.py", line 260, in cyspka
if not os.path.exists(Newdir):
UnboundLocalError: local variable 'Newdir' referenced before assignment
I am using PyMOL v2.0.0 that was downloaded from pymol.org.
Thanks,
JW
The show_contacts.py plugin from PR #99 needs to be ported to Python 3.
Porting guide: https://pymolwiki.org/index.php/2to3
Pymol 1.7 includes a 'plugins' module (http://sourceforge.net/p/pymol/code/HEAD/tree/trunk/pymol/modules/pymol/plugins/). This conflicts with the 'plugins' loader package here.
The name should probably be changed to something like 'pymolplugins' (used internally as the package name). Note that this will require users to update their .pymolrc with the correct import statement.
Running the example script included with the cyspka source code results in the following messages for me:
# Hello, PyMOLers. It should take around 1 minute per residue.
# molecule: 4AKE-A , chain: A, residue: 71.300 18, pH: 7.2
Error: Empty Selection
I have been modifying the code to try and determine where the issue is. Print messages inserted before the if NotPopNr == 0:
code will run. However, if any code following if NotPopNr == 0:
is added, then the script will not run at all and I receive a syntax error.
Any help would be much appreciated.
As a drop-in solution replace line 364 with the following four lines (after removing bullets and fixing indent of course, this is just a hack to preserve newlines):
Hi,
I am looking for script or nay module which will convert whatever changes you made to your protein and ligand to make it look pretty, it will convert all these changes all at once to python code, so that it can be applied to another complex. Is there any such script available?
Thank you.
Here a list of plugins needing refactor.
The ones tagged NeedRefactor
are old-style plugins with top-level __init__
function instead of __init_plugin__
, they are using a deprecated mechanism.
Generated with the script from #146.
ccp4_contact.py:32: SyntaxWarning: invalid escape sequence '\S'
conParser = re.compile("(\S*)\s*(\d+)([A-Z])\s*(\w+)")
ccp4_ncont.py:34: SyntaxWarning: invalid escape sequence '\s'
conParser = re.compile("\s*/(\d+)/([a-zA-Z0-9]*)/\s*(\d+).*?/\s*([a-zA-Z0-9]*).*?:")
flatten_obj.py:280: SyntaxWarning: invalid escape sequence '\d'
statere = re.compile("^%s_(.*)_(\d+)$" % metaprefix) # matches split object names
forster_distance_calculator.py:1: SyntaxWarning: invalid escape sequence '\,'
'''
forster_distance_calculator.py:80: SyntaxWarning: invalid escape sequence '\P'
print('Part of LaTeX: C:\Program Files (x86)\MiKTeX 2.9\miktex' + "\\" + "bin")
frame_slider.py:: NeedRefactor
plot_noe.py:59: SyntaxWarning: invalid escape sequence '\s'
rgx_assi = re.compile("\s*[asignASIGN]+\s+.*")
plot_noe.py:60: SyntaxWarning: invalid escape sequence '\s'
rgx_or = re.compile("\s*[orOR]+\s+.*")
plot_noe.py:61: SyntaxWarning: invalid escape sequence '\('
rgx_bracket = re.compile("(\(|\))")
plot_noe.py:62: SyntaxWarning: invalid escape sequence '\w'
rgx_tick = re.compile("(\w)\'")
plot_noe.py:71: SyntaxWarning: invalid escape sequence '\g'
restraint_block.append(rgx_tick.sub("\g<1>^", rgx_bracket.sub(" ", restraint_line)))
plot_noe.py:76: SyntaxWarning: invalid escape sequence '\g'
restraint_block.append(rgx_tick.sub("\g<1>^", rgx_bracket.sub(" ", restraint_line)))
plot_noe.py:81: SyntaxWarning: invalid escape sequence '\g'
restraint_block.append(rgx_tick.sub("\g<1>^", rgx_bracket.sub(" ", restraint_line)))
propka.py:1: SyntaxWarning: invalid escape sequence '\m'
'''
propka.py:225: SyntaxWarning: invalid escape sequence '\R'
assert PDB not in ['NIL'], "You always have to provide PDB path. Example: PDB=.\Results_propka\4ins2011.pdb"
propka.py:520: SyntaxWarning: invalid escape sequence '\R'
Newdir = os.getcwd() + "\Results_propka\\"
transformations.py:33: SyntaxWarning: invalid escape sequence '\*'
"""Homogeneous Transformation Matrices and Quaternions.
transformations.py:886: SyntaxWarning: invalid escape sequence '\*'
"""Return affine transform matrix to register two point sets.
transformations.py:995: SyntaxWarning: invalid escape sequence '\*'
"""Return matrix to transform given 3D point set into second point set.
wfmesh.py:45: SyntaxWarning: invalid escape sequence '\s'
dat = re.split("\s+", line)
plugins/Caver2_1_2.py:548: SyntaxWarning: invalid escape sequence '\C'
commandXYZ = "java %s -jar \"%s\Caver2_1.jar\" \"%s\" %f %f %f %s \"%s\" %d %d %d %s" % (JOPTS, self.pymollocation.getvalue(), input, float(self.xlocvar.get()), float(self.ylocvar.get()), float(self.zlocvar.get()), self.tunnels.getvalue(), outdir, self.varremovewater.get(), 0, self.methodvar.get(), "tun_" + self.whichModelSelect)
plugins/Caver2_1_2.py:: NeedRefactor
plugins/SuperSymPlugin.py:: NeedRefactor
plugins/annocryst.py:: NeedRefactor
plugins/apbsplugin.py:1459: SyntaxWarning: invalid escape sequence '\d'
"""
plugins/apbsplugin.py:1506: SyntaxWarning: invalid escape sequence '\d'
unassigned = re.compile('REMARK 5 *(\d+) \w* in').findall(f.read()) # Text contains PQR output string
plugins/apbsplugin.py:: NeedRefactor
plugins/autodock_plugin.py:: NeedRefactor
plugins/bnitools.py:: NeedRefactor
plugins/castp.py:: NeedRefactor
plugins/colorama.py:: NeedRefactor
plugins/contact_map_visualizer.py:: NeedRefactor
plugins/dehydron.py:: NeedRefactor
plugins/dssp_stride.py:: NeedRefactor
plugins/emovie.py:: NeedRefactor
plugins/lisica.py:: NeedRefactor
plugins/mole.py:: NeedRefactor
plugins/msms.py:: NeedRefactor
plugins/mtsslDockGui.py:: NeedRefactor
plugins/mtsslPlotter.py:: NeedRefactor
plugins/mtsslTrilaterate.py:: NeedRefactor
plugins/mtsslWizard.py:: NeedRefactor
plugins/optimize.py:: NeedRefactor
plugins/pyanm.py:: NeedRefactor
plugins/pytms.py:: NeedRefactor
plugins/rendering_plugin.py:: NeedRefactor
plugins/resicolor_plugin.py:: NeedRefactor
plugins/show_contacts.py:: NeedRefactor
This script collects any cmd.extend
found in these plugins and scraps the plugins commands.
The results were compiled into this HTML file: https://silver-hyacinthe-39.tiiny.site/
@jaredsampson @speleo3 , I tried to send to the mail-list but it seems I'm not allowed.
The autodock plugin sets retain_order to 1 upon loading. This causes some unexpected side effects in later commands.
If the plugin requires retaining the PDB order, it should enable it temporarily for loading and then restore the original value.
I performed acetylation of lysine residue using PyTM plugin. There are certain clashes in my structure after modification. How can I fix them as gromacs or other minimization softwares/ web-servers aren't able to handle acetylated residues. Please suggest a way.
Seems like python 3.10 disallows these types of conversions. We've run into these issues with Qt-based plugins we ship with PyMOL (e.g. Lighting Settings) after updating to 3.10. I haven't tested yet with the scripts here yet though, but I wouldn't be surprised if many of them here started to stop working for the same reason.
Example from another plugin's issue tracker:
vanderkamp/enlighten2-pymol#1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.