ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/yamap/dot_plot.pl
Revision: 1.1
Committed: Wed Dec 13 10:37:56 2006 UTC (9 years, 6 months ago) by gawi79
Branch: MAIN
CVS Tags: HEAD
Log Message:
A QuickMine Script

Line File contents
1 #!/usr/bin/perl -w
2
3
4 ##############################################
5 #SCRIPT NAME: dot_plot.pl
6 #DESCRIPTION: Generates dot plots of each genome vs genome
7 ##############################################
8
9
10 use strict;
11
12 use Config::Simple;
13
14 my ($tag, @tags, $file, @lines, $lines, $i, $j, $line, $column_number, @titles, @columns, $main, $title, $columns, $path, $k);
15
16 # get this from the command line
17
18 unless (@ARGV ==2) {
19 die "\n\nUsage:\n ./dot_plot.pl matrix_end configfile\nPlease try again.\n\n\n";}
20
21 my $matrix_end = shift;
22 my $config_file = shift;
23
24 my $cfg = new Config::Simple($config_file);
25 my $debug = 0;
26 # get the record separator from the config file
27 my $record_separator = $cfg->param('PARAMS.record_separator');
28 # convert since use of \t in config file results in literal \t being printed
29
30 if ($record_separator =~ "tab") {$record_separator = "\t"}
31
32 print "RECORD SEP $record_separator\n";
33 my $path2output = $cfg->param('PATHS.path2output');
34
35 open (TAGS, "abbr.list") or die "can't open abbr.list file";
36 while ($tag = <TAGS>)
37 {
38 chomp($tag);
39 push (@tags, $tag);
40 }
41
42
43 foreach $tag (@tags)
44 {
45 $file = "$tag"."$matrix_end";
46 print "TAG: $tag - Generating orphan increments $file\n";
47 open (INPUT, "$file") or die "can't open file: $file";
48 @lines = <INPUT>;
49 close INPUT;
50 @titles = split /$record_separator/,$lines[1];
51 $column_number = $#titles;
52 print "number of columns = $column_number\n";
53 $i = 0;
54 foreach $title(@titles)
55 {
56 chomp($title);
57 if ($title =~m/$tag/)
58 {
59 print "title = $title, tag = $tag, i = $i\n";
60 $main = $i;
61 }
62 $i++;
63 }
64 print "Main = $titles[$main]\n";
65 $j = 1;
66 while ($j <= $column_number)
67 {
68 $k = 0;
69 print "$titles[$j]";
70 open OUTPUT, ">$path2output/$tag"."vs"."$titles[$j]".".dat";
71 foreach $line(@lines)
72 {
73 if ($k > 1)
74 {
75 @columns = split /$record_separator/,$line;
76 foreach $columns(@columns)
77 {
78 chomp ($columns);
79 }
80 print OUTPUT "$columns[$main]\t$columns[$j]\n";
81
82 }
83 $k++;
84 }
85 close OUTPUT;
86
87
88 open GNU, ">$path2output/dot_plotter_commands$tag"."vs"."$titles[$j]".".dat";
89 print GNU qq{set terminal png small\n};
90 my $output_png = $tag."vs".$titles[$j]."_synteny_plot.png";
91 print GNU qq{set output '$output_png'\n};
92 print GNU qq{set xlabel "$tag"\n};
93 print GNU qq{set ylabel "$titles[$j]"\n};
94 print GNU "plot \'$path2output/$tag"."vs"."$titles[$j]".".dat\' title \'$tag"."vs"."$titles[$j]\'";
95
96 close GNU;
97 chdir "$path2output/";
98 print "Plotting graph $tag"."vs"."$titles[$j]\n";
99 system "gnuplot $path2output/dot_plotter_commands$tag"."vs"."$titles[$j]".".dat";
100 $path = $path2output;
101 chdir "$path";
102 my $output_jpeg = $tag."vs".$titles[$j]."_synteny_plot.jpeg";
103 system "convert $output_png $output_jpeg";
104
105 my $output_html = $tag."vs".$titles[$j]."_synteny.html";
106 open HTML, ">$path2output/$output_html";
107 print HTML qq{<html><body>};
108 print HTML qq{<img src=$output_jpeg>};
109 print HTML qq{</body></html>};
110 close HTML;
111 if ($debug == 0)
112 {
113 unlink ("$tag"."vs"."$titles[$j]".".dat");
114 unlink ("dot_plotter_commands$tag"."vs"."$titles[$j]".".dat");
115 unlink ($output_png);
116 }
117 $j++;
118 }
119 }