Debian Codegraph @

weblogo/template.eps

raw
1 %!PS-Adobe-3.0 EPSF-3.0
2 %%Title: Sequence Logo: ${logo_title}
3 %%Creator: ${creator_text}
4 %%CreationDate: ${creation_date}
5 %%BoundingBox: 0 0 ${logo_width} ${logo_height}
6 %%Pages: 0
7 %%DocumentFonts:
8 %%EndComments
9
10
11 % ---- VARIABLES ----
12
13 /True true def
14 /False false def
15
16 /debug ${debug} def
17
18 /logo_height ${logo_height} def
19 /logo_width ${logo_width} def
20 /logo_title (${logo_title}) def
21 /show_title ${show_title} def
22
23 /logo_margin ${logo_margin} def
24 /xaxis_label_height ${xaxis_label_height} def
25 /title_height ${title_height} def
26 /stroke_width ${stroke_width} def
27 /tic_length ${tic_length} def
28
29 /lines_per_logo ${lines_per_logo} def
30 /line_width ${line_width} def
31 /line_height ${line_height} def
32 /line_margin_left ${line_margin_left} def
33 /line_margin_right ${line_margin_right} def
34 /line_margin_bottom ${line_margin_bottom} def
35 /line_margin_top ${line_margin_top} def
36
37 /stack_width ${stack_width} def
38 /stack_height ${stack_height} def
39 /stacks_per_line ${stacks_per_line} def
40 /stack_margin ${stack_margin} def
41
42 /show_yaxis ${show_yaxis} def
43 /show_yaxis_label ${show_yaxis_label} def
44 /yaxis_label (${yaxis_label}) def
45 /yaxis_scale ${yaxis_scale} def % height in units
46 /yaxis_tic_interval ${yaxis_tic_interval} def % in units
47 /yaxis_minor_tic_interval ${yaxis_minor_tic_interval} def % in units
48
49 /show_xaxis_label ${show_xaxis_label} def % True or False
50 /show_xaxis ${show_xaxis} def % True or False
51 /xaxis_label (${xaxis_label}) def
52 /xaxis_tic_interval ${xaxis_tic_interval} def
53 /rotate_numbers ${rotate_numbers} def % True or False
54 /number_interval ${number_interval} def
55 /show_ends ${show_ends} def
56 /end_type (${end_type}) def % d: DNA, p: PROTEIN, -: none
57
58 /show_fineprint ${show_fineprint} def
59 /fineprint (${fineprint}) def
60 /logo_label (${logo_label}) def
61
62 /show_boxes ${show_boxes} def % True or False
63 /shrink ${shrink} def % True or False
64 /shrink_fraction ${shrink_fraction} def
65
66 /show_errorbars ${show_errorbars} def % True or False
67 /errorbar_fraction ${errorbar_fraction} def
68 /errorbar_width_fraction ${errorbar_width_fraction} def
69 /errorbar_gray ${errorbar_gray} def
70
71 /fontsize ${fontsize} def
72 /small_fontsize ${small_fontsize} def
73 /title_fontsize ${title_fontsize} def
74 /number_fontsize ${number_fontsize} def
75
76
77 /UseCIEColor true def % Fix for issue 4
78 /default_color ${default_color} def
79
80
81 % ---- DERIVED PARAMETERS ----
82
83 /char_width stack_width 2 stack_margin mul sub def
84 /char_width2 char_width 2 div def
85 /char_width4 char_width 4 div def
86
87 % movements to place 5'/N and 3'/C symbols
88 /leftEndDeltaX fontsize neg def
89 /leftEndDeltaY fontsize 1.25 mul neg def
90 /rightEndDeltaX fontsize 0.25 mul def
91 /rightEndDeltaY leftEndDeltaY def
92
93
94 % ---- PROCEDURES ----
95
96
97 /SetTitleFont {/${title_font} findfont title_fontsize scalefont setfont} bind def
98 /SetLogoFont {/${logo_font} findfont char_width scalefont setfont} bind def
99 /SetStringFont{/${text_font} findfont fontsize scalefont setfont} bind def
100 /SetPrimeFont {/Symbol findfont fontsize scalefont setfont} bind def
101 /SetSmallFont {/${text_font} findfont small_fontsize scalefont setfont} bind def
102 /SetNumberFont {/${text_font} findfont number_fontsize scalefont setfont} bind def
103
104 /DrawBox { % width height
105 /hh exch def
106 /ww exch def
107 gsave
108 0.2 setlinewidth
109 %0.5 setgray
110
111 %0 0 moveto
112 hh 0 rlineto
113 0 ww rlineto
114 hh neg 0 rlineto
115 0 ww neg rlineto
116 stroke
117 grestore
118 } bind def
119
120
121 /StartLogo {
122 %save
123 gsave
124
125
126 debug {
127 logo_margin logo_margin moveto
128 logo_height logo_margin 2 mul sub
129 logo_width logo_margin 2 mul sub
130 DrawBox } if
131
132 show_title { DrawTitle } if
133 show_xaxis_label { DrawXaxisLable } if
134 show_fineprint { DrawFineprint } if
135 DrawLogoLabel
136
137
138 MoveToFirstLine
139 } bind def
140
141
142 /DrawLogoLabel {
143 gsave
144 SetTitleFont
145
146 logo_margin
147 logo_height title_fontsize sub logo_margin sub
148 moveto
149
150 debug { title_fontsize logo_label stringwidth pop DrawBox } if
151 0 title_fontsize 4 div rmoveto % Move up to baseline (approximatly)
152 logo_label show
153
154 grestore
155 } bind def
156
157 /DrawTitle {
158 gsave
159 SetTitleFont
160
161 logo_width 2 div logo_title stringwidth pop 2 div sub
162 logo_height title_fontsize sub logo_margin sub
163 moveto
164
165 debug { title_fontsize logo_title stringwidth pop DrawBox } if
166
167 0 title_fontsize 4 div rmoveto % Move up to baseline (approximatly)
168 logo_title show
169
170 grestore
171 } bind def
172
173 /DrawXaxisLable {
174 % Print X-axis label, bottom center
175 gsave
176 SetStringFont
177
178 logo_width 2 div xaxis_label stringwidth pop 2 div sub
179 xaxis_label_height logo_margin add fontsize sub
180 moveto
181 %fontsize 3 div
182
183 debug { fontsize xaxis_label stringwidth pop DrawBox } if
184
185 xaxis_label show
186
187 grestore
188 } bind def
189
190
191 /DrawFineprint {
192 gsave
193
194 SetSmallFont
195
196 logo_width fineprint stringwidth pop sub
197 logo_margin sub line_margin_right sub
198 logo_margin
199 moveto
200
201 debug { small_fontsize fineprint stringwidth pop DrawBox } if
202
203 fineprint show
204 grestore
205 } bind def
206
207 /MoveToFirstLine {
208 logo_margin
209 logo_height logo_margin sub title_height sub line_height sub
210 moveto
211 } bind def
212
213 /EndLogo {
214 grestore
215 %showpage
216 %restore
217 } bind def
218
219
220 /StartLine{
221 gsave
222
223 % Draw outer box
224 debug { line_height line_width DrawBox } if
225
226 % Move to lower left corner of content area
227 line_margin_left line_margin_bottom rmoveto
228
229 % Draw inner content box
230 debug {
231 line_height line_margin_bottom sub line_margin_top sub
232 line_width line_margin_left sub line_margin_right sub
233 DrawBox
234 } if
235
236 show_yaxis { DrawYaxis } if
237 show_xaxis { DrawLeftEnd } if
238
239 } bind def
240
241 /EndLine{
242 show_xaxis { DrawRightEnd } if
243 grestore
244 0 line_height neg rmoveto
245 } bind def
246
247
248 /DrawYaxis {
249 gsave
250 stack_margin neg 0 translate
251 DrawYaxisBar
252 DrawYaxisLabel
253 grestore
254 } bind def
255
256
257 /DrawYaxisBar {
258 gsave
259 stack_margin neg 0 rmoveto
260
261 SetNumberFont
262 stroke_width setlinewidth
263
264 /str 10 string def % string to hold number
265 /smallgap stack_margin def
266
267 % Draw first tic and bar
268 gsave
269 tic_length neg 0 rmoveto
270 tic_length 0 rlineto
271 0 stack_height rlineto
272 stroke
273 grestore
274
275 % Draw the tics
276 % initial increment limit proc for
277 0 yaxis_tic_interval yaxis_scale abs
278 {/loopnumber exch def
279
280 % convert the number coming from the loop to a string
281 % and find its width
282 loopnumber 10 str cvrs
283 /stringnumber exch def % string representing the number
284
285 stringnumber stringwidth pop
286 /numberwidth exch def % width of number to show
287
288 /halfnumberheight
289 stringnumber CharBoxHeight 2 div
290 def
291
292 gsave
293 numberwidth % move back width of number
294 neg loopnumber stack_height yaxis_scale div mul % shift on y axis
295 halfnumberheight sub % down half the digit
296 rmoveto % move back the width of the string
297
298 tic_length neg smallgap sub % Move back a bit more
299 0 rmoveto % move back the width of the tic
300
301 stringnumber show
302 smallgap 0 rmoveto % Make a small gap
303
304 % now show the tic mark
305 0 halfnumberheight rmoveto % shift up again
306 tic_length 0 rlineto
307 stroke
308 grestore
309 } for
310
311 % Draw the minor tics
312 % initial increment limit proc for
313 0 yaxis_minor_tic_interval yaxis_scale abs
314 {/loopnumber2 exch def
315 gsave
316 0
317 loopnumber2 stack_height yaxis_scale div mul
318 rmoveto
319
320 tic_length 2 div neg 0 rlineto
321 stroke
322 grestore
323 } for
324
325 grestore
326 } bind def
327
328 /DrawYaxisLabel {
329 gsave
330 SetStringFont
331
332 % How far we move left depends on the size of
333 % the tic labels.
334 /str 10 string def % string to hold number
335 yaxis_scale yaxis_tic_interval div cvi yaxis_tic_interval mul
336 str cvs stringwidth pop
337 tic_length 1.25 mul add neg
338
339 stack_height
340 yaxis_label stringwidth pop
341 sub 2 div
342
343 rmoveto
344 90 rotate
345
346 yaxis_label show
347 grestore
348 } bind def
349
350
351 %Take a single character and return the bounding box
352 /CharBox { % <char> CharBox <lx> <ly> <ux> <uy>
353 gsave
354 newpath
355 0 0 moveto
356 % take the character off the stack and use it here:
357 true charpath
358 flattenpath
359 pathbbox % compute bounding box of 1 pt. char => lx ly ux uy
360 % the path is here, but toss it away ...
361 grestore
362 } bind def
363
364
365 % The height of a characters bounding box
366 /CharBoxHeight { % <char> CharBoxHeight <num>
367 CharBox
368 exch pop sub neg exch pop
369 } bind def
370
371
372 % The width of a characters bounding box
373 /CharBoxWidth { % <char> CharBoxHeight <num>
374 CharBox
375 pop exch pop sub neg
376 } bind def
377
378
379 /DrawLeftEnd {
380 gsave
381 SetStringFont
382 leftEndDeltaX leftEndDeltaY rmoveto
383
384 show_ends {
385 debug { leftEndDeltaY neg leftEndDeltaX neg DrawBox } if
386 end_type (d) eq {(5) show DrawPrime} if
387 end_type (p) eq {(N) show} if
388 } if
389 grestore
390 } bind def
391
392 /DrawRightEnd {
393 gsave
394 SetStringFont
395 rightEndDeltaX rightEndDeltaY rmoveto
396
397 show_ends {
398 debug { rightEndDeltaY neg leftEndDeltaX neg DrawBox } if
399 end_type (d) eq {(3) show DrawPrime} if
400 end_type (p) eq {(C) show} if
401 } if
402 grestore
403 } bind def
404
405 /DrawPrime {
406 gsave
407 SetPrimeFont
408 (\242) show
409 grestore
410 } bind def
411
412
413 /StartStack { % <stackNumber> startstack
414 show_xaxis {DrawNumber}{pop} ifelse
415 gsave
416 debug { stack_height stack_width DrawBox } if
417
418 } bind def
419
420 /EndStack {
421 grestore
422 stack_width 0 rmoveto
423 } bind def
424
425
426 /DrawNumber { % number MakeNumber
427 /n exch def
428
429
430 gsave
431 %0 stack_margin neg rmoveto
432 stroke_width setlinewidth
433 stack_width 0 rlineto
434 stack_width 2 div neg 0 rmoveto
435
436 n () eq
437 { 0 tic_length 4 div neg rlineto }
438 { 0 tic_length 2 div neg rlineto }
439 ifelse
440
441 stroke
442 grestore
443
444
445
446 gsave
447 n
448 SetNumberFont
449 stack_width 2 div tic_length 2 div neg rmoveto
450
451 rotate_numbers {
452 90 rotate
453 dup stringwidth pop neg % find the length of the number
454 stack_margin sub % Move down a bit
455 (0) CharBoxHeight 2 div neg % left half height of numbers
456 rmoveto
457 show
458 } {
459 dup stringwidth pop neg 2 div number_fontsize neg rmoveto
460 show
461 } ifelse
462
463
464
465 grestore
466 } bind def
467
468
469
470 % Draw a character whose height is proportional to symbol bits
471 /ShowSymbol{ % interval color character ShowSymbol
472 /char exch def
473 /color exch def
474 /interval exch def
475 /fraction_width exch def
476
477 /char_height
478 interval yaxis_scale div stack_height mul
479 stack_margin sub
480 dup
481 % if char_height is negative or very small replace with zero
482 % BUG FIX: This used to be '0.0 gt' but it seems that DrawHeight
483 % has a finite, non-zero minimum, which results in a rangecheck error
484 0.01 gt {}{pop 0.0} ifelse
485 def
486
487 char_height 0.0 gt {
488 show_boxes {
489 gsave
490 /ww char_height stack_margin add def
491 /hh stack_width def
492 stroke_width setlinewidth
493 hh 0 rlineto
494 0 ww rlineto
495 hh neg 0 rlineto
496 0 ww neg rlineto
497 stroke
498 grestore
499 } if
500
501 gsave
502 stack_margin stack_margin rmoveto
503 debug { char_height char_width DrawBox } if
504 1 fraction_width sub char_width mul 2 div 0 rmoveto
505 fraction_width char_width mul char_height color char DrawChar
506 grestore
507
508 } if
509 0 interval yaxis_scale div stack_height mul rmoveto
510 } bind def
511
512
513 /DrawChar { % <width> <height> <char> ShowChar
514 /tc exch def % The character
515 /color exch def % The color of the character
516 /ysize exch def % the y size of the character
517 /xsize exch def % the x size of the character
518 /xmulfactor 1 def
519 /ymulfactor 1 def
520
521 gsave
522 SetLogoFont
523 color aload pop setrgbcolor
524
525 % IReplacementHack
526 % Deal with the lack of bars on the letter 'I' in Arial and Helvetica
527 % by replacing with 'I' from Courier.
528 tc (I) eq {
529 /Courier findfont char_width scalefont setfont
530 } if
531
532
533 shrink {
534 xsize 1 shrink_fraction sub 2 div mul
535 ysize 1 shrink_fraction sub 2 div mul rmoveto
536 shrink_fraction shrink_fraction scale
537 } if
538
539 % Calculate the font scaling factors
540 % Loop twice to catch small correction due to first scaling
541 2 {
542 gsave
543 xmulfactor ymulfactor scale
544
545 ysize % desired size of character in points
546 tc CharBoxHeight
547 dup 0.0 ne {
548 div % factor by which to scale up the character
549 /ymulfactor exch def
550 } {pop pop} ifelse
551
552 xsize % desired size of character in points
553 tc CharBoxWidth
554 dup 0.0 ne {
555 div % factor by which to scale up the character
556 /xmulfactor exch def
557 } {pop pop} ifelse
558 grestore
559 } repeat
560
561
562
563 % Draw the character
564 xmulfactor ymulfactor scale
565 % Move lower left corner of character to start point
566 tc CharBox pop pop % llx lly : Lower left corner
567 exch neg exch neg
568 rmoveto
569
570 tc show
571
572 grestore
573 } bind def
574
575 /DrawErrorbar{ % interval_down interval_up DrawErrorbar
576
577 gsave
578 /points_per_unit stack_height yaxis_scale div def
579 /height_up exch points_per_unit mul def
580 /height_down exch points_per_unit mul def
581
582 show_errorbars {
583
584 stroke_width setlinewidth
585 errorbar_gray setgray
586 stack_width 2 div 0 rmoveto
587
588 /errorbar_width char_width errorbar_width_fraction mul def
589 /errorbar_width2 errorbar_width 2 div def
590
591 gsave
592 0 height_down neg rmoveto
593 errorbar_width2 neg 0 rlineto
594 errorbar_width 0 rlineto
595 errorbar_width2 neg 0 rlineto
596 0 height_down errorbar_fraction mul rlineto
597 stroke
598 grestore
599
600 gsave
601 0 height_up rmoveto
602 errorbar_width2 neg 0 rlineto
603 errorbar_width 0 rlineto
604 errorbar_width2 neg 0 rlineto
605 0 height_up neg errorbar_fraction mul rlineto
606 stroke
607 grestore
608 } if
609
610 grestore
611
612 } bind def
613
614 /DrawErrorbarFirst{ % interval_down interval_up center DrawErrorbarFirst
615 gsave
616 /points_per_unit stack_height yaxis_scale div def
617 /center exch points_per_unit mul def
618
619 0 center rmoveto
620 DrawErrorbar
621 grestore
622 } bind def
623
624 %%EndProlog
625
626 %%Page: 1 1
627
628 % Example Data
629 %StartLogo
630 % StartLine
631 % (1) StartStack
632 % 1.2 [0 0 0] (C) ShowSymbol
633 % 2.2 [0 0 0] (I) ShowSymbol
634 % 0.5 0.5 DrawErrorbar
635 % EndStack
636 % (2) StartStack
637 % 0.5 [0 0 0] (I) ShowSymbol
638 % 0.9 [0 0 0] (L) ShowSymbol
639 % 1.0 [0 0 0] (G) ShowSymbol
640 % 0.5 0.5 DrawErrorbar
641 % EndStack
642 % (234) StartStack
643 % EndStack
644 % (235) StartStack
645 % EndStack
646 % EndLine
647 %EndLogo
648
649 StartLogo
650
651 ${logo_data}
652
653 EndLogo
654
655
656 %%EOF