Representing and rendering molecular structures

The following examples result from a project to convert and represent
molecules from a number of file formats (PDB, MOL2, ALC, AL2,...)
primarily for visual appeal rather than for analysis. The
rendering was to be performed using a number of rendering packages,
both public domain and commercial (PovRay,
Tachyon, 3DStudioMax, LightWave, ....). In order to convert the geometric
structure (atoms and bonds) into a format suitable for each package, it
was decided to define a minimal format from which translators to a
particular rendering package would be written.
This is a fairly standard approach, instead of writing a converter
between every combination of input format and output format, translators
are written from every input format to a single format and another translator
converts from this single format to each output format. This intermediate
format is typically called a meta format because it usually supports
all the features of the input formats, in this case it was designed so
it only supports the minimal requirements required for the rendering.
In some cases the translator
from this meta file format can be parsed by the scripting language of
the rendering package (eg: 3DStudioMax), in other cases it may be written
as another piece of C/C++ code.

The simple file format (.txt below) was a human readable file arranged in lines.
The first character of each line determines the data on the rest of the line.
At this time there are only three line types, comments (#), atoms (a), and
bonds (b). A comment line is ignored. An atom line contains an atom
name followed by the (x,y,z) coordinate. A bond line consists of a
bond name followed by two (x,y,z) coordinates. An example of such a file
is given below.