# Drawing a DNA/SNP genome double helix in TikZ

I need to make this drawing in TikZ, but unfortunately I'm having a hard time getting started.

It seems there are no pre-packaged options available for this. A first attempt, based on code examples from TeX.SX is found below, but it lacks the 3D effect on the the Helix and the base pairs look rather simplistic

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot3+[domain=0:4*pi, samples=100, samples y=0,no marks, smooth, draw=red](
{x/(3*pi)},
{cos(deg(x))},
{sin(deg(x))}
)   coordinate[pos=0.3]  (a1)  coordinate[pos=0.3]  (b1)  coordinate[pos=0.9]  (c1) ;
\addplot3+[domain=0:4*pi, samples=100, samples y=0,no marks, smooth, draw=green](
{x/(3*pi)},
{cos(deg(x+pi))},
{sin(deg(x+pi))}
)   coordinate[pos=0.3]  (a2) coordinate[pos=0.6]  (b2) coordinate[pos=0.9]  (c2) ;
\draw (a1)--(a2);
\draw (b1)--(b2);
\draw (c1)--(c2);
\end{axis}

\end{tikzpicture}
\end{document}


This may be completely off (because I cannot judge from your screen shot what the 3d properties of your helix are), but maybe a start (and according to Wikipedia it may not be off). If you specify the 3d properties more I will be happy to adjust it, if necessary. Of course one can add the thingies with the letters, but again I don't know their orientation in 3d. So what I can offer with my current knowledge is

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\tikzset{helix part/.style n args={2}{insert path={
plot[smooth,variable=\x,domain=-90+#1*180:90+#1*180,
-- plot[smooth,variable=\x,domain=90+#1*180:-90+#1*180,
samples=11]
}},helix/.is family,
helix/.cd,
\begin{document}
\tdplotsetmaincoords{90}{105}
\begin{tikzpicture}[tdplot_main_coords]
% \draw[-latex] (0,0,0) -- (\Length,0,0) node[below]{$x$};
% \draw[-latex] (0,0,0) -- (0,\Length,0) node[left]{$y$};
% \draw[-latex] (0,0,0) -- (0,0,\Length) node[left]{$z$};
\foreach \X in {0,2,...,8}
{
\path[top color=blue!60!black,bottom color=blue!30,middle color=blue,
helix part={\X}{0}]
;
\path[top color=red!60!black,bottom color=red!30,middle color=red,
;
}
\foreach \X in {1,3,...,9}
{
\path[top color=blue!30,bottom color=blue!60!black,middle color=blue,
helix part={\X}{0}];
\path[top color=red!30,bottom color=red!60!black,middle color=red,
}
\end{tikzpicture}
\end{document}


Since this is a 3d picture, you can play with the view angles (within limitations).

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\tikzset{helix part/.style n args={2}{insert path={
plot[smooth,variable=\x,domain=-90+#1*180:90+#1*180,
-- plot[smooth,variable=\x,domain=90+#1*180:-90+#1*180,
samples=11]
}},helix/.is family,
helix/.cd,
\begin{document}
\foreach \Ang in {5,15,...,355}
{\tdplotsetmaincoords{90}{120+30*sin(\Ang)}
\begin{tikzpicture}[tdplot_main_coords]
% \draw[-latex] (0,0,0) -- (\Length,0,0) node[below]{$x$};
% \draw[-latex] (0,0,0) -- (0,\Length,0) node[left]{$y$};
% \draw[-latex] (0,0,0) -- (0,0,\Length) node[left]{$z$};
\foreach \X in {0,2,...,8}
{
\path[top color=blue!60!black,bottom color=blue!30,middle color=blue,
helix part={\X}{0}]
;
\path[top color=red!60!black,bottom color=red!30,middle color=red,
;
}
\foreach \X in {1,3,...,9}
{
\path[top color=blue!30,bottom color=blue!60!black,middle color=blue,
helix part={\X}{0}];
\path[top color=red!30,bottom color=red!60!black,middle color=red,
}
\end{tikzpicture}}
\end{document}


Barbara Beeton kindly informed me in the chat that the above may be left-handed. Anyway, the handedness is a simple sign flip.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\tikzset{helix part/.style n args={2}{insert path={
plot[smooth,variable=\x,domain=-90+#1*180:90+#1*180,
-- plot[smooth,variable=\x,domain=90+#1*180:-90+#1*180,
samples=11]
}},helix/.is family,
helix/.cd,
\begin{document}
\tdplotsetmaincoords{90}{105}
\begin{tikzpicture}[tdplot_main_coords]
\foreach \X in {0,2,...,8}
{\path[top color=blue!60!black,bottom color=blue!30,middle color=blue,
helix part={\X}{0}];
\path[top color=red!60!black,bottom color=red!30,middle color=red,
\foreach \X in {1,3,...,9}
{\path[top color=blue!30,bottom color=blue!60!black,middle color=blue,
helix part={\X}{0}];
\path[top color=red!30,bottom color=red!60!black,middle color=red,
\end{tikzpicture}
\end{document}


One can definitely also build in base pairs. Of course, if you maintain 3d and orthographic projections, the code is not a one-liner. So I expect the usual suspects some other users to show up and say that one can use such a simple code instead, so I stop here.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\tikzset{helix part/.style n args={2}{insert path={
plot[smooth,variable=\x,domain=-90+#1*180:90+#1*180,
-- plot[smooth,variable=\x,domain=90+#1*180:-90+#1*180,
samples=11]
}},
helix coordinate/.style n args={2}{insert path={
helix/.is family,
helix/.cd,
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\newcounter{cup}
\newcounter{cdown}
\begin{document}
\foreach \Ang in {5,15,...,355}
{\tdplotsetmaincoords{90}{120+30*sin(\Ang)}
\setcounter{cup}{0}
\setcounter{cdown}{0}
\def\LstUp{{"red","red","blue","green!70!black","yellow","blue"}}
\def\LstDown{{"yellow","blue","red","blue","green!70!black","red","blue"}}
\begin{tikzpicture}[tdplot_main_coords]
\foreach \X in {0,2,...,8}
{\begin{pgfonlayer}{background}
\path[top color=blue!60!black,bottom color=blue!30,middle color=blue,
helix part={\X}{0}];
\end{pgfonlayer}
\begin{pgfonlayer}{main}
\foreach \Y [count=\Z] in {-90}
{\path [helix coordinate={180*\X+\Y}{0}] coordinate(start1)
[helix coordinate={180*\X+\Y}{\pgfkeysvalueof{/tikz/helix/width}}] coordinate(start2)
coordinate(end1)
coordinate(end2);
\stepcounter{cup}
\stepcounter{cdown}
\pgfmathsetmacro{\cup}{\LstUp[mod(\number\value{cup},6)]}
\pgfmathsetmacro{\cdown}{\LstDown[mod(\number\value{cdown},7)]}
\ifnum\Z<2
\path (end1) -- (start1) coordinate[midway] (aux1)
(start2) -- (end2) coordinate[midway] (aux2);
\fill[\cup] (start2) -- (start1) -- (aux1) -- (aux2) -- cycle;
\fill[\cdown] (aux2) -- (aux1) -- (end1) -- (end2) -- cycle;
\else
\path (end1) -- (start2) coordinate[midway] (aux1)
(start1) -- (end2) coordinate[midway] (aux2);
\fill[\cup] (start2) -- (start1) -- (aux1) -- (aux2) -- cycle;
\fill[\cdown] (aux2) -- (aux1) -- (end1) -- (end2) -- cycle;
\fi}
\end{pgfonlayer}
\begin{pgfonlayer}{background}
\path[top color=red!60!black,bottom color=red!30,middle color=red,
\end{pgfonlayer}}
\foreach \X in {1,3,...,9}
{\begin{pgfonlayer}{foreground}
\path[top color=blue!30,bottom color=blue!60!black,middle color=blue,
helix part={\X}{0}];
\end{pgfonlayer}
\begin{pgfonlayer}{main}
\foreach \Y [count=\Z] in {-90}
{\path [helix coordinate={180*\X+\Y}{0}] coordinate(start1)
[helix coordinate={180*\X+\Y}{\pgfkeysvalueof{/tikz/helix/width}}] coordinate(start2)
coordinate(end1)
coordinate(end2);
\stepcounter{cup}
\stepcounter{cdown}
\pgfmathsetmacro{\cup}{\LstUp[mod(\number\value{cup},6)]}
\pgfmathsetmacro{\cdown}{\LstDown[mod(\number\value{cdown},7)]}
\ifnum\Z<2
\path (end1) -- (start1) coordinate[midway] (aux1)
(start2) -- (end2) coordinate[midway] (aux2);
\fill[\cup] (start2) -- (start1) -- (aux1) -- (aux2) -- cycle;
\fill[\cdown] (aux2) -- (aux1) -- (end1) -- (end2) -- cycle;
\else
\path (end1) -- (start2) coordinate[midway] (aux1)
(start1) -- (end2) coordinate[midway] (aux2);
\fill[\cup] (start2) -- (start1) -- (aux1) -- (aux2) -- cycle;
\fill[\cdown] (aux2) -- (aux1) -- (end1) -- (end2) -- cycle;
\fi}
\end{pgfonlayer}
\begin{pgfonlayer}{foreground}
\path[top color=red!30,bottom color=red!60!black,middle color=red,