3 # Last changed Time-stamp: <2005-11-07 13:31:34 ivo>
4 # Produce coloured Hogeweg mountain representation in PostScript.
5 # Input is a colour _dp.ps file from alidot or RNAalifold
6 # definition: mm[i],mp[i]=number of base pairs enclosing base i
9 use vars qw(@mm @mp @hue @sat @pair @pr);
11 die "Usage: $0 alidot.ps\n";
16 print "%!PS-Adobe-2.0 EPSF-1.2
19 %%BoundingBox: 66 209 518 686
24 print <<EOF; # PS macros
25 /trapez { % use as i j height prob hue sat
26 dup 0.3 mul 1 exch sub sethsbcolor
28 3 index 0.5 sub 2 index moveto % i-0.5 h moveto
30 4 2 roll exch sub 2 sub 0 rlineto
38 gsave 1 xs div 1 ys div scale 60 rotate
39 % dup stringwidth pop 2 div neg 0 rmoveto
45 my ($from, $to)=(1,0);
49 if (/^% Subsequence from (\d+) to (\d+)/) { # get start and end
52 if (/\/sequence \{ \((\S*)[\\\)]/) {
54 $seq = $1; # empty for new version
55 while (!/\) \} def/) { # read until end of definition
58 /(\S*)[\\\)]/; # ends either with `)' or `\'
61 print "/len { sequence length } def\n";
62 $length = length($seq);
67 next unless /[ul]box$/;
68 # Damn! alidot and alifold use different postscript macros.
69 # Try to recognize both
70 my ($h, $s, $blah, $i, $j, $p, $tok);
71 if (/ hsb /) { # alifold version
72 ($h, $s, $blah, $i, $j, $p, $tok) = split;
74 } else { # alidot version
75 ($i, $j, $p, $h, $s, $tok) = split;
78 if ($tok eq "lbox") { # only read lbox entries
89 for (my $i=1; $i<=$length; $i++) { #find maximum for scaling
91 $max = $mp[$i] if ($mp[$i]>$max);
93 $max = $mp[$i] if ($mp[$i]>$max);
96 # postscript scaleing etc
97 print "72 216 translate\n";
98 print "/xs {72 6 mul len div} def /ys {72 6 mul $max div} def xs ys scale\n";
99 print "0.03 setlinewidth
100 /Times-Roman findfont 1.8 scalefont setfont
104 sequence exch 1 getinterval
105 gsave 1 $max len div scale show grestore
108 print "/Times-Roman findfont 10 scalefont setfont
110 len log 0.7 sub cvi 10 exch exp % grid spacing
111 gsave 0.5 0 translate
117 cvi $from 1 sub add temp cvs centershow
123 for (my $i=1; $i<=$length; $i++) { # print pairs as coloured trapezes
124 next unless ($pair[$i]);
125 print "$i $pair[$i] ";
126 printf "%6.4f %6.4f $hue[$i] $sat[$i] trapez\n", $mp[$i], $pr[$i] ;
133 cmount.pl - produce a colored mountain plot of a consensus structure
141 cmount.pl reads a color dot plot as produced by either C<RNAalifold
142 -p> or C<alidot -p> and writes a postscript colored mountain plot to
145 In the mountain plot a colored trapez with baseline from position i to
146 j represents the pair (i,j) in the consensus structure. The color of
147 the trapez encodes the sequence variation at that pair: Red marks
148 pairs with no sequence variation; ochre, green, turquoise, blue, and
149 violet mark pairs with 2,3,4,5,6 different tpyes of pairs,