Difference between revisions of "3d pdf"

From PyMOLWiki
Jump to navigation Jump to search
(rearrange some tex to avoid dropping comma)
 
(40 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
= Overview =
 
= Overview =
 
PyMOL can convert to formats (vrml2 and idtf) that can be converted to a [[:File:Pymol.pdf|3D PDF]] (will not work with most PDF browser plugins; must be downloaded and viewed with certain viewers liked Adobe Acrobat 9.2+).
 
PyMOL can convert to formats (vrml2 and idtf) that can be converted to a [[:File:Pymol.pdf|3D PDF]] (will not work with most PDF browser plugins; must be downloaded and viewed with certain viewers liked Adobe Acrobat 9.2+).
 +
 +
'''Note'''. The figure is only represented in cartoon format. No sticks yet...
  
 
== Requirements ==
 
== Requirements ==
 
* PyMOL
 
* PyMOL
* [http://www.iaas.msu.ru/tmp/u3d/u3d-1.2.852.tar.gz u3d converter IDTF to U3D converter]
+
* [http://sourceforge.net/projects/u3d/files/Universal%203D%20Sample%20Software/ Universal 3D Sample Software - u3d converter - IDTF to U3D]
 
* LaTeX (pdflatex)
 
* LaTeX (pdflatex)
 +
 +
== Get IDFT file from PyMOL ==
 +
* Save your molecule to an IDTF file in PyMOL:
 +
<source lang="python">
 +
save pymol.idtf, *
 +
</source>
 +
PyMOL will print a line that looks like:
 +
  3Daac=20.0, 3Droll=0, 3Dc2c=0 0 1, 3Droo=62.45, 3Dcoo=0 0 -62.45
 +
copy this line into the pymol.tex file overwriting the same line in the file.
 +
 +
= Windows - Convert the IDTF to U3D =
 +
== Quick ==
 +
# Download '''Universal 3D Sample Software - u3d converter - IDTF to U3D''', and extract to Desktop<br>
 +
# Navigate to the '''bin''' folder: \Desktop\U3D_A_061228_5\Bin\Win32\Release <br>
 +
# Copy '''pymol.idtf''' in here.
 +
# Hold '''shift''' key, right click in folder, click '''Open command window here'''.
 +
Then copy this inot command window:
 +
IDTFConverter -input pymol.idtf -output pymol.u3d
 +
Copy the pymol.u3d into your LaTeX folder
 +
== General ==
 +
# Download '''Universal 3D Sample Software - u3d converter - IDTF to U3D''', and extract to C:\Program Files (x86)\U3D_A_061228_5<br>
 +
# Make a '''IDTF2U3D.bat''' and afterwards copy to '''C:\Windows'''.
 +
<source lang="winbatch">
 +
@echo off
 +
rem -- Run IDTFConverter --
 +
set IDTF_EXE_DIR=C:\Program Files (x86)\U3D_A_061228_5\Bin\Win32\Release
 +
 +
if exist "%IDTF_EXE_DIR%\IDTFConverter.exe" goto haveProg
 +
echo "%IDTF_EXE_DIR%\IDTFConverter.exe" not found
 +
goto eof
 +
 +
:haveProg
 +
if .%1==. goto noarg
 +
 +
"%IDTF_EXE_DIR%\IDTFConverter.exe" -input %1 -output %~n1.u3d
 +
goto eof
 +
 +
:noarg
 +
echo no arguments given.
 +
echo IDTF2U3D pymol.idtf
 +
 +
:eof
 +
echo Done
 +
</source>
 +
# Navigate to '''pymol.idtf'''. Right click, Open with..., Browse to: '''C:\Windows''' and select '''IDTF2U3D.bat'''
 +
Copy the pymol.u3d into your LaTeX folder
 +
 +
= Linux install - Convert the IDTF to U3D=
 +
* Currently you have to compile the u3d converter on Linux. I did that with:
 +
* Some versions of Acrobat on Linux incorrectly parse the 3D data. Adobe knows about this and plans to fix it. Ironically, I created a 3D PDF on Linux but could only view it on Mac OS X.
 +
See current versions here: http://www2.iaas.msu.ru/tmp/u3d
 +
 +
<source lang="bash">
 +
cd ~/Downloads/ ;
 +
wget http://www2.iaas.msu.ru/tmp/u3d/u3d-1.4.3.tar.gz ;
 +
tar -xzf u3d-1.4.3.tar.gz ;
 +
cd u3d-1.4.3 ;
 +
cmake . ;
 +
make ;
 +
chmod g+wx . ;
 +
set IDDIR=$PWD ;
 +
 +
cat > IDTF2U3D << EOF
 +
#!/bin/tcsh
 +
set FOLD=\$PWD
 +
set IN=\$PWD/\$1
 +
cp -f \$IN $IDDIR
 +
cd $IDDIR
 +
./IDTFConverter -input \$1 -output \$1:r:t.u3d
 +
cp -f \$1:r:t.u3d \$FOLD/
 +
EOF
 +
 +
chmod +x IDTF2U3D
 +
 +
ln -s $PWD/IDTF2U3D ~/bin/IDTF2U3D
 +
</source>
 +
 +
Then write in terminal
 +
IDTF2U3D pymol.idtf
 +
 +
= LaTeX code =
 +
== LaTeX code pdf  ==
 +
Example [[:File:Pymol.pdf|3D PDF]]<br>
 +
Download Example, and open in acrobat reader: [http://www.fys.ku.dk/~tlinnet/1zqa.pdf 1zqa PDF]
 
* The following LaTeX code saved as "pymol.tex":
 
* The following LaTeX code saved as "pymol.tex":
 
<source lang="latex">
 
<source lang="latex">
Line 16: Line 102:
 
\author{Jason Vertrees}
 
\author{Jason Vertrees}
 
\maketitle
 
\maketitle
\begin{center}
+
\begin{figure}[!htb]
 +
\centering
 
\includemovie[
 
\includemovie[
        poster,
+
poster,
        toolbar, %same as `controls'
+
toolbar, %same as `controls'
        label=pymol.ud3
+
label=pymol.ud3
        text=(pymol.u3d),
+
text=(pymol.u3d),
        3Dlights=CAD,
+
3Dlights=CAD,
        % replace the next line with what PyMOL output
+
% replace the next line with what PyMOL output
        3Daac=20.0, 3Droll=0, 3Dc2c=0 0 1, 3Droo=62.45, 3Dcoo=0 0 -62.45
+
3Daac=20.0, 3Droll=0, 3Dc2c=0 0 1, 3Droo=243.39, 3Dcoo=0 0 -243.39
 
]{\linewidth}{\linewidth}{pymol.u3d}
 
]{\linewidth}{\linewidth}{pymol.u3d}
\label{ex3d} A PyMOL object embedded in PDF, using U3D data format.
+
\caption{A PyMOL object embedded in PDF, using U3D data format.}
\end{center}
+
\label{pym:ex3d}
 +
\end{figure}
 
\end{document}
 
\end{document}
 
</source>
 
</source>
  
== Directions ==  
+
== LaTeX beamer presentation ==
 +
Download Example, and open in acrobat reader: [http://www.fys.ku.dk/~tlinnet/beamer.pdf beamer PDF] <br>
 +
Download Example, and open in acrobat reader: [http://www.fys.ku.dk/~tlinnet/beamer_1zqa.pdf beamer 1zqa PDF]
 +
<source lang="latex">
 +
\documentclass{beamer}
 +
\usepackage[3D]{movie15}
 +
\usepackage[UKenglish]{babel}
  
* Save your molecule to an IDTF file in PyMOL:
+
%% See: http://en.wikibooks.org/wiki/LaTeX/Presentations
<source lang="python">
+
%% See: http://www.hartwork.org/beamer-theme-matrix/
save pymol.idtf, *
+
\usetheme{Copenhagen}
</source>
+
\usecolortheme{beaver}
PyMOL will print a line that looks like:
 
  3Daac=20.0, 3Droll=0, 3Dc2c=0 0 1, 3Droo=62.45, 3Dcoo=0 0 -62.45
 
copy this line into the pymol.tex file overwriting the same line in the file.
 
  
* Convert the IDTF to U3D:
+
\begin{document}
   ./IDTFConverter -input pymol.idtf -output pymol.u3d
+
\title{Simple Beamer Class}    
 +
\author{Troels Linnet}
 +
\date{\today}
 +
\frame{\titlepage}
 +
\frame{\frametitle{Table of contents}\tableofcontents}
  
* Create the PDF using LaTeX:
+
\section{3D object}
  pdflatex pymol.tex
+
\frame{\frametitle{Pymol 3D object}
 +
\begin{figure}[!htb]
 +
\centering
 +
\includemovie[
 +
poster,
 +
toolbar, %same as `controls'
 +
label=pymol.ud3
 +
text=(pymol.u3d),
 +
3Dlights=CAD,
 +
% replace the next line with what PyMOL output
 +
3Daac=20.0, 3Droll=0, 3Dc2c=0 0 1, 3Droo=243.39, 3Dcoo=0 0 -243.39
 +
]{10cm}{6cm}{pymol.u3d}
 +
\caption{A PyMOL object embedded in PDF, using U3D data format.}
 +
\label{pym:ex3d}
 +
\end{figure}
 +
}
 +
 
 +
\section{Lists}
 +
\subsection{Lists I}
 +
\frame{\frametitle{Unnumbered lists}
 +
\begin{block}{My bloc}
 +
test of bloc
 +
\end{block}
  
 +
\begin{itemize}
 +
\item Introduction to  \LaTeX 
 +
\item Beamer class
 +
\end{itemize}
 +
}
  
== Caveats ==
+
\end{document}
* Currently you have to compile the u3d converter on Linux. I did that with:
 
<source lang="bash">
 
cmake .
 
make
 
 
</source>
 
</source>
which created "IDTFConverter" that I used above.
 
  
* Some versions of Acrobat on Linux incorrectly parse the 3D data. Adobe knows about this and plans to fix it. Ironically, I created a 3D PDF on Linux but could only view it on Mac OS X.
+
* Create the PDF using LaTeX:
 +
  pdflatex pymol.tex
 +
 
 +
= More on 3D PDFs =
 +
* [http://www.adobe.com/manufacturing/3dpdfsamples/3dsolutions/ 3D PDFs at Adobe]
 +
* [http://molecularmodelingbasics.blogspot.dk/2009/12/future-of-scientific-publishing-is-here.html Future of scientific publishing]
 +
* [http://jpswalsh.com/how-to-embed-a-3d-molecule-in-a-pdf/ Instructions for Jmol]
  
 +
== See Also ==
 +
* [[Movie_pdf | Movie in pdf]]
  
== More on 3D PDFs ==
+
[[Category:PyMOL_in_pdf]]
* [http://www.adobe.com/manufacturing/3dpdfsamples/3dsolutions/ 3D PDFs at Adobe]
 

Latest revision as of 12:17, 14 May 2015

Overview

PyMOL can convert to formats (vrml2 and idtf) that can be converted to a 3D PDF (will not work with most PDF browser plugins; must be downloaded and viewed with certain viewers liked Adobe Acrobat 9.2+).

Note. The figure is only represented in cartoon format. No sticks yet...

Requirements

Get IDFT file from PyMOL

  • Save your molecule to an IDTF file in PyMOL:
save pymol.idtf, *

PyMOL will print a line that looks like:

 3Daac=20.0, 3Droll=0, 3Dc2c=0 0 1, 3Droo=62.45, 3Dcoo=0 0 -62.45

copy this line into the pymol.tex file overwriting the same line in the file.

Windows - Convert the IDTF to U3D

Quick

  1. Download Universal 3D Sample Software - u3d converter - IDTF to U3D, and extract to Desktop
  2. Navigate to the bin folder: \Desktop\U3D_A_061228_5\Bin\Win32\Release
  3. Copy pymol.idtf in here.
  4. Hold shift key, right click in folder, click Open command window here.

Then copy this inot command window:

IDTFConverter -input pymol.idtf -output pymol.u3d

Copy the pymol.u3d into your LaTeX folder

General

  1. Download Universal 3D Sample Software - u3d converter - IDTF to U3D, and extract to C:\Program Files (x86)\U3D_A_061228_5
  2. Make a IDTF2U3D.bat and afterwards copy to C:\Windows.
@echo off
rem -- Run IDTFConverter --
set IDTF_EXE_DIR=C:\Program Files (x86)\U3D_A_061228_5\Bin\Win32\Release

if exist "%IDTF_EXE_DIR%\IDTFConverter.exe" goto haveProg
echo "%IDTF_EXE_DIR%\IDTFConverter.exe" not found
goto eof

:haveProg
if .%1==. goto noarg

"%IDTF_EXE_DIR%\IDTFConverter.exe" -input %1 -output %~n1.u3d 
goto eof

:noarg
echo no arguments given.
echo IDTF2U3D pymol.idtf

:eof
echo Done
  1. Navigate to pymol.idtf. Right click, Open with..., Browse to: C:\Windows and select IDTF2U3D.bat

Copy the pymol.u3d into your LaTeX folder

Linux install - Convert the IDTF to U3D

  • Currently you have to compile the u3d converter on Linux. I did that with:
  • Some versions of Acrobat on Linux incorrectly parse the 3D data. Adobe knows about this and plans to fix it. Ironically, I created a 3D PDF on Linux but could only view it on Mac OS X.

See current versions here: http://www2.iaas.msu.ru/tmp/u3d

cd ~/Downloads/ ;
wget http://www2.iaas.msu.ru/tmp/u3d/u3d-1.4.3.tar.gz ;
tar -xzf u3d-1.4.3.tar.gz ;
cd u3d-1.4.3 ;
cmake . ;
make ;
chmod g+wx . ;
set IDDIR=$PWD ;

cat > IDTF2U3D << EOF
#!/bin/tcsh
set FOLD=\$PWD
set IN=\$PWD/\$1
cp -f \$IN $IDDIR
cd $IDDIR
./IDTFConverter -input \$1 -output \$1:r:t.u3d
cp -f \$1:r:t.u3d \$FOLD/
EOF

chmod +x IDTF2U3D

ln -s $PWD/IDTF2U3D ~/bin/IDTF2U3D

Then write in terminal

IDTF2U3D pymol.idtf

LaTeX code

LaTeX code pdf

Example 3D PDF
Download Example, and open in acrobat reader: 1zqa PDF

  • The following LaTeX code saved as "pymol.tex":
\documentclass[a4paper]{article}
\usepackage[3D]{movie15}
\usepackage[UKenglish]{babel}
\usepackage[colorlinks=true]{hyperref} 
\begin{document}
\title{PyMOL 3D Objects in PDF}
\author{Jason Vertrees}
\maketitle
\begin{figure}[!htb]
\centering
\includemovie[
poster,
toolbar, %same as `controls'
label=pymol.ud3
text=(pymol.u3d),
3Dlights=CAD,
% replace the next line with what PyMOL output
3Daac=20.0, 3Droll=0, 3Dc2c=0 0 1, 3Droo=243.39, 3Dcoo=0 0 -243.39
]{\linewidth}{\linewidth}{pymol.u3d}
\caption{A PyMOL object embedded in PDF, using U3D data format.}
\label{pym:ex3d}
\end{figure}
\end{document}

LaTeX beamer presentation

Download Example, and open in acrobat reader: beamer PDF
Download Example, and open in acrobat reader: beamer 1zqa PDF

\documentclass{beamer}
\usepackage[3D]{movie15}
\usepackage[UKenglish]{babel}

%% See: http://en.wikibooks.org/wiki/LaTeX/Presentations
%% See: http://www.hartwork.org/beamer-theme-matrix/
\usetheme{Copenhagen} 
\usecolortheme{beaver}

\begin{document}
\title{Simple Beamer Class}   
\author{Troels Linnet} 
\date{\today} 
\frame{\titlepage} 
\frame{\frametitle{Table of contents}\tableofcontents} 

\section{3D object} 
\frame{\frametitle{Pymol 3D object}
\begin{figure}[!htb]
\centering
\includemovie[
poster,
toolbar, %same as `controls'
label=pymol.ud3
text=(pymol.u3d),
3Dlights=CAD,
% replace the next line with what PyMOL output
3Daac=20.0, 3Droll=0, 3Dc2c=0 0 1, 3Droo=243.39, 3Dcoo=0 0 -243.39
]{10cm}{6cm}{pymol.u3d}
\caption{A PyMOL object embedded in PDF, using U3D data format.}
\label{pym:ex3d}
\end{figure}
}

\section{Lists}
\subsection{Lists I}
\frame{\frametitle{Unnumbered lists}
\begin{block}{My bloc}
test of bloc
\end{block}

\begin{itemize}
\item Introduction to  \LaTeX  
\item Beamer class
\end{itemize} 
}

\end{document}
  • Create the PDF using LaTeX:
 pdflatex pymol.tex

More on 3D PDFs

See Also