-
Notifications
You must be signed in to change notification settings - Fork 0
/
tikzlibrarydna.code.tex
235 lines (205 loc) · 6.5 KB
/
tikzlibrarydna.code.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
%
% Copyright © 2021 by Timothy S. Jones
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Timothy S. Jones.
%
% This work consists of the file tikzlibrarydna.code.tex.
%
\ProvidesFile{tikzlibrarydna.code}[2021/06/15 v0.0.1 DNA diagrams using TikZ]
\pgfkeys{/dna/.cd,
coding sequence length/.initial=6mm,
}
\tikzset{
feature/.style={draw, transform shape},
coding sequence/.style={
feature,
shape=single arrow,
minimum height=6mm,
single arrow head extend=1mm,
anchor=west
},
ribosome binding site/.style={
feature,
shape=semicircle,
anchor=south,
yshift=-0.5\pgflinewidth,
inner sep=1pt,
fill=black
},
promoter/.style={
feature,
shape=promoter,
promoter arrow={Triangle[length=3pt,width=3pt]},
anchor=south west,
yshift=\pgflinewidth,
minimum height=2mm,
minimum width=2mm,
inner sep=0
},
terminator/.style={
feature,
shape=terminator,
anchor=south,
yshift=0.5\pgflinewidth,
minimum height=2mm,
minimum width=2mm,
inner sep=0
},
line cap=rect,
}%
% Most of the below is adapted from tikzlibrarygraphs.code.tex
\def\tikzdna@dnaplot{%
\pgfutil@ifnextchar[{\tikzdna@dnaplot@}{\tikzdna@dnaplot@[]}%
}%
% #1: \dnaplot [...]
% FIXME do something with #1
\def\tikzdna@dnaplot@[#1]{%
\pgfutil@ifnextchar f{\tikzdna@dnaplot@features}{%
\pgfutil@ifnextchar r{\tikzdna@dnaplot@regulation}{%
\tikzdna@dnaplot@features features%
}%
}%
}%
\def\tikzdna@dnaplot@features@done{%
}%
\def\tikzdna@dnaplot@features features{%
\pgfutil@ifnextchar[{\tikzdna@dnaplot@features@}{\tikzdna@dnaplot@features@[]}%
}%
% #1: \dnaplot features [...]
\def\tikzdna@dnaplot@features@[#1]{%
% FIXME set options with #1
\tikzdna@dnaplot@features@normal@main%
}%
\def\tikzdna@dnaplot@features@normal@main#1{%
\tikzdna@dnaplot@features@parse@group{#1}%
\tikzdna@dnaplot@main@done%
}%
\def\tikzdna@dnaplot@features@parse@group#1{%
\let\tikzdna@dnaplot@features@group@cont\pgfutil@empty%
\let\tikzdna@dnaplot@features@group@conta\pgfutil@empty%
\tikzdna@dnaplot@features@encloser#1[\pgf@stop@eogroup%
}%
%
% Replace ...[...]... by ...[{...}]...
%
\def\tikzdna@dnaplot@features@encloser{%
\tikzdna@dnaplot@features@encloser@%
}%
\def\tikzdna@dnaplot@features@encloser@#1[{%
\pgfutil@ifnextchar\pgf@stop@eogroup{%
\expandafter\tikzdna@dnaplot@features@semi\tikzdna@dnaplot@features@group@cont#1;%
}{%
\expandafter\def\expandafter\tikzdna@dnaplot@features@group@cont\expandafter{\tikzdna@dnaplot@features@group@cont#1[}%
\tikzdna@dnaplot@features@encloser@cont%
}%
}%
\def\tikzdna@dnaplot@features@encloser@cont#1]#2[{%
\pgfutil@ifnextchar\pgf@stop@eogroup{%
\expandafter\tikzdna@dnaplot@features@semi\tikzdna@dnaplot@features@group@cont{#1}]#2;}{%
\expandafter\def\expandafter\tikzdna@dnaplot@features@group@cont\expandafter{\tikzdna@dnaplot@features@group@cont{#1}]#2[}%
\tikzdna@dnaplot@features@encloser@cont}%
}%
%
% Replace ; by ,
%
\def\tikzdna@dnaplot@features@semi{%
\tikzdna@dnaplot@features@semi@%
}%
\def\tikzdna@dnaplot@features@semi@#1;{%
\pgfutil@ifnextchar\pgf@stop@eogroup{%
\expandafter\tikzdna@dnaplot@features@main@parser\tikzdna@dnaplot@features@group@conta#1,}{%
\expandafter\def\expandafter\tikzdna@dnaplot@features@group@conta\expandafter{\tikzdna@dnaplot@features@group@conta#1,}%
\tikzdna@dnaplot@features@semi%
}%
}%
\def\tikzdna@dnaplot@features@main@parser#1,{%
\tikzdna@dnaplot@features@grab@feature@type#1\pgf@stop\pgf@stop@eofeature%
% \tikz@lib@graph@stored@actions%
\pgfutil@ifnextchar\pgf@stop@eofeature{%
\tikzdna@dnaplot@features@feature@done%
}{%
% FIXME
}%
}%
\def\tikzdna@dnaplot@features@grab@feature@type{%
% FIXME implement foreach
% \pgfutil@ifnextchar\foreach\tikzdna@dnaplot@features@do@foreach\tikzdna@dnaplot@features@parse@type@text%
\tikzdna@dnaplot@features@parse@type@text%
}
%
% Get the type of the feature
%
\def\tikzdna@dnaplot@features@parse@type@text#1\pgf@stop{%
\tikzdna@dnaplot@features@parse@normal@feature#1[\pgf@stop%
}%
\def\tikzdna@dnaplot@features@parse@normal@feature#1[{%
\edef\pgf@marshal{\noexpand\pgfkeys@spdef\noexpand\tikzdna@dnaplot@features@type@only{#1}}%
\pgf@marshal%
% previously saved node text here
\edef\tikzdna@dnaplot@features@feature@type{\tikz@lib@graph@path\tikzdna@dnaplot@features@type@only}%
\tikzdna@dnaplot@features@handle@feature@cont%
}
\newif\iftikzgraphsautonumbernodes
\newcount\tikzdna@dnaplot@auto@number
\def\tikzdna@dnaplot@auto@sep{\space}%
\tikzset{
/tikzdna/.cd,%
}%
\def\tikzdna@dnaplot@features@do@autonumber{%
% FIXME do not overwrite \tikzdna@dnaplot@features@type@only here
% do we even need this
\ifx\tikzdna@dnaplot@features@type@only\pgfutil@empty%
\else%
\edef\tikzdna@dnaplot@features@type@only{\tikz@lib@graph@name@only\tikzdna@dnaplot@auto@sep\the\tikzdna@dnaplot@auto@number}%
\global\advance\tikzdna@dnaplot@auto@number by1\relax%
\fi%
}%
%
% We have now parsed everything up to the opening "[". We continue
%
\def\tikzdna@dnaplot@features@handle@feature@cont{%
% TODO
\iftikzgraphsautonumbernodes%
\tikz@lib@do@autonumber%
\fi%
\iftikz@lib@graph@fresh@node%
\tikz@lg@if@local@node{\tikz@lib@graph@name}{\tikz@lg@find@fresh@name}{}%
\fi%
\let\tikzgraphnodeas\tikzgraphnodeas@default%
\pgfutil@ifnextchar\pgf@stop{%
\ifx\tikz@lib@graph@name@only\pgfutil@empty%
\expandafter\tikz@lib@graph@node@empty@done%
\else
\expandafter\tikz@lib@graph@node@opt\expandafter[\expandafter]\expandafter[%
\fi%
}{\tikz@lib@graph@node@opt[}%
}%
\def\tikzdna@dnaplot@features@feature@done\pgf@stop@eofeature{%
% TODO
}%
\def\tikzdna@dnaplot@main@done{%
% TODO
}%
\def\tikzdna@dnaplot@regulation regulation{%
\pgfutil@ifnextchar[{\tikzdna@dnaplot@regulation@}{\tikzdna@dnaplot@regulation@[]}%
}%
\def\tikzdna@dnaplot@regulation@[#1]#2;{%
}%
\pgfutil@IfUndefined{tikzaddtikzonlycommandshortcutlet}{%
\def\tikzaddtikzonlycommandshortcutlet#1#2{%
\expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands%
\let#1=#2%
}%
}%
}{}%
\tikzaddtikzonlycommandshortcutlet\dnaplot\tikzdna@dnaplot%