MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Chem PDB files, Export and Manipulation

  • To: mathgroup at
  • Subject: [mg95457] Re: Chem PDB files, Export and Manipulation
  • From: Albert Retey <awnl at>
  • Date: Mon, 19 Jan 2009 02:57:19 -0500 (EST)
  • References: <gksbn6$dqp$>


> I would like to use Mathematica 7.0's ability to import pdb files and
> other (supported) chemistry related files into a Graphics3D object, to
> be able to position and manipulate the resulting molecules and their
> coordinates relative to other objects (Polygons, GraphicsComplexes,
> etc.).
> How can this be done? Is it possible to manipulate a single atom's
> position within Mathematica's objects, or does it need to be specified
> in the pdb file beforehand?

It is definitely possible, but for typical content of these files it
might be somewhat difficult to locate the graphics primitives that you
need to manipulate. This is not only because there might be plenty of
them but also because the imported graphics make use of GraphicsComplex,
which is reasonable and a good choice but makes the location probably
somewhat more complex. With good knowledge and understanding of
Mathematica basics (especially pattern matching I would guess) and some
experience it should be possible, but I don't know of any easy klick and
point way to do what you want for 3d graphics with many objects and

> When imported into Mathematica, are pdb files scalable vectors, or
> bitmaps? It seems that the resolution of the collective atoms
> deteriorates considerably once you expand the original image (within
> Mathematica, of course). Is it possible to export the resulting 3D
> image to a vector image?

Not being an expert for this kind of data I am left with the example
data, which seem to be imported correctly as Mathematica graphic
objects, which means they are mathematica expressions representing
vector graphics. If you choose a vector image format as output
Mathematica will usually export vector data and not converting to
pixels, AFAIK. You might have seen the behavior you describe when
looking at the documentation, in which most large graphics are converted
to pixel formats to make the documentation more compact. If you
reevaluate everything, the graphics should be rendering nice also when
expanding the image, you can then also rotate and zoom...

> The section dealing with Chemistry/Biology objects in the Mathematica
> help is not very clear (understatement) on how to include and
> manipulate the resulting molecules within other graphical objects.

that is a typical problem with the help: it probably suggests that you
are familiar with the mathematicas 'paradigms', especially this one:
'everything is an expression'. When understanding that the molecule-data
is imported as a 3d-Graphics-object and that, of course :-), is an
expression, you will understand that there is no need to handle or
explain these in any special way. You can just use all the regular
functions to manipulate expressions of any kind. To see them in
'expression format' you can look at them with InputForm or FullForm.
Admittedly that is not much help for those who are not so familiar with
all the details of Mathematica, so some examples in the documentation
would be a big help, of course...

> If anyone knows anything about this, I would appreciate your help!

not too much, but I hope it still is of some help. I have included some
code which shows how you can create an interface to interactively
manipulate the position of one atom in one of the examples provided with
mathematica, not a very realistic use case but probably a starting point....


Import something from the example data:


There are 23 GraphicsComplexes in the graphics3d:


You can extract just the first of them:


and show only it alone:


Combining these with a manipulate you can find which of them is what is
of interest to you. To do this, I extract the plotrange of the total view:


... and use that to fix the PlotRange:


In the following, we would like to manipulate one of the atoms in the
chain represented by graphics complex number 23:


These are the coordinates of the first point in the GraphicsComplex,
which happens to be the coordinate of the first atom of this chain:


Making use of all the above, this will give you an interface to
manipulate the coordinates of that first atom:


Some notes:
1) the Dynamic is only included for performance reasons -- but makes a
big difference :-),
2) manipulating the coordinates of a graphics complex instead of
coordinates of single graphics primitives has the advantage that the
chain stays intact: the connection to the next atom is automatically
changed, too. Of course that is not always what you want, so sometimes
you would even need to pull some of the graphic primitives out of the
graphics complex.

  • Prev by Date: Re: Re: Which editor do you use for math articles
  • Next by Date: Re: Re: Which editor do you use for math articles
  • Previous by thread: Bizarre Histogram behavior
  • Next by thread: image not displaying properly