Saturday, 21 March 2015

What open-source software can produce 3D PDF representation of molecules?


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?




Answer



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.


No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...