[Chimera-users] Using runCommand outputs
Tom Goddard
goddard at sonic.net
Thu Nov 14 10:37:11 PST 2013
Hi Ahir,
Every Chimera command has an equivalent Python function. I just didn't tell you all the places you would have to look to find them. Commands that have a separate dialog (graphical user interface) usually have their own code directory and are not in Midas/__init__.py. So for example the findclash command has the equivalent Python function "detectClash()" in directory
chimera/share/DetectClash
(On Mac the directory is Chimera.app/Contents/Resources/share/DetectClash). So it can be a bit tricky to find the Python. Here's what I do when I can't find the Python code. Each command is registered in Chimera code with the routine addCommand(). So I search for addCommand in all the share directories. Below is a list for Chimera 1.8.
You are right that trying to save reply log output instead of directly running Python functions is not feasible for more complex scripts.
Tom
$ cd Chimera-1.8.app/Contents/Resources/share
$ grep "addCommand(" */*.py
Accelerators/ChimeraExtension.py:addCommand('ac', accel_cmd, None, help = True, changesDisplay = True)
AddAttr/ChimeraExtension.py:addCommand("defattr", cmdAddAttr, help=True, changesDisplay=False)
AddCharge/ChimeraExtension.py:addCommand("addcharge", cmdAddCharge, help=True, changesDisplay=False)
AddH/ChimeraExtension.py:addCommand("addh", cmdAddH, help=True)
Addions/ChimeraExtension.py:addCommand("adions", cmdAddions, help=True)
Animate/ChimeraExtension.py:# addCommand(command, cmdFunc, revFunc=None, help=None, changesDisplay=True)
Animate/ChimeraExtension.py:addCommand('scene',
Animate/ChimeraExtension.py:#addCommand('transition',
Animate/ChimeraExtension.py:#addCommand('animate',
Animate/ChimeraExtension.py:addCommand('kfadd',
Animate/ChimeraExtension.py:addCommand('kfclear',
Animate/ChimeraExtension.py:addCommand('kfdel',
Animate/ChimeraExtension.py:addCommand('kfmove',
Animate/ChimeraExtension.py:addCommand('kfmovie',
Animate/ChimeraExtension.py:addCommand('kfsave',
Animate/ChimeraExtension.py:addCommand('kfshow',
Animate/ChimeraExtension.py:addCommand('kfstatus',
Animate/ChimeraExtension.py:addCommand('kftrans',
Aniso/ChimeraExtension.py:addCommand("aniso", cmdAniso, revFunc=cmdUnaniso, help=True)
BuildStructure/ChimeraExtension.py:addCommand("invert", cmdInvert, help=True)
ChangeChainIDs/ChimeraExtension.py:addCommand("changechains", cmdChangeChains, help=True, changesDisplay=False)
Combine/ChimeraExtension.py:addCommand("combine", cmdCombine, help=True)
CrystalContacts/ChimeraExtension.py:addCommand('crystalcontacts', crystal_contacts_command, help = True)
DetectClash/ChimeraExtension.py:addCommand("findclash", cmdDetectClash, revFunc=cmdUndetectClash, help=True)
ESP/ChimeraExtension.py:addCommand("coulombic", wrapper, help=True)
EnsembleMatch/ChimeraExtension.py:addCommand('tile', tile_cmd, tile_cmd, help = True)
EnsembleMatch/ChimeraExtension.py:addCommand('cluster', cluster_cmd, None, help = True)
FindHBond/ChimeraExtension.py:addCommand("hbonds", cmdHBonds, revFunc=cmdUnHBonds, help=True)
FindHBond/ChimeraExtension.py:addCommand("findhbond", cmdHBonds, revFunc=cmdUnHBonds, help=True)
FitMap/ChimeraExtension.py:mt.addCommand('fitmap', fit_map, unfit_map, help = True)
Fly/ChimeraExtension.py:addCommand('fly', fly_cmd, help = True)
IcosahedralCage/ChimeraExtension.py:Midas.midas_text.addCommand('hkcage', hkcage, help = True)
Ilabel/ChimeraExtension.py:addCommand("2dlabels", doLabel2DCmd, help=True)
Intersurf/ChimeraExtension.py:midas_text.addCommand("intersurf", emo.commandLine)
Lighting/ChimeraExtension.py:addCommand('lighting', lighting, help=True)
ListInfo/ChimeraExtension.py:addCommand("list", emo.command, help=True, changesDisplay=False)
ListInfo/ChimeraExtension.py:addCommand("listmodels", emo.command, help=True, changesDisplay=False)
ListInfo/ChimeraExtension.py:addCommand("listchains", emo.command, help=True, changesDisplay=False)
ListInfo/ChimeraExtension.py:addCommand("listresidues", emo.command, help=True, changesDisplay=False)
ListInfo/ChimeraExtension.py:addCommand("listatoms", emo.command, help=True, changesDisplay=False)
ListInfo/ChimeraExtension.py:addCommand("listselection", emo.command, help=True, changesDisplay=False)
ListInfo/ChimeraExtension.py:addCommand("listphysicalchains", emo.command, help=True, changesDisplay=False)
ListInfo/ChimeraExtension.py:addCommand("listen", emo.command, help=True, changesDisplay=False)
ListInfo/ChimeraExtension.py:addCommand("sequence", emo.command, help=True, changesDisplay=False)
MMMD/ChimeraExtension.py:addCommand("minimize", emo.cmdMMMD, help=True)
MMMD/ChimeraExtension.py:#addCommand("dynamics", emo.cmdMMMD, help=True)
Mask/ChimeraExtension.py:Midas.midas_text.addCommand('mask', mask_cmd, help = True)
MatchMaker/ChimeraExtension.py:addCommand("mmaker", cmdMatchMaker, help=True)
MatchMaker/ChimeraExtension.py:addCommand("matchmaker", cmdMatchMaker, help=True)
Measure/ChimeraExtension.py:addCommand('measure', measure_cmd, help = True)
MeshToMolecule/ChimeraExtension.py:addCommand('meshmol', mesh_to_molecule, help = True)
Midas/midas_text.py:def addCommand(command, cmdFunc, revFunc=None, help=None, changesDisplay=True):
ModelClip/ChimeraExtension.py:addCommand('mclip', mclip_command, unclip_command, help = True)
MoleculeCopy/ChimeraExtension.py:addCommand('mcopy', mcopy_cmd, help = True)
MoleculeMap/ChimeraExtension.py:addCommand('molmap', molmap_cmd, help = True)
Morph/ChimeraExtension.py:addCommand("morph", emo.cmdMorph, help=True)
Movie/ChimeraExtension.py:addCommand('coordset', coordset, help = True)
MovieRecorder/ChimeraExtension.py:addCommand("movie", doMovieCmd, help=True, changesDisplay=False)
MultiscaleColor/ChimeraExtension.py:Midas.midas_text.addCommand('msc', msc_command, msc_undo_command, help = True)
NucleicAcids/ChimeraExtension.py:addCommand('nucleotides', nucleotides, revFunc=unnucleotides, help=True)
Play/ChimeraExtension.py:addCommand('play', play, reverse_play, help = ('play.html', 'Play'))
RNALayout/ChimeraExtension.py:addCommand('rna', rna_cmd, help = True)
Ramachandran/ChimeraExtension.py:addCommand("ramachandran", emo.cmdLine, help=True)
ResRenumber/ChimeraExtension.py:addCommand("resrenumber", cmdResRenumber, help=True, changesDisplay=False)
Rotamers/ChimeraExtension.py:addCommand("swapaa", cmdRotamers, help=True)
Segger/ChimeraExtension.py:Midas.midas_text.addCommand('segment', segment, None, help = True)
Shape/ChimeraExtension.py:addCommand('shape', shape_cmd, help = True)
Solvate/ChimeraExtension.py:addCommand("solvate", cmdSolvate, help=True)
SplitMolecule/ChimeraExtension.py:Midas.midas_text.addCommand('split', split_molecules, help = True, changesDisplay=False)
StructureDiagram/ChimeraExtension.py:addCommand("struct2d", emo.cmdLine, help=True, changesDisplay=False)
Surface/ChimeraExtension.py:addCommand('sop', sop_cmd, unsop_cmd, help = True)
SurfaceColor/ChimeraExtension.py:addCommand('scolor', scolor_cmd, scolor_cmd, help = True)
SurfaceColor/ChimeraExtension.py:addCommand('scolour', scolor_cmd, scolor_cmd, help = True)
SurfaceZone/ChimeraExtension.py:Midas.midas_text.addCommand('bondzone', bzone, no_bzone, help = True, changesDisplay=False)
SymmetryCopies/ChimeraExtension.py:Midas.midas_text.addCommand('sym', symmetry_copies, undo_symmetry_copies,
Topography/ChimeraExtension.py:addCommand('topography', topo, help = True)
ViewDock/ChimeraExtension.py:addCommand("viewdock", emo.cmdViewdock, help=True)
VolumeFilter/ChimeraExtension.py:addCommand('vop', vop_cmd, help = True)
VolumeSeries/ChimeraExtension.py:addCommand('vseries', vseries_cmd, help = True)
VolumeViewer/ChimeraExtension.py:addCommand('volume', volume_cmd, help = True)
Zone/ChimeraExtension.py:Midas.midas_text.addCommand('zonesel', zone_cmd, help = True)
apbs/ChimeraExtension.py:addCommand("apbs", emo.cmdLine, help=True)
blastpdb/ChimeraExtension.py:addCommand("blast", emo.cmdLine, help=True, changesDisplay=False)
blastpdb/ChimeraExtension.py:addCommand("psiblast", emo.cmdLine, help=True, changesDisplay=False)
chimera/writeSel.py:addCommand("writesel", midasCmd, help=True)
pdb2pqr/ChimeraExtension.py:addCommand("pdb2pqr", emo.cmdLine, help=True)
vina/ChimeraExtension.py:addCommand("vina", vinaEmo.cmdLine, help=True)
$
On Nov 14, 2013, at 1:21 AM, wrote:
> Thanks for the prompt reply Tom, that explains things! I took a look at the init.py file, and I can see that it's not as straight forward and as you said, some runcommand functionality is not represented by midas commands too right? For example, I cant find findclash for example. I am not beyond using runcommand ("findclash" blah blah log/savefile True) etc, but what is the easiest way to feed the output of runcommand that does not have a savefile option , i.e if the ouput goes not to the reply log but rather to IDLE, is there any way of getting this data back to a file, without manually cut and pasting it into a file and saving it? Because the saveReplyLog from tkgui does not save anything if I am running IDLE, because the output goes to IDLE (and I am using IDLE during writing/testing the script). If there is a way of doing this, then its a suitabe workaround for me!
>
> Thanks again
> Ahir
>
> One thing,
>
> Quoting Tom Goddard
>
>> Hi Ahir,
>>
>> Unfortunately runCommand() does not return any Python objects resulting from the command -- would be convenient if it worked that way. If you want return values from a command you need to call the Python function that does that command. Most of those are in file
>>
>> chimera/share/Midas/__init__.py
>>
>> with the function name matching the command name, e.g. rmsd() for the "rmsd" command, or match() for the "match" command. So open that file in a text editor and search for the command you want. We unfortunately don't have documentation on the Python functions so this can be troublesome and I'm sure is why you prefer runCommand(). We will provide documentation for all the Python functions in our next generation Chimera that we are working on now.
>>
>> Tom
>>
>>
>> On Nov 13, 2013, at 8:40 AM, wrote:
>>
>>> Hello all, I am getting confused by the runCommand() functionality when I am trying to run scripts. When I run my python script through IDLE(From Tools-General), the ouput of runcommand commands like rmsd etc are given the IDLE. I want to store the output from runcommand into a variable dynamically. I dont want to save from the ReplyLog (by running program without IDLE) or output to file, is there something in python itself that I am not understanding and hence, not using, or is it not possible to store the output of runcommand into a variable/list etc, as it is possible for the midas.rmsd function for example. I only ask because I prefer to use the command line functionality over the midas command. If it is only possible with the direct midas, how do I find out the equivalent command of the runcommand for the midas python formatting?
>>>
>>> Thank you
>>> Sorry if my question is a bit confusing!
>>>
>>> Ahir
>>>
>>> ----------------------------------------------------------------
>>> This message was sent using IMP, the Internet Messaging Program.
>>>
>>> _______________________________________________
>>> Chimera-users mailing list
>>> Chimera-users at cgl.ucsf.edu
>>> http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
>>>
>>
>>
>
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
More information about the Chimera-users
mailing list