[Tex/LaTex] How to draw nucleosomes with wrapped DNA in tikz or pstricks

3dpstrickstikz-pgf

The nucleosome is the fundamental unit of DNA packing in cells, and I am trying to generate some figures for regular use in manuscripts and presentations. The nucleosome is commonly abstracted to a drawing in one of two ways. One representation is as it appears in Wikipedia Creative Commons nucleosome image by Wikipedia user Darekk2

drawn as a core of eight spheres (representing the core histone octamer), with a two wraps of DNA and a ninth histone (H1). Sometimes the proteins are further abstracted to a cylinder or just a single sphere so that several adjacent nucleosomes packing DNA can be illustrated. That's what I'm trying to achieve. Very often the cylinder is tilted, like in this extremely impoverished tikz attempt. I would be thrilled to keep the multiple histone proteins, but it may be too challenging.

 \documentclass{standalone}
 \usepackage {tikz}
 \usetikzlibrary{shapes}
 \begin {document}
 \tikzset{nucleosome core/.style={cylinder, 
     rotate=30,shape aspect=0.5,minimum width=1cm,
     minimum height=0.7cm, cylinder uses custom fill,
     cylinder end fill=red!50,cylinder body fill=red!25}}
 \begin{tikzpicture}
 \foreach \i in {0,2,4,6} { 
   \path node [nucleosome core] at (\i,0) {} edge [bend right] (\i + 1.7,0);
 }
   \end{tikzpicture}
 \end{document}

nucleosome

Here the DNA linking adjacent nucleosomes is evident, but it is missing the DNA wrapping, which is really essential because that's what the nucleosome does.

I think to get to something like the Wikipedia version I'd need to use pstricks, though I normally use tikz for figures and would be willing to trade 3D realism for familiarity. At a minimum, I'd like my cylinder-tikz version to include the wrappings.

[EDIT: I added a bounty because, while I recognize the particular question may be of limited interest to the larger TeX.SX community, I think I'd learn a lot from better efforts than my current best shot. If more inspiration is needed, here is an example of some nucleosomes as cylinders, and here with epigenetic marks decorating nucleosomes.]

Best Answer

Definitely not perfect, and it mostly could/should be parameterised (and the `frontwrapping' layer is arguably unecessary):

\documentclass{article}
\usepackage{tikz}

\begin{document}

\pgfdeclarelayer{backwrapping}
\pgfdeclarelayer{frontwrapping}
\pgfsetlayers{backwrapping,main,frontwrapping}

\tikzset{
    wrapping/.style={
        draw=black!60, 
        line cap=round, 
        line join=round, 
        ultra thick},
    nucleosome/.style={
        fill=red!40, 
        fill opacity=.9, 
        draw=none},
    top cylinder/.style={
        fill=red!60, 
        fill opacity=.9
    }
}


\begin{tikzpicture}[scale=0.75]

\foreach \q [remember=\q as \p] in {1, 2, 3, 4}{

\begin{scope}[shift={(\q*3,0)}, rotate=30]
\path [nucleosome] 
    (0,1) 
    arc (90:270:0.375 and 1) -- (1.25,-1) 
    arc (270:90:0.375 and 1) -- cycle;
\path [top cylinder] 
    (1.625, 0) arc (0:360:0.375 and 1) -- cycle;

\begin{scope}[shift={(0.25,0)}]
\begin{pgfonlayer}{backwrapping}
\draw [wrapping] 
    (0.25, -1.125) 
    \foreach \i in {180,185,...,360}{ -- (\i/720+0.375*sin -\i, 1.125*cos \i)};
\draw [wrapping] (0, 1.125)  arc(90:0:0.125cm and 0.25cm) arc(0:-90:1cm and 1cm) coordinate (wrapping-start-\q);
\end{pgfonlayer}

\begin{pgfonlayer}{frontwrapping}
\draw [wrapping] 
    (0, 1.125)  
    \foreach \i in {0,5,...,180}{ -- (\i/720+0.375*sin -\i,1.125*cos \i)}
    [shift={(0.5,0)}]
    (0, 1.125) 
    \foreach \i in {0,5,...,150}{ -- (\i/720+0.375*sin -\i,1.125*cos \i)} coordinate (wrapping-end-\q);
\end{pgfonlayer}
\end{scope}
\ifnum\q>1
    \draw [wrapping] (wrapping-end-\p) .. controls ++(-60:0.5cm)  and ++(180:0.25cm) .. (wrapping-start-\q);
\fi
\ifnum\q=4
\draw [wrapping] (wrapping-end-\q) arc (210:270:1cm and 0.75cm);
\fi
\end{scope}
}

\end{tikzpicture}

\end{document}

I can't post an image but drawing the linking between adjacent nucleosomes was done by trial and error, so not ideal. I can `sort of' see how it could be done automatically, but I was too lazy.

EDIT by mwibrow. Removed (initially 0) as it is buggy in some PGF versions.


EDIT by JLDiaz. Since the author has not enough reputation to post an image, I'm doing so for him. In order to generate this image a small modification had to be done in the source code. The option (initially 0) was removed in the \foreach loop.

Result