WSTester updated to work plus hopefully all the other changes that need to go into...
[jabaws.git] / binaries / src / ViennaRNA / Utils / dpzoom.pl
1 #!/usr/bin/perl -w
2 # zoom into a PostScript dot plot produced by RNAfold, RNAalifold or alidot
3 # Last changed Time-stamp: <2003-03-24 12:47:26 ivo> 
4 sub usage {
5   die "Usage: $0 [-f first] [-l last] [dp_file]\n";
6 }
7
8 $from=1;
9 $to = -1;
10 # parse command line
11 while ($_ = shift) {
12   /^-[\?h]/ && usage();
13   /^-f$/ && ($from = shift, next );
14   /^-l$/ && ($to   = shift, next );
15   unshift (@ARGV, $_);
16   last;
17 }
18
19 usage() if eof();
20
21 while (<>) {
22   if (/\/sequence \{ \((\S*)[\\\)]/) {
23     $seq = $1;              # empty for new version
24     while (!/\) \} def/) {  # read until end of definition
25       $_ = <>;
26       /(\S*)[\\\)]/;      # ends either with `)' or `\'
27       $seq .= $1;
28     }
29     if ($to>$from) { $seq=substr($seq,$from-1,$to-$from+1) }
30     else { $seq=substr($seq,$from-1) }
31     print  "% Subsequence from $from to $to\n";
32     print "/sequence { (\\\n";
33     for ($p=0; $p<length($seq); $p+=250)  {
34       print substr($seq,$p, 250), "\\\n";
35     }
36     print ") } def\n";
37   }
38   elsif (/(\d+) (\d+) (.*box$)/) {
39     $i=$1; $j=$2;
40     next if (($i<$from) || (($j>$to)&&($to>0)));
41     $i -= ($from-1);
42     $j -= ($from-1);
43     printf "%d %d %s\n", $i, $j, $3;
44   }
45   else {print}
46 }