2
|
1 %!PS-Adobe-3.0 EPSF-3.0
|
|
2 %%Title: Sequence Logo : {$TITLE}
|
|
3 %%Creator: {$CREATOR}
|
|
4 %%CreationDate: {$CREATIONDATE}
|
|
5 %%BoundingBox: 0 0 {$LOGOWIDTHPOINTS} {$LOGOHEIGHTPOINTS}
|
|
6 %%Pages: 0
|
|
7 %%DocumentFonts:
|
|
8 %%EndComments
|
|
9
|
|
10 {$DESC}
|
|
11
|
|
12
|
|
13 % ---- CONSTANTS ----
|
|
14 /cmfactor 72 2.54 div def % defines points -> cm conversion
|
|
15 /cm {cmfactor mul} bind def % defines centimeters
|
|
16
|
|
17
|
|
18 % ---- VARIABLES ----
|
|
19
|
|
20 {$COLORDEF}
|
|
21
|
|
22 /logoWidth {$LOGOWIDTH} cm def
|
|
23 /logoHeight {$LOGOLINEHEIGHT} cm def
|
|
24 /logoTitle ({$TITLE}) def
|
|
25
|
|
26 /yaxis {$YAXIS} def
|
|
27 /yaxisLabel ({$YAXIS_LABEL}) def
|
|
28 /yaxisBits {$BARBITS} def % bits
|
|
29 /yaxisTicBits {$TICBITS} def
|
|
30
|
|
31
|
|
32 /xaxis {$NUMBERING} def
|
|
33 /xaxisLabel ({$XAXIS_LABEL}) def
|
|
34 /showEnds ({$SHOWENDS}) def % d: DNA, p: PROTEIN, -: none
|
|
35
|
|
36 /showFineprint true def
|
|
37 /fineprint ({$FINEPRINT}) def
|
|
38
|
|
39 /charsPerLine {$CHARSPERLINE} def
|
|
40 /logoLines {$LOGOLINES} def
|
|
41
|
|
42 /showingBox ({$SHOWINGBOX}) def %n s f
|
|
43 /shrinking {$SHRINKBOOLEAN} def
|
|
44 /shrink {$SHRINKFACTOR} def
|
|
45 /outline {$OUTLINE} def
|
|
46
|
|
47 /IbeamFraction {$ERRORBARFRACTION} def
|
|
48 /IbeamGray 0.50 def
|
|
49 /IbeamLineWidth 0.5 def
|
|
50
|
|
51 /fontsize 12 def
|
|
52 /titleFontsize 14 def
|
|
53 /smallFontsize 6 def
|
|
54
|
|
55 /defaultColor {$DEFAULT_COLOR} def
|
|
56
|
|
57 {$COLORDICT}
|
|
58
|
|
59 % Standard DNA/RNA color scheme
|
|
60 % /colorDict <<
|
|
61 % (G) orange
|
|
62 % (T) red
|
|
63 % (C) blue
|
|
64 % (A) green
|
|
65 % (U) red
|
|
66 % >> def
|
|
67
|
|
68 % Standard Amino Acid colors
|
|
69 %/colorDict <<
|
|
70 % (G) green
|
|
71 % (S) green
|
|
72 % (T) green
|
|
73 % (Y) green
|
|
74 % (C) green
|
|
75 % (N) purple
|
|
76 % (Q) purple
|
|
77 % (K) blue
|
|
78 % (R) blue
|
|
79 % (H) blue
|
|
80 % (D) red
|
|
81 % (E) red
|
|
82 % (P) black
|
|
83 % (A) black
|
|
84 % (W) black
|
|
85 % (F) black
|
|
86 % (L) black
|
|
87 % (I) black
|
|
88 % (M) black
|
|
89 % (V) black
|
|
90 %>> def
|
|
91
|
|
92
|
|
93
|
|
94 % ---- DERIVED PARAMETERS ----
|
|
95
|
|
96 /leftMargin
|
|
97 fontsize 3.5 mul
|
|
98
|
|
99 def
|
|
100
|
|
101 /bottomMargin
|
|
102 fontsize 0.75 mul
|
|
103
|
|
104 % Add extra room for axis
|
|
105 xaxis {fontsize 1.75 mul add } if
|
|
106 xaxisLabel () eq {} {fontsize 0.75 mul add} ifelse
|
|
107 def
|
|
108
|
|
109
|
|
110 /topMargin
|
|
111 logoTitle () eq { 10 }{titleFontsize 4 add} ifelse
|
|
112 def
|
|
113
|
|
114 /rightMargin
|
|
115 %Add extra room if showing ends
|
|
116 showEnds (-) eq { fontsize}{fontsize 1.5 mul} ifelse
|
|
117 def
|
|
118
|
|
119 /yaxisHeight
|
|
120 logoHeight
|
|
121 bottomMargin sub
|
|
122 topMargin sub
|
|
123 def
|
|
124
|
|
125 /ticWidth fontsize 2 div def
|
|
126
|
|
127 /pointsPerBit yaxisHeight yaxisBits div def
|
|
128
|
|
129 /isBoxed
|
|
130 showingBox (s) eq
|
|
131 showingBox (f) eq or {
|
|
132 true
|
|
133 } {
|
|
134 false
|
|
135 } ifelse
|
|
136 def
|
|
137
|
|
138 /stackMargin 1 def
|
|
139
|
|
140 % Do not add space aroung characters if characters are boxed
|
|
141 /charRightMargin
|
|
142 isBoxed { 0.0 } {stackMargin} ifelse
|
|
143 def
|
|
144
|
|
145 /charTopMargin
|
|
146 isBoxed { 0.0 } {stackMargin} ifelse
|
|
147 def
|
|
148
|
|
149 /charWidth
|
|
150 logoWidth
|
|
151 leftMargin sub
|
|
152 rightMargin sub
|
|
153 charsPerLine div
|
|
154 charRightMargin sub
|
|
155 def
|
|
156
|
|
157 /charWidth4 charWidth 4 div def
|
|
158 /charWidth2 charWidth 2 div def
|
|
159
|
|
160 /stackWidth
|
|
161 charWidth charRightMargin add
|
|
162 def
|
|
163
|
|
164 /numberFontsize
|
|
165 fontsize charWidth lt {fontsize}{charWidth} ifelse
|
|
166 def
|
|
167
|
|
168 % movements to place 5'/N and 3'/C symbols
|
|
169 /leftEndDeltaX fontsize neg def
|
|
170 /leftEndDeltaY fontsize 1.5 mul neg def
|
|
171 /rightEndDeltaX fontsize 0.25 mul def
|
|
172 /rightEndDeltaY leftEndDeltaY def
|
|
173
|
|
174 % Outline width is proporional to charWidth,
|
|
175 % but no less that 1 point
|
|
176 /outlinewidth
|
|
177 charWidth 32 div dup 1 gt {}{pop 1} ifelse
|
|
178 def
|
|
179
|
|
180
|
|
181 % ---- PROCEDURES ----
|
|
182
|
|
183 /StartLogo {
|
|
184 % Save state
|
|
185 save
|
|
186 gsave
|
|
187
|
|
188 % Print Logo Title, top center
|
|
189 gsave
|
|
190 SetTitleFont
|
|
191
|
|
192 logoWidth 2 div
|
|
193 logoTitle
|
|
194 stringwidth pop 2 div sub
|
|
195 logoHeight logoLines mul
|
|
196 titleFontsize sub
|
|
197 moveto
|
|
198
|
|
199 logoTitle
|
|
200 show
|
|
201 grestore
|
|
202
|
|
203 % Print X-axis label, bottom center
|
|
204 gsave
|
|
205 SetStringFont
|
|
206
|
|
207 logoWidth 2 div
|
|
208 xaxisLabel stringwidth pop 2 div sub
|
|
209 fontsize 3 div
|
|
210 moveto
|
|
211
|
|
212 xaxisLabel
|
|
213 show
|
|
214 grestore
|
|
215
|
|
216 % Show Fine Print
|
|
217 showFineprint {
|
|
218 gsave
|
|
219 SetSmallFont
|
|
220 logoWidth
|
|
221 fineprint stringwidth pop sub
|
|
222 smallFontsize sub
|
|
223 smallFontsize 3 div
|
|
224 moveto
|
|
225
|
|
226 fineprint show
|
|
227 grestore
|
|
228 } if
|
|
229
|
|
230 % Move to lower left corner of last line, first stack
|
|
231 leftMargin bottomMargin translate
|
|
232
|
|
233 % Move above first line ready for StartLine
|
|
234 0 logoLines logoHeight mul translate
|
|
235
|
|
236 SetLogoFont
|
|
237 } bind def
|
|
238
|
|
239 /EndLogo {
|
|
240 grestore
|
|
241 showpage
|
|
242 restore
|
|
243 } bind def
|
|
244
|
|
245
|
|
246 /StartLine{
|
|
247 % move down to the bottom of the line:
|
|
248 0 logoHeight neg translate
|
|
249
|
|
250 gsave
|
|
251 yaxis { MakeYaxis } if
|
|
252 xaxis { ShowLeftEnd } if
|
|
253 } bind def
|
|
254
|
|
255 /EndLine{
|
|
256 xaxis { ShowRightEnd } if
|
|
257 grestore
|
|
258 } bind def
|
|
259
|
|
260
|
|
261 /MakeYaxis {
|
|
262 gsave
|
|
263 stackMargin neg 0 translate
|
|
264 ShowYaxisBar
|
|
265 ShowYaxisLabel
|
|
266 grestore
|
|
267 } bind def
|
|
268
|
|
269
|
|
270 /ShowYaxisBar {
|
|
271 gsave
|
|
272 SetStringFont
|
|
273
|
|
274 /str 10 string def % string to hold number
|
|
275 /smallgap stackMargin 2 div def
|
|
276
|
|
277 % Draw first tic and bar
|
|
278 gsave
|
|
279 ticWidth neg 0 moveto
|
|
280 ticWidth 0 rlineto
|
|
281 0 yaxisHeight rlineto
|
|
282 stroke
|
|
283 grestore
|
|
284
|
|
285
|
|
286 % Draw the tics
|
|
287 % initial increment limit proc for
|
|
288 0 yaxisTicBits yaxisBits abs %cvi
|
|
289 {/loopnumber exch def
|
|
290
|
|
291 % convert the number coming from the loop to a string
|
|
292 % and find its width
|
|
293 loopnumber 10 str cvrs
|
|
294 /stringnumber exch def % string representing the number
|
|
295
|
|
296 stringnumber stringwidth pop
|
|
297 /numberwidth exch def % width of number to show
|
|
298
|
|
299 /halfnumberheight
|
|
300 stringnumber CharBoxHeight 2 div
|
|
301 def
|
|
302
|
|
303 numberwidth % move back width of number
|
|
304 neg loopnumber pointsPerBit mul % shift on y axis
|
|
305 halfnumberheight sub % down half the digit
|
|
306
|
|
307 moveto % move back the width of the string
|
|
308
|
|
309 ticWidth neg smallgap sub % Move back a bit more
|
|
310 0 rmoveto % move back the width of the tic
|
|
311
|
|
312 stringnumber show
|
|
313 smallgap 0 rmoveto % Make a small gap
|
|
314
|
|
315 % now show the tic mark
|
|
316 0 halfnumberheight rmoveto % shift up again
|
|
317 ticWidth 0 rlineto
|
|
318 stroke
|
|
319 } for
|
|
320 grestore
|
|
321 } bind def
|
|
322
|
|
323 /ShowYaxisLabel {
|
|
324 gsave
|
|
325 SetStringFont
|
|
326
|
|
327 % How far we move left depends on the size of
|
|
328 % the tic labels.
|
|
329 /str 10 string def % string to hold number
|
|
330 yaxisBits yaxisTicBits div cvi yaxisTicBits mul
|
|
331 str cvs stringwidth pop
|
|
332 ticWidth 1.5 mul add neg
|
|
333
|
|
334
|
|
335 yaxisHeight
|
|
336 yaxisLabel stringwidth pop
|
|
337 sub 2 div
|
|
338
|
|
339 translate
|
|
340 90 rotate
|
|
341 0 0 moveto
|
|
342 yaxisLabel show
|
|
343 grestore
|
|
344 } bind def
|
|
345
|
|
346
|
|
347 /StartStack { % <stackNumber> startstack
|
|
348 xaxis {MakeNumber}{pop} ifelse
|
|
349 gsave
|
|
350 } bind def
|
|
351
|
|
352 /EndStack {
|
|
353 grestore
|
|
354 stackWidth 0 translate
|
|
355 } bind def
|
|
356
|
|
357
|
|
358 % Draw a character whose height is proportional to symbol bits
|
|
359 /MakeSymbol{ % charbits character MakeSymbol
|
|
360 gsave
|
|
361 /char exch def
|
|
362 /bits exch def
|
|
363
|
|
364 /bitsHeight
|
|
365 bits pointsPerBit mul
|
|
366 def
|
|
367
|
|
368 /charHeight
|
|
369 bitsHeight charTopMargin sub
|
|
370 dup
|
|
371 0.0 gt {}{pop 0.0} ifelse % if neg replace with zero
|
|
372 def
|
|
373
|
|
374 charHeight 0.0 gt {
|
|
375 char SetColor
|
|
376 charWidth charHeight char ShowChar
|
|
377
|
|
378 showingBox (s) eq { % Unfilled box
|
|
379 0 0 charWidth charHeight false ShowBox
|
|
380 } if
|
|
381
|
|
382 showingBox (f) eq { % Filled box
|
|
383 0 0 charWidth charHeight true ShowBox
|
|
384 } if
|
|
385
|
|
386 } if
|
|
387
|
|
388 grestore
|
|
389
|
|
390 0 bitsHeight translate
|
|
391 } bind def
|
|
392
|
|
393
|
|
394 /ShowChar { % <width> <height> <char> ShowChar
|
|
395 gsave
|
|
396 /tc exch def % The character
|
|
397 /ysize exch def % the y size of the character
|
|
398 /xsize exch def % the x size of the character
|
|
399
|
|
400 /xmulfactor 1 def
|
|
401 /ymulfactor 1 def
|
|
402
|
|
403
|
|
404 % if ysize is negative, make everything upside down!
|
|
405 ysize 0 lt {
|
|
406 % put ysize normal in this orientation
|
|
407 /ysize ysize abs def
|
|
408 xsize ysize translate
|
|
409 180 rotate
|
|
410 } if
|
|
411
|
|
412 shrinking {
|
|
413 xsize 1 shrink sub 2 div mul
|
|
414 ysize 1 shrink sub 2 div mul translate
|
|
415
|
|
416 shrink shrink scale
|
|
417 } if
|
|
418
|
|
419 % Calculate the font scaling factors
|
|
420 % Loop twice to catch small correction due to first scaling
|
|
421 2 {
|
|
422 gsave
|
|
423 xmulfactor ymulfactor scale
|
|
424
|
|
425 ysize % desired size of character in points
|
|
426 tc CharBoxHeight
|
|
427 dup 0.0 ne {
|
|
428 div % factor by which to scale up the character
|
|
429 /ymulfactor exch def
|
|
430 } % end if
|
|
431 {pop pop}
|
|
432 ifelse
|
|
433
|
|
434 xsize % desired size of character in points
|
|
435 tc CharBoxWidth
|
|
436 dup 0.0 ne {
|
|
437 div % factor by which to scale up the character
|
|
438 /xmulfactor exch def
|
|
439 } % end if
|
|
440 {pop pop}
|
|
441 ifelse
|
|
442 grestore
|
|
443 } repeat
|
|
444
|
|
445 % Adjust horizontal position if the symbol is an I
|
|
446 tc (I) eq {
|
|
447 charWidth 2 div % half of requested character width
|
|
448 tc CharBoxWidth 2 div % half of the actual character
|
|
449 sub 0 translate
|
|
450 % Avoid x scaling for I
|
|
451 /xmulfactor 1 def
|
|
452 } if
|
|
453
|
|
454
|
|
455 % ---- Finally, draw the character
|
|
456
|
|
457 newpath
|
|
458 xmulfactor ymulfactor scale
|
|
459
|
|
460 % Move lower left corner of character to start point
|
|
461 tc CharBox pop pop % llx lly : Lower left corner
|
|
462 exch neg exch neg
|
|
463 moveto
|
|
464
|
|
465 outline { % outline characters:
|
|
466 outlinewidth setlinewidth
|
|
467 tc true charpath
|
|
468 gsave 1 setgray fill grestore
|
|
469 clip stroke
|
|
470 } { % regular characters
|
|
471 tc show
|
|
472 } ifelse
|
|
473
|
|
474 grestore
|
|
475 } bind def
|
|
476
|
|
477
|
|
478 /ShowBox { % x1 y1 x2 y2 filled ShowBox
|
|
479 gsave
|
|
480 /filled exch def
|
|
481 /y2 exch def
|
|
482 /x2 exch def
|
|
483 /y1 exch def
|
|
484 /x1 exch def
|
|
485 newpath
|
|
486 x1 y1 moveto
|
|
487 x2 y1 lineto
|
|
488 x2 y2 lineto
|
|
489 x1 y2 lineto
|
|
490 closepath
|
|
491
|
|
492 clip
|
|
493
|
|
494 filled {
|
|
495 fill
|
|
496 }{
|
|
497 0 setgray stroke
|
|
498 } ifelse
|
|
499
|
|
500 grestore
|
|
501 } bind def
|
|
502
|
|
503
|
|
504 /MakeNumber { % number MakeNumber
|
|
505 gsave
|
|
506 SetNumberFont
|
|
507 stackWidth 0 translate
|
|
508 90 rotate % rotate so the number fits
|
|
509 dup stringwidth pop % find the length of the number
|
|
510 neg % prepare for move
|
|
511 stackMargin sub % Move back a bit
|
|
512 charWidth (0) CharBoxHeight % height of numbers
|
|
513 sub 2 div %
|
|
514 moveto % move back to provide space
|
|
515 show
|
|
516 grestore
|
|
517 } bind def
|
|
518
|
|
519
|
|
520 /Ibeam{ % heightInBits Ibeam
|
|
521 gsave
|
|
522 % Make an Ibeam of twice the given height in bits
|
|
523 /height exch pointsPerBit mul def
|
|
524 /heightDRAW height IbeamFraction mul def
|
|
525
|
|
526 IbeamLineWidth setlinewidth
|
|
527 IbeamGray setgray
|
|
528
|
|
529 charWidth2 height neg translate
|
|
530 ShowIbar
|
|
531 newpath
|
|
532 0 0 moveto
|
|
533 0 heightDRAW rlineto
|
|
534 stroke
|
|
535 newpath
|
|
536 0 height moveto
|
|
537 0 height rmoveto
|
|
538 currentpoint translate
|
|
539 ShowIbar
|
|
540 newpath
|
|
541 0 0 moveto
|
|
542 0 heightDRAW neg rlineto
|
|
543 currentpoint translate
|
|
544 stroke
|
|
545 grestore
|
|
546 } bind def
|
|
547
|
|
548
|
|
549 /ShowIbar { % make a horizontal bar
|
|
550 gsave
|
|
551 newpath
|
|
552 charWidth4 neg 0 moveto
|
|
553 charWidth4 0 lineto
|
|
554 stroke
|
|
555 grestore
|
|
556 } bind def
|
|
557
|
|
558
|
|
559 /ShowLeftEnd {
|
|
560 gsave
|
|
561 SetStringFont
|
|
562 leftEndDeltaX leftEndDeltaY moveto
|
|
563 showEnds (d) eq {(5) show ShowPrime} if
|
|
564 showEnds (p) eq {(N) show} if
|
|
565 grestore
|
|
566 } bind def
|
|
567
|
|
568
|
|
569 /ShowRightEnd {
|
|
570 gsave
|
|
571 SetStringFont
|
|
572 rightEndDeltaX rightEndDeltaY moveto
|
|
573 showEnds (d) eq {(3) show ShowPrime} if
|
|
574 showEnds (p) eq {(C) show} if
|
|
575 grestore
|
|
576 } bind def
|
|
577
|
|
578
|
|
579 /ShowPrime {
|
|
580 gsave
|
|
581 SetPrimeFont
|
|
582 (\242) show
|
|
583 grestore
|
|
584 } bind def
|
|
585
|
|
586
|
|
587 /SetColor{ % <char> SetColor
|
|
588 dup colorDict exch known {
|
|
589 colorDict exch get aload pop setrgbcolor
|
|
590 } {
|
|
591 pop
|
|
592 defaultColor aload pop setrgbcolor
|
|
593 } ifelse
|
|
594 } bind def
|
|
595
|
|
596 % define fonts
|
|
597 /SetTitleFont {/Times-Bold findfont titleFontsize scalefont setfont} bind def
|
|
598 /SetLogoFont {/Helvetica-Narrow-Bold findfont charWidth scalefont setfont} bind def
|
|
599 /SetStringFont{/Helvetica-Bold findfont fontsize scalefont setfont} bind def
|
|
600 /SetPrimeFont {/Symbol findfont fontsize scalefont setfont} bind def
|
|
601 /SetSmallFont {/Helvetica findfont smallFontsize scalefont setfont} bind def
|
|
602
|
|
603 /SetNumberFont {
|
|
604 /Helvetica-Bold findfont
|
|
605 numberFontsize
|
|
606 scalefont
|
|
607 setfont
|
|
608 } bind def
|
|
609
|
|
610 %Take a single character and return the bounding box
|
|
611 /CharBox { % <char> CharBox <lx> <ly> <ux> <uy>
|
|
612 gsave
|
|
613 newpath
|
|
614 0 0 moveto
|
|
615 % take the character off the stack and use it here:
|
|
616 true charpath
|
|
617 flattenpath
|
|
618 pathbbox % compute bounding box of 1 pt. char => lx ly ux uy
|
|
619 % the path is here, but toss it away ...
|
|
620 grestore
|
|
621 } bind def
|
|
622
|
|
623
|
|
624 % The height of a characters bounding box
|
|
625 /CharBoxHeight { % <char> CharBoxHeight <num>
|
|
626 CharBox
|
|
627 exch pop sub neg exch pop
|
|
628 } bind def
|
|
629
|
|
630
|
|
631 % The width of a characters bounding box
|
|
632 /CharBoxWidth { % <char> CharBoxHeight <num>
|
|
633 CharBox
|
|
634 pop exch pop sub neg
|
|
635 } bind def
|
|
636
|
|
637
|
|
638 % Deprecated names
|
|
639 /startstack {StartStack} bind def
|
|
640 /endstack {EndStack} bind def
|
|
641 /makenumber {MakeNumber} bind def
|
|
642 /numchar { MakeSymbol } bind def
|
|
643
|
|
644 %%EndProlog
|
|
645
|
|
646 %%Page: 1 1
|
|
647 StartLogo
|
|
648 StartLine % line number 1
|
|
649
|
|
650 {$DATA}
|
|
651
|
|
652 EndLine
|
|
653 EndLogo
|
|
654
|
|
655 %%EOF
|
|
656
|
|
657
|
|
658
|
|
659
|
|
660
|
|
661
|
|
662
|
|
663
|
|
664
|
|
665
|
|
666
|
|
667
|
|
668
|
|
669
|
|
670
|
|
671
|
|
672
|
|
673
|
|
674
|