ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/yamap/gnu_plotter.pl
Revision: 1.1
Committed: Wed Dec 13 10:44:05 2006 UTC (9 years, 6 months ago) by gawi79
Branch: MAIN
CVS Tags: HEAD
Log Message:
A QuickMine script - require gnuplot

Line File contents
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 use Config::Simple;
6
7 my (@lines, $lines, $i, $j, $k, @length, $length, @genome, $number_plots, @title, $title, $path);
8
9 unless (@ARGV ==1) {
10 die "\n\nUsage:\n ./gnu_plotter.pl configfile\nPlease try again.\n\n\n";}
11
12 my $config_file = shift;
13
14 my $cfg = new Config::Simple($config_file);
15 my $debug = 0;
16 # get the record separator from the config file
17 my $record_separator = $cfg->param('PARAMS.record_separator');
18 # convert since use of \t in config file results in literal \t being printed
19
20 if ($record_separator =~ "tab") {$record_separator = "\t"}
21
22 print "RECORD SEP $record_separator\n";
23
24 my $path2output = $cfg->param('PATHS.path2output');
25 open (INPUT, "$path2output/orphan_time.html") or die "can't open orphan_time.html file";
26 open OUT, ">$path2output/gnu_plotter.dat";
27 @lines = <INPUT>;
28 close INPUT;
29 @length = split /$record_separator/, $lines[2];
30 my $number_of_genomes = $#lines - 1;
31 print qq{$#lines\n};
32 my $blank = "-";
33 for ($i = 0; $i<=$#length; $i++)
34 {
35 unless ($i == 0)
36 {
37 print OUT qq{$i};
38 }
39 for ($j = 2; $j <=$#lines; $j++)
40 {
41 @genome = split /$record_separator/, $lines[$j];
42 if ($i == 0)
43 {
44 push @title,$genome[$i];
45 }
46 else
47 {
48 chomp $genome[$i];
49 print OUT qq{ $genome[$i]};
50 }
51 }
52 print OUT qq{\n};
53
54 }
55 close OUT;
56 $number_plots = $#lines;
57 open GNU, ">$path2output/gnu_plotter_commands.dat";
58 print GNU qq{set terminal png small\n};
59 print GNU qq{set output 'orphan_plot.png'\n};
60 print GNU qq{set xlabel "Genome Number"\n};
61 print GNU qq{set ylabel "Number of orphans"\n};
62 print GNU qq{plot [1:$number_of_genomes][0:*] };
63 for ($k = 2; $k <= $number_plots; $k++)
64 {
65 print GNU qq{'$path2output/gnu_plotter.dat' using 1:$k smooth bezier notitle};
66
67 unless ($k == $number_plots)
68 {
69 print GNU qq{,}
70 }
71 }
72 close GNU;
73 chdir "$path2output/";
74 print qq{Plotting graph\n};
75 system "gnuplot $path2output/gnu_plotter_commands.dat";
76 $path = "$path2output/";
77 chdir "$path";
78 system "convert orphan_plot.png orphan_plot.jpeg";
79 open HTML, ">$path2output/orphan_plot.html";
80 print HTML qq{<html><body>};
81 print HTML qq{<img src="orphan_plot.jpeg">};
82 print HTML qq{</body></html>};
83 close HTML;
84 if ($debug == 0)
85 {
86 unlink ("gnu_plotter_commands.dat");
87 unlink ("gnu_plotter.dat");
88 unlink ("orphan_plot.png");
89 }