3 # Last changed Time-stamp: <2005-11-07 12:08:38 ivo>
4 # $Id: colorrna.pl,v 1.1 2005/11/07 12:42:27 ivo Exp $
5 # colorize a secondary structure plot with reliability annotation
6 # from positional entropy
10 $Getopt::Std::STANDARD_HELP_VERSION=1;
16 print STDERR "\nusage: $0 FOO_ss.ps FOO_dp.ps > FOO_css.ps\n";
17 print STDERR "For more details run\n\tperldoc -F $0\n";
20 HELP_MESSAGE() unless $#ARGV >0;
22 my %mfe = (); # hash of mfe pairs
23 my @ss_ps = ('',''); # head and tail of the ss.ps file
25 my $n = swallow_ss_ps(); # read ss plot
26 my %hsb = read_dp(); # read dot plot and compute entropies
28 print $ss_ps[0]; # print head
32 dup 0.3 mul 1 exch sub sethsbcolor
34 /colorpair { % i j hue sat colorpair
35 % draw basepair i,j in color
41 1 sub coor exch get aload pop moveto
42 1 sub coor exch get aload pop lineto
49 foreach my $k (keys %hsb) {
50 my ($i,$j) = split($;,$k);
51 print "$i $j ", $hsb{$k}->[0], " ", $hsb{$k}->[1]," colorpair\n";
53 print $ss_ps[1]; # print main part
54 print $ss_ps[2]; # print showpage etc
57 # read the secondary structure plot
61 $macro_seen=1 if /colorpair/;
62 $length ++ if /^\/coor/ .. /^\] def/;
63 if (/^\/pairs/ .. /^\] def/) {
64 $mfe{$1,$2}=1 if /(\d+)\s+(\d+)/;
67 $tail++ if /^drawpairs/;
68 s/^drawpairs/% drawpairs/;
69 $tail++ if /^showpage/;
77 # read dot plot and extract hsb values
82 $hsb{$F[3],$F[4]} = [$F[0], $F[1]];
89 colorrna - colorize an alirna.ps file
93 colorrna.pl alirna.ps alidot.ps > colorRNA.ps
97 colorrna reads an RNA secondary structure plot and a dot plot
98 containing pair probabilities and covariance annotation as, produced
99 by C<RNAalifold -p>, and writes a new secondary structure plot with
100 color annotated seqence annotation to stdout. The color annotation
101 is taken directly from the color dot plot file.
105 Ivo L. Hofacker <ivo@tbi.univie.ac.at>
106 Stefan Washietl <wash@tbi.univie.ac.at>