
Hi I do like to color some molecules/atoms I figured out, that I create a color like this:
c=chimera.Color() c=(1,0,0,1)
But when I apply this to all the atoms of a molecule, I end up with the following error-message:
for a in m.atoms: a.color=c
Traceback (most recent call last): File "<pyshell#66>", line 1, in ? for a in m.atoms: RuntimeError: __wrappy__ is missing
I suppose, that colors like "red"are predefined somewhere, where? Are the different color-levels modell/molecule/atom are just fancy stuff for the interactive user? - I colored a molecule first (interactive) "byatom" and then tried to alter the coloring by hand:
m.color=c
it did not work, I had to alter the color atomwise... is color-byatom a function? How can I call it? Is there a way to "switch on"a history function in the buildin IDLE? Copy and paste do also not work within the IDLE. I allways have to copy and paste via an editor...

On Friday, September 26, 2003, at 02:41 AM, Lars Kunert wrote:
Hi I do like to color some molecules/atoms
I figured out, that I create a color like this:
c=chimera.Color() c=(1,0,0,1)
Does the code above have a typo in it? The first line assigns 'c' to point at a Color instance, then the second line has 'c' point to a four-tuple (effectively discarding the Color instance). Perhaps you meant the second line to be 'c.rgba = (1,0,0,1)'? Regardless of the 'c' assignment problem, the more basic problem is that Color is a base class (for MaterialColor and TextureColor) that isn't supposed to be used directly like this. For the most part you want to use MaterialColors when assigning colors in Chimera. To get the color you wanted above, there are two methods: from chimera.colorTable import getColorByName c = getColorByName("red") The getColorByName() function returns a MaterialColor instance. You can use any of the color names in the Actions...Color menu with getColorByName (e.g. "dodger blue"). If you need a shade that isn't one of the built-in color names, you would have to do something similar to what you were trying to do earlier: c = chimera.MaterialColor(1, 0, 0, None) # 'None' is the "material", i.e. use the default material
But when I apply this to all the atoms of a molecule, I end up with the following error-message:
for a in m.atoms: a.color=c
Traceback (most recent call last): File "<pyshell#66>", line 1, in ? for a in m.atoms: RuntimeError: __wrappy__ is missing
I don't get this error using the code you supplied. In both the case where 'c' is a four-tuple and the case where it's a Color instance, I get: TypeError: argument 1 should be a const Color* In your code, is 'm' a Molecule instance created by chimera.openModels.open(), or is it something else?
I suppose, that colors like "red"are predefined somewhere, where?
Yes, in the chimera.colorTable module, as in the example code above.
Are the different color-levels modell/molecule/atom are just fancy stuff for the interactive user? - I colored a molecule first (interactive) "byatom" and then tried to alter the coloring by hand:
m.color=c
it did not work, I had to alter the color atomwise... is color-byatom a function? How can I call it?
Coloring "by atom" assigns colors to individual atoms, which overrides colors assigned at the model level, which is why your color assignment to the molecule had no apparent effect. The is explained in detail in a new programmer's example (i.e. it's not in the 1700 release) called "Chimera's Object Model" which explains not only the color hierarchy (in the section "Display Properties") but the whole basic layout of Chimera objects. To access this example you need to go to http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/Examples/ index.html (it's the first example). There are two functions to assist in coloring by element type. They are both in the chimera.actions module. The first is colorByElement(), which colors atoms in the current selection, or everything if nothing is selected. By default it sets the "color" attribute (the atom's color). You can supply the keyword 'attr="surfaceColor"' to make it color surfaces instead, or 'attr="labelColor"' to make it color labels. Perhaps more useful is the colorAtomByElement(a) function which takes an atom as argument. It takes the same 'attr' keyword that colorByElement() does. In the next release (in about two weeks), it will instead take an 'attrs' keyword for a list of attributes to set.
Is there a way to "switch on"a history function in the buildin IDLE? Copy and paste do also not work within the IDLE. I allways have to copy and paste via an editor...
In IDLE, you can insert an old line of code by clicking the mouse to put the insertion point in that line of code and then hitting Return. The code will appear at the bottom and you can edit it and so forth. Eric Pettersen UCSF Computer Graphics Lab pett@cgl.ucsf.edu http://www.cgl.ucsf.edu
participants (2)
-
Eric Pettersen
-
Lars Kunert