ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/yamap/genome_plot.pl
Revision: 1.1
Committed: Wed Dec 13 10:41:21 2006 UTC (9 years, 9 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, $genome, $number_plots, @title, $title, $path, $output_png, $output_jpeg, $output_html, @orfs, $orf_count);
8
9 unless (@ARGV ==1) {
10 die "\n\nUsage:\n ./genome_plot.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 @lines = <INPUT>;
27 close INPUT;
28 my $blank = "-";
29 print qq{\n$blank\n};
30 my $number_of_genomes = $#lines - 2;
31 for ($j = 2; $j <=$#lines; $j++)
32 {
33 @genome = split /$record_separator/, $lines[$j];
34 $title = $genome[0];
35 print "$title";
36 open OUT, ">$path2output/gene_plotter$title.dat";
37 open (INC, "$path2output/$title"."_orphan_increment.html") or die "can't open $title"."_orphan_increment.html file";
38 @orfs = <INC>;
39 close INC;
40 $orf_count = @orfs -2;
41 print OUT qq{0 $orf_count\n};
42 $i = 1;
43 foreach $genome (@genome)
44 {
45 unless ($genome =~m/$blank/ || $genome =~m/NC/)
46 {
47 print OUT qq{$i $genome\n};
48 $i++;
49 }
50 }
51 close OUT;
52
53
54
55 open GNU, ">$path2output/gene_plotter_commands$title.dat";
56 print GNU qq{set terminal png small\n};
57 $output_png = $title."_orphan_plot.png";
58 print GNU qq{set output '$output_png'\n};
59 print GNU qq{set xlabel "Genome Number"\n};
60 print GNU qq{set ylabel "Number of orphans"\n};
61 print GNU qq{plot [0:$number_of_genomes][0:*] };
62
63 print GNU qq{'$path2output/gene_plotter$title.dat' using 1:2 smooth bezier title '$title'};
64
65
66 close GNU;
67 chdir "$path2output/";
68 print qq{Plotting graph $title\n};
69 system "gnuplot $path2output/gene_plotter_commands$title.dat";
70 $path = "$path2output";
71 chdir "$path";
72 $output_jpeg = $title."_orphan_plot.jpeg";
73 system "convert $output_png $output_jpeg";
74
75 $output_html = $title."_orphan_plot.html";
76 open HTML, ">$path2output/$output_html";
77 print HTML qq{<html><body>};
78 print HTML qq{<img src=$output_jpeg>};
79 print HTML qq{</body></html>};
80 close HTML;
81 if ($debug == 0)
82 {
83 unlink ("gene_plotter_commands$title.dat");
84 unlink ("gene_plotter$title.dat");
85 unlink ($output_png);
86 }
87 }