
Hi, I am just trying to get started coding some plugins to Chimera, by following the Programmer's Guide 1.3. I have limited programming experience, and the points below were where I got stuck... Not sure if the guide is generally aimed at those with more or less developer skills? Starting with the examples (writeMol2.py) it isn't clear that all these commands should be typed in the IDLE window. I see that it is mentioned previously in the text, but it would be helpful to make clear that this is not in the command line or python prompt. When you've downloaded 4fun.pdb and saved it somewhere, does it matter where you save it, and how should you specify this in commands like opened = chimera.openModels.open('4fun.pdb') E.g. this would have made it more clear that you don't just put the file in a particular place that Chimera knows were to look: opened = chimera.openModels.open('Users/username/Downloads/4fun.pdb') Actually, this point was more relevant to the command: execfile("backbone.py") which I was working on earlier. I was trying to save backbone.py in one of the Chimera.app/Contents/Resources folders, and hoping that Chimera would find it with the above command: When really the command should be more like: execfile("Users/username/Desktop/backbone.py") Running chimera from the command line: A note that it is necessary to add the Chimera bin to the PATH variable would have been handy, especially for novice developers. export PATH=$PATH:/Applications/Chimera.app/Contents/Resources/bin/ ToolbarButton.py I got errors when running this script unless I put the import statements in the mainchain function like this import os import chimera def mainchain(): import re import chimera MAINCHAIN = re.compile("^(N|CA|C)$", re.I) for m in chimera.openModels.list(modelTypes=[chimera.Molecule]): for a in m.atoms: a.display = MAINCHAIN.match(a.name) != None chimera.tkgui.app.toolbar.add('ToolbarButton.tiff', mainchain, 'Show Main Chain', None) Otherwise I got errors like: Traceback (most recent call last): File "/Applications/Chimera.app/Contents/Resources/share/ __main__.py", line 65, in <module> value = chimeraInit.init(sys.argv) File "/Applications/Chimera.app/Contents/Resources/share/ chimeraInit.py", line 434, in init tkgui.eventLoop() File "/Applications/Chimera.app/Contents/Resources/share/chimera/ tkgui.py", line 2885, in eventLoop app.mainloop() File "/Applications/Chimera.app/Contents/Frameworks/ Python.framework/Versions/2.5/lib/python2.5/lib-tk/Tkinter.py", line 1023, in mainloop self.tk.mainloop(n) File "/Applications/Chimera.app/Contents/Frameworks/ Python.framework/Versions/2.5/lib/python2.5/site-packages/Pmw/Pmw_1_3/ lib/PmwBase.py", line 1747, in __call__ return apply(self.func, args) File "/Applications/Chimera.app/Contents/Resources/share/chimera/ toolbar.py", line 191, in <lambda> command=lambda func=callback: _guard(func)) File "/Applications/Chimera.app/Contents/Resources/share/chimera/ toolbar.py", line 28, in _guard func() File "ToolbarButton.py", line 8, in mainchain MAINCHAIN = re.compile("^(N|CA|C)$", re.I) NameError: global name 're' is not defined Error in toolbar callback: NameError: global name 're' is not defined (see reply log for Python traceback info) This is just my feedback, which I hope is useful Cheers, Will.

Hi Will, Thanks for the useful suggestions on the Chimera programming examples. The Chimera programming documentation has not had much attention. Your points are good. 1. Note in programming examples whether you are intended to cut and paste code into the IDLE window or simply load a script. I don't know what was intended. 2. Use full paths to files, or say that Chimera must be started in the directory containing the needed files, or explain how to use Chimera "cd" command to change to directory containing needed files. 3. Say how to run Chimera from a terminal on Mac OS. Do the examples say to run Chimera from a command-line? Would be useful for issue 2 above. What will be done on Microsoft Windows? 4. The ToolbarButton.py doesn't work unless the "import re" and "import chimera" are in the function body. This is because Chimera deletes all globals after loading a file. This has often been a headache for me and Chimera should not delete globals. I've added these improvements to our Chimera requests list http://plato.cgl.ucsf.edu/trac/chimera/wiki/requests Thanks for spending the time to tell us these problems. Tom -------- Original Message -------- Subject: [Chimera-users] Programmer's Guide feedback.... From: Will Moore To: chimera-users Date: 12/14/09 8:36 AM
Hi,
I am just trying to get started coding some plugins to Chimera, by following the Programmer's Guide 1.3. I have limited programming experience, and the points below were where I got stuck... Not sure if the guide is generally aimed at those with more or less developer skills?
Starting with the examples (writeMol2.py) it isn't clear that all these commands should be typed in the IDLE window. I see that it is mentioned previously in the text, but it would be helpful to make clear that this is not in the command line or python prompt.
When you've downloaded 4fun.pdb and saved it somewhere, does it matter where you save it, and how should you specify this in commands like opened = chimera.openModels.open('4fun.pdb')
E.g. this would have made it more clear that you don't just put the file in a particular place that Chimera knows were to look: opened = chimera.openModels.open('Users/username/Downloads/4fun.pdb')
Actually, this point was more relevant to the command: execfile("backbone.py")
which I was working on earlier. I was trying to save backbone.py in one of the Chimera.app/Contents/Resources folders, and hoping that Chimera would find it with the above command: When really the command should be more like: execfile("Users/username/Desktop/backbone.py")
Running chimera from the command line: A note that it is necessary to add the Chimera bin to the PATH variable would have been handy, especially for novice developers. export PATH=$PATH:/Applications/Chimera.app/Contents/Resources/bin/
ToolbarButton.py I got errors when running this script unless I put the import statements in the mainchain function like this
import os import chimera
def mainchain(): import re import chimera MAINCHAIN = re.compile("^(N|CA|C)$", re.I) for m in chimera.openModels.list(modelTypes=[chimera.Molecule]): for a in m.atoms: a.display = MAINCHAIN.match(a.name) != None chimera.tkgui.app.toolbar.add('ToolbarButton.tiff', mainchain, 'Show Main Chain', None)
Otherwise I got errors like:
Traceback (most recent call last): File "/Applications/Chimera.app/Contents/Resources/share/__main__.py", line 65, in <module> value = chimeraInit.init(sys.argv) File "/Applications/Chimera.app/Contents/Resources/share/chimeraInit.py", line 434, in init tkgui.eventLoop() File "/Applications/Chimera.app/Contents/Resources/share/chimera/tkgui.py", line 2885, in eventLoop app.mainloop() File "/Applications/Chimera.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk/Tkinter.py", line 1023, in mainloop self.tk.mainloop(n) File "/Applications/Chimera.app/Contents/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/Pmw/Pmw_1_3/lib/PmwBase.py", line 1747, in __call__ return apply(self.func, args) File "/Applications/Chimera.app/Contents/Resources/share/chimera/toolbar.py", line 191, in <lambda> command=lambda func=callback: _guard(func)) File "/Applications/Chimera.app/Contents/Resources/share/chimera/toolbar.py", line 28, in _guard func() File "ToolbarButton.py", line 8, in mainchain MAINCHAIN = re.compile("^(N|CA|C)$", re.I) NameError: global name 're' is not defined Error in toolbar callback: NameError: global name 're' is not defined (see reply log for Python traceback info)
This is just my feedback, which I hope is useful
Cheers,
Will.
participants (2)
-
Tom Goddard
-
Will Moore