Debian Codegraph @

texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.domains.tex

raw
1 %%
2 %% This is file `pgfmolbio.domains.tex',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% pgfmolbio.dtx (with options: `pmb-dom-tex')
8 %%
9 %% Copyright (C) 2024 by Wolfgang Esser-Skala
10 %%
11 %% This work may be distributed and/or modified under the
12 %% conditions of the LaTeX Project Public License, either version 1.3c
13 %% of this license or (at your option) any later version.
14 %% The latest version of this license is in
15 %% https://www.latex-project.org/lppl.txt
16 %% and version 1.3c or later is part of all distributions of LaTeX
17 %% version 2008/05/04 or later.
18 %%
19 \ProvidesFile{pgfmolbio.domains.tex}[2024/06/17 v0.21a Protein domains]
20
21
22 \ProvidesFile{pgfmolbio.domains.tex}[2012/10/01 v0.2 Protein Domains]
23
24 \ifluatex
25 \RequireLuaModule{pgfmolbio.domains}
26 \directlua{pmbSpecialKeys = pgfmolbio.domains.SpecialKeys:new()}
27 \fi
28
29 \def\@pmb@dom@keydef#1#2{%
30 \pgfkeyssetvalue{/pgfmolbio/domains/#1}{#2}%
31 }
32
33 \def\pmbdomvalueof#1{%
34 \pgfkeysvalueof{/pgfmolbio/domains/#1}%
35 }
36
37 \@pmb@dom@keydef{name}{Protein}
38 \newif\ifpmb@dom@showname
39 \pgfmolbioset[domains]{%
40 show name/.is if=pmb@dom@showname,
41 show name
42 }
43 \@pmb@dom@keydef{description}{}
44
45 \@pmb@dom@keydef{x unit}{.5mm}
46 \@pmb@dom@keydef{y unit}{6mm}
47 \@pmb@dom@keydef{residues per line}{200}
48 \@pmb@dom@keydef{baseline skip}{3}
49 \@pmb@dom@keydef{residue numbering}{auto}
50 \@pmb@dom@keydef{residue range}{auto-auto}
51 \@pmb@dom@keydef{enlarge left}{0cm}
52 \@pmb@dom@keydef{enlarge right}{0cm}
53 \@pmb@dom@keydef{enlarge top}{1cm}
54 \@pmb@dom@keydef{enlarge bottom}{0cm}
55
56 \pgfmolbioset[domains]{%
57 style/.code=\pgfmolbioset[domains]{current style/.style={#1}}
58 }
59
60 \@pmb@dom@keydef{domain font}{\footnotesize}
61
62 \@pmb@dom@keydef{level}{}
63 \@pmb@dom@keydef{disulfide base distance}{1}
64 \@pmb@dom@keydef{disulfide level distance}{.2}
65 \@pmb@dom@keydef{range font}{\sffamily\scriptsize}
66
67 \newif\ifpmb@dom@showruler
68 \pgfmolbioset[domains]{%
69 show ruler/.is if=pmb@dom@showruler,
70 show ruler
71 }
72 \@pmb@dom@keydef{ruler range}{auto-auto}
73 \@pmb@dom@keydef{default ruler step size}{50}
74 \@pmb@dom@keydef{ruler distance}{-.5}
75
76 \@pmb@dom@keydef{sequence}{}
77 \@pmb@dom@keydef{magnified sequence font}{\ttfamily\footnotesize}
78
79 \newif\ifpmb@dom@showsecstructure
80 \pgfmolbioset[domains]{%
81 show secondary structure/.is if=pmb@dom@showsecstructure,
82 show secondary structure=false
83 }
84 \@pmb@dom@keydef{secondary structure distance}{1}
85 \pgfmolbioset[domains]{%
86 helix back border color/.code=\colorlet{helix back border color}{#1},
87 helix back main color/.code=\colorlet{helix back main color}{#1},
88 helix back middle color/.code=\colorlet{helix back middle color}{#1},
89 helix front border color/.code=\colorlet{helix front border color}{#1},
90 helix front main color/.code=\colorlet{helix front main color}{#1},
91 helix front middle color/.code=\colorlet{helix front middle color}{#1},
92 helix back border color=white!50!black,
93 helix back main color=white!90!black,
94 helix back middle color=white,
95 helix front border color=red!50!black,
96 helix front main color=red!90!black,
97 helix front middle color=red!10!white
98 }
99
100 \@pmb@dom@keydef{sequence length}{}
101
102 \@pmb@dom@keydef{@layer}{}
103
104 \newcommand\setfeatureshape[2]{%
105 \expandafter\def\csname @pmb@dom@feature@#1@shape\endcsname{#2}%
106 }
107
108 \newcommand\setfeatureshapealias[2]{%
109 \expandafter\def\csname @pmb@dom@feature@#1@shape\endcsname{%
110 \@nameuse{@pmb@dom@feature@#2@shape}%
111 }%
112 }
113
114 \ifluatex
115 \newcommand\setfeaturestylealias[2]{%
116 \directlua{
117 if pmbProtein then
118 pmbProtein.specialKeys:aliasFeatureStyle("#1", "#2")
119 else
120 pmbSpecialKeys:aliasFeatureStyle("#1", "#2")
121 end
122 }%
123 }
124 \newcommand\setfeaturealias[2]{%
125 \setfeatureshapealias{#1}{#2}%
126 \setfeaturestylealias{#1}{#2}%
127 }
128 \else
129 \let\setfeaturealias\setfeatureshapealias%
130 \fi
131
132 \newcommand\pmbdomdrawfeature[1]{%
133 \@ifundefined{@pmb@dom@feature@#1@shape}{%
134 \PackageWarning{pgfmolbio}%
135 {Feature shape `#1' unknown, using `default'.}%
136 \@pmb@dom@feature@default@shape%
137 }{%
138 \@nameuse{@pmb@dom@feature@#1@shape}%
139 }%
140 }
141
142 \setfeatureshape{default}{%
143 \path [/pgfmolbio/domains/current style]
144 (\xLeft, \yMid + .5 * \pmbdomvalueof{y unit}) rectangle
145 (\xRight, \yMid - .5 * \pmbdomvalueof{y unit});
146 }
147
148 \setfeatureshape{domain}{
149 \draw [/pgfmolbio/domains/current style, rounded corners=2pt]
150 (\xLeft, \yMid + .5 * \pmbdomvalueof{y unit}) rectangle
151 (\xRight, \yMid - .5 * \pmbdomvalueof{y unit});
152 \node at (\xMid, \yMid)
153 {\pmbdomvalueof{domain font}{\pmbdomvalueof{description}}};
154 }
155 \setfeaturealias{DOMAIN}{domain}
156
157 \setfeatureshape{signal peptide}{%
158 \path [/pgfmolbio/domains/current style]
159 (\xLeft, \yMid + \pmbdomvalueof{y unit} / 5) rectangle
160 (\xRight, \yMid - \pmbdomvalueof{y unit} / 5);
161 }
162 \setfeaturealias{SIGNAL}{signal peptide}
163
164 \setfeatureshape{propeptide}{%
165 \path [/pgfmolbio/domains/current style]
166 (\xLeft, \yMid + .5 * \pmbdomvalueof{y unit}) rectangle
167 (\xRight, \yMid - .5 * \pmbdomvalueof{y unit});
168 }
169 \setfeaturealias{PROPEP}{propeptide}
170
171 \setfeatureshape{carbohydrate}{%
172 \draw [/pgfmolbio/domains/current style]
173 (\xMid, \yMid) --
174 (\xMid, \yMid + .7 * \pmbdomvalueof{y unit})
175 node [above] {\tiny\strut\pmbdomvalueof{description}};
176 \fill [/pgfmolbio/domains/current style]
177 (\xMid, \yMid + .7 * \pmbdomvalueof{y unit}) circle [radius=1pt];
178 }
179 \setfeaturealias{CARBOHYD}{carbohydrate}
180
181 \setfeatureshape{other/main chain}{%
182 \ifpmb@dom@showsecstructure%
183 \pgfmathsetmacro\yUpper{%
184 \yMid + \pmbdomvalueof{secondary structure distance}
185 * \pmbdomvalueof{y unit}%
186 }
187 \draw [thin]
188 (\xLeft, \yUpper pt) --
189 (\xRight, \yUpper pt);%
190 \fi%
191 \path [/pgfmolbio/domains/current style]
192 (\xLeft, \yMid) --
193 (\xRight, \yMid);%
194 }
195
196 \setfeatureshape{other/name}{%
197 \ifpmb@dom@showname%
198 \node [/pgfmolbio/domains/current style]
199 at (\xMid, \pmbdomvalueof{baseline skip} * \pmbdomvalueof{y unit})
200 {\pmbdomvalueof{name} (\pmbdomvalueof{sequence length} residues)};
201 \fi%
202 }
203
204 \setfeatureshape{disulfide}{%
205 \pgfmathsetmacro\yUpper{%
206 \yMid + (
207 \pmbdomvalueof{disulfide base distance} +
208 (\pmbdomvalueof{level} - 1) *
209 \pmbdomvalueof{disulfide level distance}
210 ) * \pmbdomvalueof{y unit}
211 }
212 \path [/pgfmolbio/domains/current style]
213 (\xLeft, \yMid) --
214 (\xLeft, \yUpper pt) --
215 (\xRight, \yUpper pt) --
216 (\xRight, \yMid);
217 }
218 \setfeaturealias{DISULFID}{disulfide}
219
220 \setfeatureshape{range}{%
221 \pgfmathsetmacro\yUpper{%
222 \yMid + (
223 \pmbdomvalueof{disulfide base distance} +
224 (\pmbdomvalueof{level} - 1) *
225 \pmbdomvalueof{disulfide level distance}
226 ) * \pmbdomvalueof{y unit}
227 }
228 \path [/pgfmolbio/domains/current style]
229 (\xLeft, \yUpper pt) --
230 (\xRight, \yUpper pt)
231 node [pos=.5, above]
232 {\pmbdomvalueof{range font}{\pmbdomvalueof{description}}};
233 }
234
235 \setfeatureshape{other/ruler}{%
236 \draw [/pgfmolbio/domains/current style]
237 (\xMid,
238 \yMid + \pmbdomvalueof{ruler distance} *
239 \pmbdomvalueof{y unit}) --
240 (\xMid,
241 \yMid + \pmbdomvalueof{ruler distance} *
242 \pmbdomvalueof{y unit} - 1mm)
243 node [below=-1mm] {\tiny\sffamily\strut\residueNumber};
244 }
245
246 \setfeatureshape{other/sequence}{%
247 \node [/pgfmolbio/domains/current style]
248 at (\xMid, \yMid) {\strut\currentResidue};
249 }
250
251 \newlength\pmb@magnifiedsequence@width
252
253 \setfeatureshape{other/magnified sequence above}{%
254 \settowidth\pmb@magnifiedsequence@width{%
255 \begin{pgfinterruptpicture}%
256 \pmbdomvalueof{magnified sequence font}%
257 \featureSequence%
258 \end{pgfinterruptpicture}%
259 }%
260 \pgfmathsetmacro\xUpperLeft{\xMid - \pmb@magnifiedsequence@width / 2}
261 \pgfmathsetmacro\xUpperRight{\xMid + \pmb@magnifiedsequence@width / 2}
262
263 \draw [/pgfmolbio/domains/current style]
264 (\xLeft, \yMid) --
265 (\xLeft, \yMid + \pmbdomvalueof{y unit} / 6) --
266 (\xUpperLeft pt, \yMid + \pmbdomvalueof{y unit} * 4/6) --
267 (\xUpperLeft pt, \yMid + \pmbdomvalueof{y unit} * 5/6)
268 (\xUpperRight pt, \yMid + \pmbdomvalueof{y unit} * 5/6) --
269 (\xUpperRight pt, \yMid + \pmbdomvalueof{y unit} * 4/6) --
270 (\xRight, \yMid + \pmbdomvalueof{y unit} / 6) --
271 (\xRight, \yMid);
272 \node [anchor=mid]
273 at (\xMid, \yMid + \pmbdomvalueof{y unit})
274 {\pmbdomvalueof{magnified sequence font}\featureSequence};
275 }
276
277 \setfeatureshape{other/magnified sequence below}{%
278 \settowidth\pmb@magnifiedsequence@width{%
279 \begin{pgfinterruptpicture}%
280 \pmbdomvalueof{magnified sequence font}%
281 \featureSequence%
282 \end{pgfinterruptpicture}%
283 }%
284 \pgfmathsetmacro\xLowerLeft{\xMid - \pmb@magnifiedsequence@width / 2}
285 \pgfmathsetmacro\xLowerRight{\xMid + \pmb@magnifiedsequence@width / 2}
286
287 \draw [/pgfmolbio/domains/current style]
288 (\xLeft, \yMid) --
289 (\xLeft, \yMid - \pmbdomvalueof{y unit} / 6) --
290 (\xLowerLeft pt, \yMid - \pmbdomvalueof{y unit}) --
291 (\xLowerLeft pt, \yMid - \pmbdomvalueof{y unit} * 7/6)
292 (\xLowerRight pt, \yMid - \pmbdomvalueof{y unit} * 7/6) --
293 (\xLowerRight pt, \yMid - \pmbdomvalueof{y unit}) --
294 (\xRight, \yMid - \pmbdomvalueof{y unit} / 6) --
295 (\xRight, \yMid);
296 \node [anchor=mid]
297 at (\xMid, \yMid - \pmbdomvalueof{y unit} * 8/6)
298 {\pmbdomvalueof{magnified sequence font}\featureSequence};
299 }
300
301 \newcommand\@pmb@dom@helixsegment[1]{%
302 svg [scale=#1] "%
303 c 0.30427 0
304 0.62523 0.59174
305 0.79543 0.96646
306 c 0.97673 2.15039
307 1.34005 4.49858
308 1.84538 6.6178
309 c 0.56155 2.35498
310 0.99602 4.514
311 1.82948 6.72355
312 c 0.11069 0.29346
313 0.23841 0.69219
314 0.56172 0.69219
315 l -5 0
316 c -0.27235 0.0237
317 -0.55793 -0.51373
318 -0.65225 -0.76773
319 c -0.98048 -2.64055
320 -1.40233 -5.46534
321 -2.06809 -8.00784
322 c -0.50047 -1.91127
323 -0.94696 -3.73368
324 -1.68631 -5.43929
325 c -0.14066 -0.3245
326 -0.34516 -0.78514
327 -0.69997 -0.78514
328 z"
329 }
330
331 \newcommand\@pmb@dom@helixhalfsegment[1]{%
332 svg [scale=#1] "%
333 c 0.50663 2.18926
334 0.96294 4.51494
335 1.78125 6.71875
336 c 0.09432 0.254
337 0.35265 0.80495
338 0.625 0.78125
339 l 5 0
340 c -0.32331 0
341 -0.45181 -0.42529
342 -0.5625 -0.71875
343 c -0.83346 -2.20955
344 -1.2822 -4.36377
345 -1.84375 -6.78125
346 l -5 0
347 z"
348 }
349
350 \pgfdeclareverticalshading[%
351 helix back border color,%
352 helix back main color,%
353 helix back middle color%
354 ]{helix half upper back}{100bp}{
355 color(0bp)=(helix back middle color);
356 color(5bp)=(helix back middle color);
357 color(45bp)=(helix back main color);
358 color(75bp)=(helix back border color);
359 color(100bp)=(helix back border color)
360 }
361
362 \pgfdeclareverticalshading[%
363 helix back border color,%
364 helix back main color,%
365 helix back middle color%
366 ]{helix half lower back}{100bp}{
367 color(0bp)=(helix back border color);
368 color(25bp)=(helix back border color);
369 color(35bp)=(helix back main color);
370 color(55bp)=(helix back middle color);
371 color(95bp)=(helix back main color);
372 color(100bp)=(helix back main color)
373 }
374
375 \pgfdeclareverticalshading[%
376 helix back border color,%
377 helix back main color,%
378 helix back middle color%
379 ]{helix full back}{100bp}{
380 color(0bp)=(helix back border color);
381 color(25bp)=(helix back border color);
382 color(30bp)=(helix back main color);
383 color(40bp)=(helix back middle color);
384 color(60bp)=(helix back main color);
385 color(75bp)=(helix back border color);
386 color(100bp)=(helix back border color)
387 }
388
389 \pgfdeclareverticalshading[%
390 helix front border color,%
391 helix front main color,%
392 helix front middle color%
393 ]{helix half upper front}{100bp}{
394 color(0bp)=(helix front main color);
395 color(5bp)=(helix front main color);
396 color(45bp)=(helix front middle color);
397 color(65bp)=(helix front main color);
398 color(75bp)=(helix front border color);
399 color(100bp)=(helix front border color)
400 }
401
402 \pgfdeclareverticalshading[%
403 helix front border color,%
404 helix front main color,%
405 helix front middle color%
406 ]{helix full front}{100bp}{
407 color(0bp)=(helix front border color);
408 color(25bp)=(helix front border color);
409 color(40bp)=(helix front main color);
410 color(60bp)=(helix front middle color);
411 color(70bp)=(helix front main color);
412 color(75bp)=(helix front border color);
413 color(100bp)=(helix front border color)
414 }
415
416 \setfeatureshape{helix/half upper back}{%
417 \ifpmb@dom@showsecstructure%
418 \pgfmathsetmacro\yShift{%
419 \pmbdomvalueof{secondary structure distance} *
420 \pmbdomvalueof{y unit}%
421 }
422 \draw [shading=helix half upper back]
423 (\xLeft, \yMid + \yShift pt)
424 \@pmb@dom@helixhalfsegment{\pmbdomvalueof{x unit} / 5};
425 \fi%
426 }
427
428 \setfeatureshape{helix/half lower back}{%
429 \ifpmb@dom@showsecstructure%
430 \pgfmathsetmacro\yShift{%
431 \pmbdomvalueof{secondary structure distance} *
432 \pmbdomvalueof{y unit}%
433 }
434 \draw [shading=helix half lower back]
435 (\xRight, \yMid + \yShift pt) [rotate=180]
436 \@pmb@dom@helixhalfsegment{\pmbdomvalueof{x unit} / 5};
437 \fi%
438 }
439
440 \setfeatureshape{helix/full back}{%
441 \ifpmb@dom@showsecstructure%
442 \pgfmathsetmacro\yShift{%
443 \pmbdomvalueof{secondary structure distance} *
444 \pmbdomvalueof{y unit}%
445 }
446 \draw [shading=helix full back]
447 (\xMid, \yLower + \yShift pt)
448 \@pmb@dom@helixsegment{\pmbdomvalueof{x unit} / 5};
449 \fi%
450 }
451
452 \setfeatureshape{helix/half upper front}{%
453 \ifpmb@dom@showsecstructure%
454 \pgfmathsetmacro\yShift{%
455 \pmbdomvalueof{secondary structure distance} *
456 \pmbdomvalueof{y unit}%
457 }
458 \draw [shading=helix half upper front]
459 (\xRight, \yMid + \yShift pt) [xscale=-1]
460 \@pmb@dom@helixhalfsegment{\pmbdomvalueof{x unit} / 5};
461 \fi%
462 }
463
464 \setfeatureshape{helix/full front}{%
465 \ifpmb@dom@showsecstructure%
466 \pgfmathsetmacro\yShift{%
467 \pmbdomvalueof{secondary structure distance} *
468 \pmbdomvalueof{y unit}%
469 }
470 \draw [shading=helix full front]
471 (\xMid, \yLower + \yShift pt) [xscale=-1]
472 \@pmb@dom@helixsegment{\pmbdomvalueof{x unit} / 5};
473 \fi%
474 }
475
476 \definecolor{strand left color}{RGB}{42,127,255}
477 \definecolor{strand right color}{RGB}{128,179,255}
478
479 \setfeatureshape{beta strand}{%
480 \ifpmb@dom@showsecstructure%
481 \pgfmathsetmacro\yShift{%
482 \pmbdomvalueof{secondary structure distance} *
483 \pmbdomvalueof{y unit}%
484 }
485 \draw [/pgfmolbio/domains/current style]
486 (\xLeft, \yMid + \pmbdomvalueof{x unit} + \yShift pt) --
487 (\xRight - 1.5 * \pmbdomvalueof{x unit},
488 \yMid + \pmbdomvalueof{x unit} + \yShift pt) --
489 (\xRight - 1.5 * \pmbdomvalueof{x unit},
490 \yMid + 1.5 * \pmbdomvalueof{x unit} + \yShift pt) --
491 (\xRight, \yMid + \yShift pt) --
492 (\xRight - 1.5 * \pmbdomvalueof{x unit},
493 \yMid - 1.5 * \pmbdomvalueof{x unit} + \yShift pt) --
494 (\xRight - 1.5 * \pmbdomvalueof{x unit},
495 \yMid - \pmbdomvalueof{x unit} + \yShift pt) --
496 (\xLeft, \yMid - \pmbdomvalueof{x unit} + \yShift pt) --
497 cycle;%
498 \fi%
499 }
500 \setfeaturealias{STRAND}{beta strand}
501
502 \setfeatureshape{beta turn}{%
503 \ifpmb@dom@showsecstructure%
504 \pgfmathsetmacro\yShift{%
505 \pmbdomvalueof{secondary structure distance} *
506 \pmbdomvalueof{y unit}%
507 }
508 \pgfmathsetmacro\turnXradius{(\xRight - \xLeft) / 2}%
509 \pgfmathsetmacro\turnYradius{\pmbdomvalueof{x unit} * 1.5}%
510 \fill [white]
511 (\xLeft, \yMid + 1mm + \yShift pt) rectangle
512 (\xRight, \yMid - 1mm + \yShift pt);%
513 \draw [/pgfmolbio/domains/current style]
514 (\xLeft - .5pt, \yMid + \yShift pt) --
515 (\xLeft, \yMid + \yShift pt) arc
516 [start angle=180, end angle=0,
517 x radius=\turnXradius pt, y radius=\turnYradius pt] --
518 (\xRight + .5pt, \yMid + \yShift pt);%
519 \fi%
520 }
521 \setfeaturealias{TURN}{beta turn}
522
523 \setfeatureshape{beta bridge}{%
524 \ifpmb@dom@showsecstructure%
525 \pgfmathsetmacro\yShift{%
526 \pmbdomvalueof{secondary structure distance} *
527 \pmbdomvalueof{y unit}%
528 }
529 \draw [/pgfmolbio/domains/current style]
530 (\xLeft, \yMid + .25 * \pmbdomvalueof{x unit} + \yShift pt) --
531 (\xRight - 1.5 * \pmbdomvalueof{x unit},
532 \yMid + .25 * \pmbdomvalueof{x unit} + \yShift pt) --
533 (\xRight - 1.5 * \pmbdomvalueof{x unit},
534 \yMid + 1.5 * \pmbdomvalueof{x unit} + \yShift pt) --
535 (\xRight, \yMid + \yShift pt) --
536 (\xRight - 1.5 * \pmbdomvalueof{x unit},
537 \yMid - 1.5 * \pmbdomvalueof{x unit} + \yShift pt) --
538 (\xRight - 1.5 * \pmbdomvalueof{x unit},
539 \yMid - .25 * \pmbdomvalueof{x unit} + \yShift pt) --
540 (\xLeft, \yMid - .25 * \pmbdomvalueof{x unit} + \yShift pt) --
541 cycle;%
542 \fi%
543 }
544
545 \setfeatureshape{bend}{%
546 \ifpmb@dom@showsecstructure%
547 \pgfmathsetmacro\yShift{%
548 \pmbdomvalueof{secondary structure distance} *
549 \pmbdomvalueof{y unit}%
550 }
551 \fill [white]
552 (\xLeft, \yMid + 1mm + \yShift pt) rectangle
553 (\xRight, \yMid - 1mm + \yShift pt);%
554 \draw [/pgfmolbio/domains/current style]
555 (\xLeft - .5pt, \yMid + \yShift pt) --
556 (\xLeft, \yMid + \yShift pt) --
557 (\xMid, \yMid + .5 * \pmbdomvalueof{y unit} + \yShift pt) --
558 (\xRight, \yMid + \yShift pt) --
559 (\xRight + .5pt, \yMid + \yShift pt);%
560 \fi%
561 }
562
563 \ifluatex\else\expandafter\endinput\fi
564
565 \newcommand\pmb@dom@inputuniprot[1]{%
566 \directlua{
567 pmbProtein:readUniprotFile("#1")
568 pmbProtein:getParameters()
569 pmbProtein:setParameters{
570 residueNumbering = "\pmbdomvalueof{residue numbering}"
571 }
572 }%
573 }
574
575 \newcommand\pmb@dom@inputgff[1]{%
576 \directlua{
577 pmbProtein:readGffFile("#1")
578 pmbProtein:setParameters{
579 residueNumbering = "\pmbdomvalueof{residue numbering}"
580 }
581 }%
582 }
583
584 \newcommand\pmb@dom@addfeature[4][]{%
585 \begingroup%
586 \pgfmolbioset[domains]{#1}%
587 \@pmb@toksa{#1}%
588 \directlua{
589 pmbProtein:addFeature{
590 key = "#2",
591 start = "#3",
592 stop = "#4",
593 kvList = "\luaescapestring{\the\@pmb@toksa}",
594 level = tonumber("\pmbdomvalueof{level}"),
595 layer = tonumber("\pmbdomvalueof{@layer}")
596 }
597 }%
598 \endgroup%
599 }
600
601 \newif\ifpmb@dom@tikzpicture
602
603 \newenvironment{pmbdomains}[2][]{%
604 \@ifundefined{useasboundingbox}%
605 {\pmb@dom@tikzpicturefalse\begin{tikzpicture}}%
606 {\pmb@dom@tikzpicturetrue}%
607 \pgfmolbioset[domains]{sequence length=#2, #1}%
608 \let\inputuniprot\pmb@dom@inputuniprot%
609 \let\inputgff\pmb@dom@inputgff%
610 \let\addfeature\pmb@dom@addfeature%
611 \directlua{
612 pmbProtein = pgfmolbio.domains.Protein:new()
613 pmbProtein.specialKeys =
614 pgfmolbio.domains.SpecialKeys:new(pmbSpecialKeys)
615 pmbProtein:setParameters{
616 sequenceLength = "\pmbdomvalueof{sequence length}"
617 }
618 pmbProtein:setParameters{
619 residueNumbering = "\pmbdomvalueof{residue numbering}"
620 }
621 }%
622 }{%
623 \pmb@dom@addfeature[@layer=1]{other/main chain}%
624 {(1)}{(\pmbdomvalueof{sequence length})}%
625 \@pmb@toksa=%
626 \expandafter\expandafter\expandafter\expandafter%
627 \expandafter\expandafter\expandafter{%
628 \pgfkeysvalueof{/pgfmolbio/domains/name}%
629 }%
630 \directlua{
631 pmbProtein:setParameters{
632 residueRange = "\pmbdomvalueof{residue range}",
633 defaultRulerStepSize = "\pmbdomvalueof{default ruler step size}"
634 }
635 pmbProtein:setParameters{
636 name = "\luaescapestring{\the\@pmb@toksa}",
637 xUnit = "\pmbdomvalueof{x unit}",
638 yUnit = "\pmbdomvalueof{y unit}",
639 residuesPerLine = "\pmbdomvalueof{residues per line}",
640 baselineSkip = "\pmbdomvalueof{baseline skip}",
641 showRuler = "\ifpmb@dom@showruler true\else false\fi",
642 rulerRange = "\pmbdomvalueof{ruler range}",
643 sequence = "\pmbdomvalueof{sequence}"
644 }
645 pmbProtein:calculateDisulfideLevels()
646 pgfmolbio.setCoordinateFormat(
647 "\pgfkeysvalueof{/pgfmolbio/coordinate unit}",
648 "\pgfkeysvalueof{/pgfmolbio/coordinate format string}"
649 )
650 \ifpmb@loadmodule@convert
651 local filename =
652 "\pgfkeysvalueof{/pgfmolbio/convert/output file name}"
653 if filename == "(auto)" then
654 filename = "pmbconverted" .. pgfmolbio.outputFileId
655 end
656 filename = filename ..
657 ".\pgfkeysvalueof{/pgfmolbio/convert/output file extension}"
658 outputFile, ioError = io.open(filename, "w")
659 if ioError then
660 tex.error(ioError)
661 end
662 \ifpmb@con@outputtikzcode
663 tex.sprint = function(a) outputFile:write(a) end
664 pmbProtein:getParameters()
665 tex.sprint("\string\n\string\\begin{tikzpicture}")
666 pmbProtein:printTikzDomains()
667 tex.sprint("\string\n\string\\end{tikzpicture}")
668 \else
669 \ifpmb@con@includedescription
670 pmbProtein.includeDescription = true
671 \fi
672 outputFile:write(tostring(pmbProtein))
673 \fi
674 outputFile:close()
675 pgfmolbio.outputFileId = pgfmolbio.outputFileId + 1
676 \else
677 pmbProtein:printTikzDomains()
678 \fi
679 pmbProtein = nil
680 }%
681 \ifpmb@dom@tikzpicture\else\end{tikzpicture}\fi%
682 }
683
684 \newcommand\setdisulfidefeatures[1]{%
685 \directlua{
686 if pmbProtein then
687 pmbProtein.specialKeys:clearKeys("disulfideKeys")
688 pmbProtein.specialKeys:setKeys("disulfideKeys", "#1", true)
689 else
690 pmbSpecialKeys:clearKeys("disulfideKeys")
691 pmbSpecialKeys:setKeys("disulfideKeys", "#1", true)
692 end
693 }%
694 }
695
696 \newcommand\adddisulfidefeatures[1]{%
697 \directlua{
698 if pmbProtein then
699 pmbProtein.specialKeys:setKeys("disulfideKeys", "#1", true)
700 else
701 pmbSpecialKeys:setKeys("disulfideKeys", "#1", true)
702 end
703 }%
704 }
705
706 \newcommand\removedisulfidefeatures[1]{%
707 \directlua{
708 if pmbProtein then
709 pmbProtein.specialKeys:setKeys("disulfideKeys", "#1", nil)
710 else
711 pmbSpecialKeys:setKeys("disulfideKeys", "#1", nil)
712 end
713 }%
714 }
715
716 \setdisulfidefeatures{DISULFID, disulfide, range}
717
718 \newcommand\setfeatureprintfunction[2]{%
719 \directlua{
720 if pmbProtein then
721 pmbProtein.specialKeys:setKeys("printFunctions", "#1", #2)
722 else
723 pmbSpecialKeys:setKeys("printFunctions", "#1", #2)
724 end
725 }%
726 }
727
728 \newcommand\removefeatureprintfunction[1]{%
729 \directlua{
730 if pmbProtein then
731 pmbProtein.specialKeys:setKeys("printFunctions", "#1", nil)
732 else
733 pmbSpecialKeys:setKeys("printFunctions", "#1", nil)
734 end
735 }%
736 }
737
738 \setfeatureprintfunction{other/sequence}%
739 {pgfmolbio.domains.printSequenceFeature}
740 \setfeatureprintfunction{alpha helix, pi helix, 310 helix, HELIX}%
741 {pgfmolbio.domains.printHelixFeature}
742
743 \newcommand\setfeaturestyle[2]{%
744 \@pmb@toksa{#2}%
745 \directlua{
746 if pmbProtein then
747 pmbProtein.specialKeys:setFeatureStyle(
748 "#1", "\luaescapestring{\the\@pmb@toksa}"
749 )
750 else
751 pmbSpecialKeys:setFeatureStyle(
752 "#1", "\luaescapestring{\the\@pmb@toksa}"
753 )
754 end
755 }%
756 }
757
758 \setfeaturestyle{default}{draw}
759 \setfeaturestyle{domain}%
760 {fill=Chartreuse,fill=LightSkyBlue,fill=LightPink,fill=Gold!50}
761 \setfeaturestyle{signal peptide}{fill=black}
762 \setfeaturestyle{propeptide}%
763 {*1{fill=Gold, opacity=.5, rounded corners=4pt}}
764 \setfeaturestyle{carbohydrate}{red}
765 \setfeaturestyle{other/main chain}{*1{draw, line width=2pt, black!25}}
766 \setfeaturestyle{other/name}{font=\sffamily}
767 \setfeaturestyle{disulfide}{draw=olive}
768 \setfeaturestyle{range}{*1{draw,decorate,decoration=brace}}
769 \setfeaturestyle{other/ruler}{black, black!50}
770 \setfeaturestyle{other/sequence}{*1{font=\ttfamily\tiny}}%
771 \setfeaturestyle{other/magnified sequence above}%
772 {*1{draw=black!50, densely dashed}}
773 \setfeaturestylealias{other/magnified sequence below}%
774 {other/magnified sequence above}
775 \setfeaturestyle{alpha helix}{%
776 *1{helix front border color=red!50!black,%
777 helix front main color=red!90!black,%
778 helix front middle color=red!10!white}%
779 }
780 \setfeaturestylealias{HELIX}{alpha helix}
781 \setfeaturestyle{pi helix}{%
782 *1{helix front border color=yellow!50!black,%
783 helix front main color=yellow!70!red,%
784 helix front middle color=yellow!10!white}%
785 }
786 \setfeaturestyle{310 helix}{%
787 *1{helix front border color=magenta!50!black,%
788 helix front main color=magenta!90!black,%
789 helix front middle color=magenta!10!white}%
790 }
791 \setfeaturestyle{beta strand}{%
792 *1{left color=strand left color, right color=strand right color}%
793 }
794 \setfeaturestyle{beta turn}{*1{draw=violet, thick}}
795 \setfeaturestyle{beta bridge}{*1{fill=MediumBlue}}
796 \setfeaturestyle{bend}{*1{draw=magenta, thick}}
797 \endinput
798 %%
799 %% End of file `pgfmolbio.domains.tex'.