[Chimera-users] Script parameters
Thomas Goddard
goddard at cgl.ucsf.edu
Mon Mar 15 16:18:38 PDT 2010
Hi Will,
Your method of starting Chimera
chimera volume.mrc --script colourMaps.py -- -a red
looks reasonable but doesn't work. Chimera insists that the data files
come after the options (like --script). But the --script <file> option
treats all subsequent arguments as script arguments (not data files)
unless they start with "--". The bottom line is Chimera wants the data
file at the end but that doesn't open the data file if you use the
--script option. This is pretty messed up and we will do something to
fix it. In the meantime you can use
chimera --script colourMaps.py volume.mrc -a red
This won't open volume.mrc, instead volume.mrc will be the first
argument to your script and your script will have to open it with
from chimera import openModels
openModels.open(sys.argv[1])
Thanks for pointing out this problem. We will discuss it at our weekly
Chimera meeting and come up with a solution that lets you open data
files and a script on the command-line.
Tom
> Hi Tom,
>
> Thanks for that. Works great!
>
> Now I have another question:
>
> I'm trying to pass colors to the script in the arguments, but not having
> much luck.
> In the script itself, do you recover the arguments in the normal way:
> Like this?
>
> import getopt, sys, os
> try:
> opts, args = getopt.getopt(sys.argv[1:] ,"a:", [])
> except getopt.GetoptError, err:
> pass
> returnMap = {}
> print opts
> for opt, arg in opts:
> if opt == "-a":
> returnMap["a"] = arg
> print returnMap
>
>
> If I run this script directly from the command line like this:
> python colourMaps.py -a red
>
> I get the expected print out
> [('-a', 'red')]
> {'a': 'red'}
>
> but if I try to call this script at the same time as opening maps from
> the command line, I don't get anything:
> chimera volume.mrc --script colourMaps.py -- -a red
>
> Reply log:
> []
> {}
>
> I'm also getting a UI dialog
> "Please designate file type for --script"
> which I have to 'cancel' every time I open chimera with this command.
> Is there any way I can avoid this?
>
> Many thanks,
>
>
> Will.
>
More information about the Chimera-users
mailing list