
Hi everyone, I would like to add non-molecular graphics objects to my molecules for illustration. The obvious way to do so is to load a BILD or VRML file, but since I create these objects in Python scripts, I'd prefer to a direct Python interface rather than write a temporary file and load it. Is there a reasonably stable interface for doing this? Thanks in advance, Konrad. -- --------------------------------------------------------------------- Konrad Hinsen Centre de Biophysique Moléculaire, CNRS Orléans Synchrotron Soleil - Division Expériences Saint Aubin - BP 48 91192 Gif sur Yvette Cedex, France Tel. +33-1 69 35 97 15 E-Mail: research AT khinsen DOT fastmail DOT net ---------------------------------------------------------------------

Hi Konrad, You can use the Chimera BILD format without creating a temporary file by creating a string containing the commands, then use StringIO to make a file object from that string and open it. For example, from StringIO import StringIO bild = StringIO(".cylinder %g %g %g %g %g %g %g\n" % (end1[0], end1[1], end1[2], end2[0], end2[1], end2[2], radius)) from chimera import openModels model = openModels.open(bild, type="Bild", identifyAs='My annotations', sameAs = mol) The identifyAs argument assigns the name to the new model that will be shown in the Model Panel dialog. The sameAs argument says that the new model should be aligned with the specified model (same positioning transform). I stole this example from the Chimera Axes/Centroids/Planes code, found in the Chimera distribution in chimera/share/StructMeasure/Axes.py The BILD format produces a VRML model in Chimera and VRML models are horribly inflexible. For instance you cannot change the color of an object in a VRML model without destroying the model and building a new one. Basically the VRML is immutable after it is created. To avoid that limitation I have sometimes resorted to using (some say abusing) the Chimera Molecule object for showing annotations. The Chimera Volume Tracer tool lets you place spherical markers and connect them by cylindrical links, and you can move, delete, recolor, resize, add text labels ... the markers. This is implemented as a Molecule in Chimera, the relevant code is chimera/share/VolumePath/markerset.py A third approach to showing annotations that are geometric shapes is to use the Chimera "shape" command. http://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/shape.html This can make spheres, cylinders, tubular paths, and a few other shapes -- not many though. The shapes can be created with the Chimera command or via Python calls to the Shape module chimera/share/Shape None of the annotation display techniques combine flexibility with ease of use. I suggest using BILD if possible. Tom
Hi everyone,
I would like to add non-molecular graphics objects to my molecules for illustration. The obvious way to do so is to load a BILD or VRML file, but since I create these objects in Python scripts, I'd prefer to a direct Python interface rather than write a temporary file and load it. Is there a reasonably stable interface for doing this?
Thanks in advance, Konrad. -- --------------------------------------------------------------------- Konrad Hinsen Centre de Biophysique Moléculaire, CNRS Orléans Synchrotron Soleil - Division Expériences Saint Aubin - BP 48 91192 Gif sur Yvette Cedex, France Tel. +33-1 69 35 97 15 E-Mail: research AT khinsen DOT fastmail DOT net ---------------------------------------------------------------------

On 7 Jan 2011, at 19:12, Tom Goddard wrote:
You can use the Chimera BILD format without creating a temporary file by creating a string containing the commands, then use StringIO to make a file object from that string and open it. For example,
from StringIO import StringIO bild = StringIO(".cylinder %g %g %g %g %g %g %g\n" % (end1[0], end1[1], end1[2], end2[0], end2[1], end2[2], radius)) from chimera import openModels model = openModels.open(bild, type="Bild", identifyAs='My annotations', sameAs = mol)
That's already a lot better than my temporary file solution.
The identifyAs argument assigns the name to the new model that will be shown in the Model Panel dialog. The sameAs argument says that the new model should be aligned with the specified model (same positioning transform).
And those options make it even better.
To avoid that limitation I have sometimes resorted to using (some say abusing) the Chimera Molecule object for showing annotations. The Chimera Volume Tracer tool lets you place spherical markers and connect them by cylindrical links,
That's what I have been doing until now, but I don't see how I can get arrows through Molecule objects.
None of the annotation display techniques combine flexibility with ease of use. I suggest using BILD if possible.
Sounds reasonable. Thanks for your explanations! Konrad. -- --------------------------------------------------------------------- Konrad Hinsen Centre de Biophysique Moléculaire, CNRS Orléans Synchrotron Soleil - Division Expériences Saint Aubin - BP 48 91192 Gif sur Yvette Cedex, France Tel. +33-1 69 35 97 15 E-Mail: research at khinsen dot fastmail dot net ---------------------------------------------------------------------

On Jan 7, 2011, at 10:12 AM, Tom Goddard wrote:
The BILD format produces a VRML model in Chimera and VRML models are horribly inflexible. For instance you cannot change the color of an object in a VRML model without destroying the model and building a new one. Basically the VRML is immutable after it is created.
This is not 100% true anymore. If your BILD object doesn't have any ".color" directives in it, then the resulting object will be shown using the model-level color attribute, which can be changed in all the normal ways you can change model-level colors. It may be true that parts of the model created before the first ".color" directive will use the model-level color (I'd have to find/read code I didn't write to verify that -- ugh!). --Eric Eric Pettersen UCSF Computer Graphics Lab http://www.cgl.ucsf.edu

On 7 Jan 2011, at 19:12, Tom Goddard wrote:
You can use the Chimera BILD format without creating a temporary file by creating a string containing the commands, then use StringIO to make a file object from that string and open it. For example,
from StringIO import StringIO bild = StringIO(".cylinder %g %g %g %g %g %g %g\n" % (end1[0], end1[1], end1[2], end2[0], end2[1], end2[2], radius)) from chimera import openModels model = openModels.open(bild, type="Bild", identifyAs='My annotations', sameAs = mol)
The identifyAs argument assigns the name to the new model that will be shown in the Model Panel dialog. The sameAs argument says that the new model should be aligned with the specified model (same positioning transform).
This works perfectly well, except for one point: a session containing such models cannot be saved to a session file: Traceback (most recent call last): File "/Applications/Chimera.app/Contents/Resources/lib/python2.7/ 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/ baseDialog.py", line 342, in command getattr(s, buttonFuncName(txt))() File "/Applications/Chimera.app/Contents/Resources/share/OpenSave/ __init__.py", line 237, in Save getattr(self, self.keepEquiv())() File "/Applications/Chimera.app/Contents/Resources/share/chimera/ baseDialog.py", line 560, in OK self.Apply() File "/Applications/Chimera.app/Contents/Resources/share/OpenSave/ __init__.py", line 169, in Apply self.command(1, self) File "/Applications/Chimera.app/Contents/Resources/share/ SimpleSession/gui.py", line 24, in _saveCB saveSession(paths[0]) File "/Applications/Chimera.app/Contents/Resources/share/ SimpleSession/save.py", line 151, in saveSession source = v.openedAs[0] AttributeError: '_vrml.VRMLModel' object has no attribute 'openedAs' Should this be considered a bug or the fair punishment for using undocumented features? Konrad. -- --------------------------------------------------------------------- Konrad Hinsen Centre de Biophysique Moléculaire, CNRS Orléans Synchrotron Soleil - Division Expériences Saint Aubin - BP 48 91192 Gif sur Yvette Cedex, France Tel. +33-1 69 35 97 15 E-Mail: research at khinsen dot fastmail dot net ---------------------------------------------------------------------

Hi Konrad, This is certainly a bug and we'll fix it today. The fix will be in tonight's Chimera daily builds (compiled 9 pm - midnight Pacific time). Thanks for reporting it. Tom
This works perfectly well, except for one point: a session containing such models cannot be saved to a session file:
Traceback (most recent call last): File "/Applications/Chimera.app/Contents/Resources/lib/python2.7/ 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/ baseDialog.py", line 342, in command getattr(s, buttonFuncName(txt))() File "/Applications/Chimera.app/Contents/Resources/share/OpenSave/ __init__.py", line 237, in Save getattr(self, self.keepEquiv())() File "/Applications/Chimera.app/Contents/Resources/share/chimera/ baseDialog.py", line 560, in OK self.Apply() File "/Applications/Chimera.app/Contents/Resources/share/OpenSave/ __init__.py", line 169, in Apply self.command(1, self) File "/Applications/Chimera.app/Contents/Resources/share/ SimpleSession/gui.py", line 24, in _saveCB saveSession(paths[0]) File "/Applications/Chimera.app/Contents/Resources/share/ SimpleSession/save.py", line 151, in saveSession source = v.openedAs[0] AttributeError: '_vrml.VRMLModel' object has no attribute 'openedAs'
Should this be considered a bug or the fair punishment for using undocumented features?
Konrad. -- --------------------------------------------------------------------- Konrad Hinsen Centre de Biophysique Moléculaire, CNRS Orléans Synchrotron Soleil - Division Expériences Saint Aubin - BP 48 91192 Gif sur Yvette Cedex, France Tel. +33-1 69 35 97 15 E-Mail: research at khinsen dot fastmail dot net ---------------------------------------------------------------------
On 7 Jan 2011, at 19:12, Tom Goddard wrote:
You can use the Chimera BILD format without creating a temporary file by creating a string containing the commands, then use StringIO to make a file object from that string and open it. For example,
from StringIO import StringIO bild = StringIO(".cylinder %g %g %g %g %g %g %g\n" % (end1[0], end1[1], end1[2], end2[0], end2[1], end2[2], radius)) from chimera import openModels model = openModels.open(bild, type="Bild", identifyAs='My annotations', sameAs = mol)
The identifyAs argument assigns the name to the new model that will be shown in the Model Panel dialog. The sameAs argument says that the new model should be aligned with the specified model (same positioning transform).
participants (3)
-
Eric Pettersen
-
Konrad Hinsen
-
Tom Goddard