[Chimera-users] BILD object question
Eric Pettersen
pett at cgl.ucsf.edu
Fri Mar 21 14:47:04 PDT 2008
Hi Jeff,
The Axis class in share/StructMeasure/Axes.py does this since it
builds its axes depictions using BILD objects. Basically, it uses a
StringIO object to emulate a file that it can then hand off to
chimera.openModels.open(). Here is the pertinent code:
from StringIO import StringIO
if isinstance(color, basestring):
colorPart = ".color " + color
else:
if hasattr(color, "rgba"):
rgb = color.rgba()[:3]
else:
rgb = color[:3]
colorPart = ".color %g %g %g" % tuple(rgb)
end1 = center + vec * ext1
end2 = center + vec * ext2
bild = StringIO("%s\n.cylinder %g %g %g %g %g %g %g\n"
% (colorPart, end1[0], end1[1], end1
[2],
end2[0], end2[1], end2[2], radius))
self.model = chimera.openModels.open(bild, type="Bild",
sameAs=sameAs, hidden=True,
identifyAs=name)[0]
# allow balloon help to give informative string...
self.model.oslIdent = lambda *args: self.name
--Eric
On Mar 20, 2008, at 12:59 PM, William Jeffrey Triffo wrote:
> hello,
>
> I have been writing simple .bild files for BILD objects (arrows,
> spheres) that I then load into Chimera.
>
> what would the commands be in a python script to generate a BILD model
> within the current session, so that I don't have to keep hand-writing
> and re-loading the .bild file (the contents of the .bild file are
> often
> outputted coordinates from such a script, that I then copy into a text
> file and load)?
>
> thanks,
>
> -Jeff
> _______________________________________________
> Chimera-users mailing list
> Chimera-users at cgl.ucsf.edu
> http://www.cgl.ucsf.edu/mailman/listinfo/chimera-users
More information about the Chimera-users
mailing list