Related to PDB embedded objects, I'm wondering if there would be much interest 
in my releasing an implementation of a language designed to make fairly 
elaborate illustrations in PyMOL. The reason I ask is because it would take 
some time to document and distribute, but I would do it if the demand was 
there. The implementation is written and battle-tested in my own projects, but 
undocumented.

At this moment, I call the language CGObjects. Here are a couple of examples of 
what it can do:

http://www.jamesstroud.com/pictures/site-pictures/cgobjects-example/image
http://www.jamesstroud.com/site-multimedia/site-mp4-movies/example-mp4-movie

(The movie is just a bunch of still images created using the library.)

CGObjects is a hierarchical and purely declarative language that is based on 
yaml structure. For example, the (superfluous) helices in the picture in the 
first link are specified like this:

  - a_helix :
    - show : True
    - object : doublehelix
      args :
        pitch : 5
        phase : 30
        handedness : left
        p : [1, -15, 0]
        p1 : [0, -15, 0]
        p2 : [0, 15, 0]
        rgb1 : [1, 1, 0]
        rgb2 : [0, 1, 1]
        step : 0.1
        radius : 0.075
        head_size : 0.225
        nsec : 30
        center_on : "atoms cyl D 4:6 CA"
        align_to :
          my_moment : [0, 0, 1]
          frame: "atoms cyl D 4:6 CA"
          frame_moment : [1, 0, 0]

Although this example looks complicated, it is mostly styling information 
(rgb1, rgb2, radius, head_size, etc.). The doublehelix is created by winding 
point "p" around the axis specified by "p1" and "p2" with a "pitch" of 5.

Points can be specified as vectors (e.g. [1, -15, 0]) or by atom selections 
(e.g. "atoms cyl D 4 CA").

The selection syntax allows for very terse and intuitive selections for single 
atoms or atom ranges. For example, the CA atoms of residues 4 through 6 of 
chain D of the pdb abbreviated as "cyl" are selected with the expression

     atoms cyl D 4:6 CA

Selections are not limited, however, in that they can be arbitrarily 
complicated using an S-expression (LISP-like) syntax that is easy to use once 
you get the hang of it. Here is an example:

  or (and (one_of segID A000 A002 B00B B00D C000 C002) (< resSeq 25))
     (and (one_of segID A00C A00E B001 B003 C00A C00C) (> resSeq 22))

This expression selects all residues numbered less than 25 from segments named 
A000, A002, etc., and also all residues greater than 22 from segments A00C, 
A00E, etc. Although S-expressions look funny or confusing at first, once you 
get the hang of them, you might agree with me that any other selection syntax 
seems barbaric by comparison. (Note that "atoms cyl D 4:6 CA" is actually an 
S-expression, where "atoms" is the operator and the rest of the expression 
contains the arguments to the operator.)

In the first link above, note that the helices are perfectly aligned with the 
so-called figure axes (green, blue, and yellow double-headed arrows). These 
figure axes align with the principle moments of the triangle made by "atoms cyl 
D 4:6".  Similarly, the helix is made to align with these moments by first 
centering on the triangle formed by the atom centers of "atoms cyl D 4:6" and 
then by aligning the last moment of the helix with the principal moment of the 
triangle. All of this high-level geometry is specified by only five simple 
lines:

        center_on : "atoms cyl D 4:6 CA"
        align_to :
          my_moment : [0, 0, 1]
          frame: "atoms cyl D 4:6 CA"
          frame_moment : [1, 0, 0]

The use of atom selections and moments frees the user from performing manual 
alignments, extracting coordinates, or doing math. This means that if your 
model coordinates change, then your illustrations change with them.

CGObjects has many different types of objects like surfaces, polytubes, and 
arrows. It also supports reusable, hierarchical styling and even variable 
declarations, making it possible to change the appearance of an entire set of 
illustrations in a centralized and uniform way.

James



On Oct 26, 2012, at 2:32 PM, Pete Meyer wrote:
> Francois Berenger wrote:
>> Hello,
>> For some new project, I'd like to be able to generate things
>> and store them in PDB format.
>> For example, a triangle, a line segment, a square,
>> a cube, a sphere, an arrow, etc.
>> Being able to change the color and "line width" would be nice.
>> Is there some official recommended way of doing this?
>> Is there some software able to read and display such
>> graphical annotations of PDB files?
>> I'll also need the format description in that case.
>> I want to be able to process a PDB file and store the result
>> of my processing in the same PDB file as some kind of annotation.
>> My current way of doing this is to discretize my objects as H atoms
>> in some other output PDB file, but that's just a temporary workaround.
>> My current search got me this:
>> http://www.cgl.ucsf.edu/eccc1/
>> So, maybe there is some support for what I am looking for into
>> Chimera.
>> Thanks a lot for your suggestions,
>> Francois.

Reply via email to