[Chimera-users] Script parameters
Will Moore
will at lifesci.dundee.ac.uk
Mon Mar 15 15:33:37 PDT 2010
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.
On 15 Mar 2010, at 17:25, Thomas Goddard wrote:
> Hi Will,
>
> Here's a Python script that will change a volume color:
>
> from chimera import openModels
> from VolumeViewer import Volume
> for v in openModels.list(modelTypes=[Volume]):
> v.set_parameters(surface_colors = [(1.0, 0.0, 0.0, 1.0)])
> v.show()
>
> You can do the same thing more easily with a Chimera command and you
> can put such commands in a file (suffix .cmd) for Chimera to execute
> (by opening the file).
>
> volume # color plum
>
> This colors all volume models as plum color. If you wanted a
> specific model you would use for example #2 instead of #. The
> notation # means all models.
>
> You could also run this Chimera command from Python.
>
> from chimera import runCommand
> runCommand("volume # color plum")
>
>
> Tom
>
>
>
>> Hi,
>>
>> I'm trying to write a script to change the surface colors of
>> volumes in
>> Chimera:
>>
>> This is what I have so far.
>>
>> for m in chimera.openModels.list():
>> print m.surface_colors
>> m.surface_colors = [(1.0, 0.0, 0.0, 1.0)]
>> print m.surface_colors
>>
>> This seems to alter the surface colors, but has no effect on what the
>> maps look like in the UI.
>> Do I need to call something else for the UI to be updated, or am I
>> using
>> the wrong approach entirely?
>>
>> Also, I would like to only select the volumes in the first line but I
>> don't know what modelTypes this is:
>> for m in chimera.openModels.list(modelTypes=[chimera.Molecule]):
>>
>> Many thanks,
>>
>> Will.
>>
>>
>>
>> William Moore
>> Wellcome Trust Centre for Gene Regulation & Expression
>> College of Life Sciences
>> MSI/WTB/JBC Complex
>> University of Dundee
>> Dow Street
>> Dundee DD1 5EH
>> United Kingdom
>>
>> Phone 01382 386364
>> http://openmicroscopy.org.uk
>>
William Moore
Wellcome Trust Centre for Gene Regulation & Expression
College of Life Sciences
MSI/WTB/JBC Complex
University of Dundee
Dow Street
Dundee DD1 5EH
United Kingdom
Phone 01382 386364
http://openmicroscopy.org.uk
More information about the Chimera-users
mailing list