# Using Chemical Data to make molecule graphics

I would like to take the acetone and chloroform molecules that Mathematica's chemical data provides, and plot them together. I want to show how chloroform can hydrogen bond to acetone. Right now I have them plotted on top of each other :/

Show[ChemicalData["Chloroform", "MoleculePlot"],
ChemicalData["Acetone", "MoleculePlot"]]


-
...I don't think Mathematica is the best software to use for this. Why not use a dedicated 3D chemical drawing program? –  Ｊ. Ｍ. Apr 7 at 19:31
–  belisarius Apr 7 at 19:40
If you examine the FullForm of the molecular plots, you may come up with a one-off solution. Some assembly may be required. –  David Carraher Apr 7 at 20:11
Are there any free 3D chemical drawing programs? –  olliepower Apr 7 at 20:17
Somewhat related (for post-processing): Can a LatticeData image be displayed in a space filled fashion. –  Jens Apr 7 at 20:24
show 1 more comment

A quick way of showing how the two structures can be positioned relative to each other in a single Graphics3D is as follows:

With[{rMax = 500},
Manipulate[
Graphics3D[
{First@ChemicalData["Acetone", "MoleculePlot"],
GeometricTransformation[
First@ChemicalData["Chloroform", "MoleculePlot"],
Composition[
TranslationTransform[{displacementX, displacementY,
displacementZ}],
RotationTransform[
rotationAngle, {Cos[axisAzimuth] Sin[axisPolar],
Sin[axisAzimuth] Sin[axisPolar], Cos[axisPolar]}]]]},
PlotRange -> {{-rMax, rMax}, {-rMax, rMax}, {-rMax, rMax}}
],
{{displacementX, 0}, -rMax, rMax}, {{displacementY, 0}, -rMax,
rMax}, {{displacementZ, 0}, -rMax, rMax}, {rotationAngle, 0,
2 Pi},
{axisPolar, 0, 2 Pi}, {axisAzimuth, 0, 2 Pi}
]
]


The Manipulate is just to let you do some manual re-positioning. You can eventually get better results by doing pre-calculated shifts and rotations based on the exact locations of the atoms. But I'm focusing here on the basic ingredients. For the display, this involves mainly the use of First to extract the contents of the Graphics3D of the molecule, then the translation and rotation using GeometricTransformation with a Composition of the former two operations.

The variable rMax sets the plot range and the maximum displacement of the chloroform molecule relative to the acetone.

-
+1 Very nice! Now this is the first step to do genetic manipulation completely inside Mma :D –  belisarius Apr 7 at 21:05
wow, excellent work. This is exactly what I was looking for. –  olliepower Apr 7 at 23:59

Here is a less impressive take on the question.

positionsA =
ChemicalData["Acetone", "AtomPositions"] /. {x_, y_, z_} -> {x + 400, y + 400, z + 400};
positionsC = ChemicalData["Chloroform", "AtomPositions"];
{atomsA, atomsC} = {ChemicalData["Acetone", "VertexTypes"],
ChemicalData["Chloroform", "VertexTypes"]};
{colorsA, colorsC} = {Map[ColorData["Atoms", #] &, atomsA],
Map[ColorData["Atoms", #] &, atomsC]};