19
$\begingroup$

Most of the existing software I know (like VMD or Pymol) say that they can be used to create PDF files with 3D representations of molecules: actual 3D models, which you can rotate inside the Adobe Acrobat viewer. However, they all require the use of “Adobe Acrobat Pro 9 Extended” for its 3D capture feature. From what I can read, this feature does not exist any more in Acrobat X and was transferred to a separate product, Tetra4D, which doesn't work on Mac OS.

So, how can I produce PDF files including 3D molecular models using free (or better, open source) tools?

$\endgroup$
  • $\begingroup$ What I would look for is something that lets you draw molecules and save as a 3D standard (VML, etc). Then something that takes that standard and saves as 3D pdf. Open source of course. Mash 'em up! $\endgroup$ – ManishEarth May 31 '12 at 14:16
18
$\begingroup$

Disclaimer

  1. This is not for the faint-hearted.
  2. If you are not interested in using LaTeX, stop reading now, as this uses the media15 or movie9 packages to embed U3D in a pdfLaTeX generated PDF. This answer assumes basic familiarity with LaTeX. I have tested this with pdfLaTeX and it should work fine in XeLaTeX.
  3. One of the tools I have used (DAZ Studio) is apparently 'free for a limited time'. It is also not available on Linux. FOSS replacement suggestions are welcome.
  4. I'm of the personal opinion that 3D in PDF is not as good as it sounds.

What doesn't work

VMD offers the ability to output as OBJ, which can then be processed with FOSS MeshLab into a U3D file that can be embedded into a PDF. This is sub-optimal for two reasons:

  • There is no way to tell MeshLab that the VMD-generated mesh is supposed to be Gouraud-shaded. This means that the hard facets of the mesh will be glaringly obvious in the pdf, even if you use an unwieldy degree of subdivision.

  • Colours are not preserved. Your model will appear in the PDF with a uniform grey texture.

As such, MeshLab is not suitable at this stage.

Preparing a model

VMD offers a number of decent export options to get our geometry out of .PDB or what have you and into a mesh format. I opted to use the VRML format to output a mesh of a ribbon representation of PDB entry 4DM9. I then imported this into Blender.

enter image description here

Blender has no reliable U3D export capabilities, however I can use it to assign Gouraud shading to all of the shapes and assign colours to them. I then use the blender export function to export the scene as a Wavefront .OBJ file, with attendant .MTL file.

Processing with DAZ Studio

I am indebted to the author of this article (John Nyquist), which indicated that DAZ Studio can convert Wavefront to U3D just fine, with preservation of textures. DAZ is a very specific program that seems to be heavily geared towards posing, clothing and rendering humanoid figures in the spirit of programs like Poser. However all we really need is the U3D export function and we can read in the structure just fine.

Sometimes, this is how I see myself:

enter image description here

Okay in all seriousness, don't put a human figure in or on your molecule without good reason. Export as U3D and then we can embed in pdfLaTeX.

pdfLaTeX and movie9

As a proof of concept, I just followed the minimal example given in the media9 manual for getting a 3D model into a pdfLaTeX-generated PDF. Here it is, being viewed in Adobe Reader X (I know, I know!). Bear in mind that very few readers can actually display 3D PDF, which is one of the reasons why I feel that it is not such a good idea for chemical visualisation.

enter image description here

It starts off zoomed way too far in because I did not set up any options for the import (however you can find out all about that in the media9 or movie15 package manuals) and is a bit laggy on account of having over 1 million faces (I went way overboard with subdivision), however the important thing is that it works.

Improvements welcome!

Obviously, this is a pretty Rube Goldbergesque route to getting a molecule into a PDF. There probably exist easier ways which should definitely be suggested.

$\endgroup$
8
$\begingroup$

If you are ready to invest a lot of time to learn Asymptote you can use it to create 3D PDF documents from pdb files with it. Here is an example. It has the advantage that Asymptote has a good LaTeX integration and you can use the code directly in a LaTeX document. But it would be very messy to get the appearance right and I'd say it will only work for Ball-and-Stick models.

Update: I found some other nice examples of crystal unit cells being depicted with Asymptote, which can serve as some kind of proof-of-concept on using Asymptote to depict (simple) molecules:

Labels and angles in crystal structure using Asymptote

enter image description here

Drawing 3D crystal lattice with tikz/pstricks

enter image description here

Both are from TeX.StackExchange, so if you want to try asymptote you might find some help there, when you run into problems.

$\endgroup$
  • $\begingroup$ That's pretty neat - how is atomic connectivity obtained, though? It looks like most of the atoms are joined in some kind of linear sequence, probably the order in which they are defined in the pdb? $\endgroup$ – Richard Terrett Jun 1 '12 at 5:54
  • $\begingroup$ @RichardTerrett: Sorry, but I don't know how it is done in the example. I accidentally came across Asymptote while searching for a good way to embed 3D molecules in PDF documents but haven't had the time to learn it. But I'm pretty sure one can produce code with it that connects certain atoms with one another according to information from pdb files. $\endgroup$ – Philipp Jun 2 '12 at 12:51
4
$\begingroup$

There is online converter from PubChem CID to 3D PDF/U3D at http://xemistry.com/ (http://85.214.192.197/pdf3d to be exact).

As to Asymptote - go to its forum and ask for help. 3D PDF export is under development, so early adopters (AKA guinea pigs) are welcome. Among other things OBJ import is in the works. The apparent lack of demand is one of the reasons FOSS support for 3D PDF is slow to emerge - and at lest asking for it in appropriate place is the minimal effort I can think of.

Also you can inspire the developers of your favorite tools to take code from Asymptote or Intel U3D Sample library to produce 3D PDF directly or develop standalone converters.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.