Skip to content

Instantly share code, notes, and snippets.

@JungeAlexander
Last active August 29, 2015 14:02
Show Gist options
  • Save JungeAlexander/4f88d9eee15e5e4508c4 to your computer and use it in GitHub Desktop.
Save JungeAlexander/4f88d9eee15e5e4508c4 to your computer and use it in GitHub Desktop.
Secondary structure of a toy ncRNA sequence. A small example for vector graphics programming in LaTeX using the tikz package.
Display the source blob
Display the rendered blob
Raw
\documentclass{standalone} % Package 'standalone' allows to compile tikz images independently or to incorporate them into LaTeX documents
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
[nucl/.style={black, circle, draw=black, fill=black!10, minimum size=2em},
A/.style={nucl, fill=red!30},
G/.style={nucl, fill=blue!30},
C/.style={nucl, fill=green!30},
U/.style={nucl, fill=yellow!30},
molEnd/.style={fill=none, draw=none, minimum size=2em}]
% Secondary strcuture
\matrix (m2) [matrix of nodes, row sep=1.5em, column sep=1.5em, nodes=nucl, ampersand replacement=\&] {
% 1 2 3 4 5 6 7 8
\& \& \& \& \& |[C]| C \& |[C]| C \& \\ % 1
|[molEnd]| {5'} \& |[U]| U \& |[G]| G \& |[G]| G \& |[A]| A \& \& \& |[C]| C \\ % 2
|[molEnd]| {3'} \& |[A]| A \& |[C]| C \& |[C]| C \& |[U]| U \& \& \& |[A]| A \\ % 3
\& \& \& \& \& |[U]| U \& |[U]| U \& \\ % 4
};
% Backbone
\path
(m2-2-1) edge (m2-2-2)
(m2-2-2) edge (m2-2-3)
(m2-2-3) edge (m2-2-4)
(m2-2-4) edge (m2-2-5)
(m2-2-5) edge (m2-1-6)
(m2-1-6) edge (m2-1-7)
(m2-1-7) edge (m2-2-8)
(m2-2-8) edge (m2-3-8)
(m2-3-8) edge (m2-4-7)
(m2-4-7) edge (m2-4-6)
(m2-4-6) edge (m2-3-5)
(m2-3-5) edge (m2-3-4)
(m2-3-4) edge (m2-3-3)
(m2-3-3) edge (m2-3-2)
(m2-3-2) edge (m2-3-1);
% Basepairs
\path
(m2-2-2) edge (m2-3-2)
(m2-2-3) edge (m2-3-3)
(m2-2-4) edge (m2-3-4)
(m2-2-5) edge (m2-3-5);
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment