[Bio] / FortyEight / WebPage / GenomeStatistics.pm Repository:
ViewVC logotype

Annotation of /FortyEight/WebPage/GenomeStatistics.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download) (as text)

1 : paarmann 1.1 package WebPage::GenomeStatistics;
2 :    
3 :     use base qw( WebApp::WebPage );
4 :    
5 :     1;
6 :    
7 :     use FIG;
8 :     use FIGV;
9 :     use FIG_Config;
10 :     use CGI;
11 :     use Table;
12 :    
13 :     =pod
14 :    
15 :     =head1 NAME
16 :    
17 :     GenomeStatistics - display statistics about a new genome
18 :    
19 :     =head1 DESCRIPTION
20 :    
21 :     WebPage module to display statistics about a new genome, e.g. comparison to another version
22 :     of this organism already in the seed.
23 :    
24 :     =head1 METHODS
25 :    
26 :     =over 4
27 :    
28 :     =item * B<output> ()
29 :    
30 :     Returns the html output of the page.
31 :    
32 :     =cut
33 :    
34 :     sub output {
35 :     my ($self) = @_;
36 :    
37 :     # initialize objects
38 :     my $app = $self->application();
39 :     my $cgi = new CGI;
40 :     my $job = $cgi->param('job');
41 :     my $basedir = $FIG_Config::fortyeight_jobs . "/" . $job;
42 :     my $genome_id = `cat $basedir/GENOME_ID`;
43 :     my $genome_name = `cat $basedir/GENOME`;
44 :     chomp $genome_id;
45 :     my $organism_directory = $basedir . "/rp/" . $genome_id;
46 :     my $fig = FIGV->new($organism_directory);
47 :    
48 :     # open statistics file
49 :     my $same = 0;
50 :     my $identical = 0;
51 :     my $different = 0;
52 :     my $table_data;
53 :     my $seed_genome_id = undef;
54 :     my $titles;
55 :     my $infos;
56 :     open(FH, $basedir."/rp/".$genome_id."/comparison") or return "could not open comparison file";
57 :     while (<FH>) {
58 :     my $line = $_;
59 :     chomp $line;
60 :     my @row = split /\t/, $line;
61 :    
62 :     # determine seed genome id
63 :     unless (defined($seed_genome_id)) {
64 :     my $peg_id_2 = $row[3];
65 :     $peg_id_2 =~ /^fig\|(\d+\.\d+)/;
66 :     $seed_genome_id = $1;
67 :     }
68 :    
69 :     # create popup menu
70 :     push(@$titles, [ undef, undef, 'Subsystems', undef, undef, 'Subsystems', undef ]);
71 :     my $info1 = join('<br>', split(/~/, $row[2]));
72 :     if ($info1 eq "0") {
73 :     $info1 = "- none -"
74 :     }
75 :     my $info2 = join('<br>', split(/~/, $row[5]));
76 :     if ($info2 eq "0") {
77 :     $info2 = "- none -"
78 :     }
79 :     push(@$infos, [ undef, undef, $info1, undef, undef, $info2, undef ]);
80 :    
81 :     # create feature links
82 : paczian 1.2 $row[0] = "<a href='seedviewer.cgi?action=ShowAnnotation&job=$job&prot=" . $row[0] . "' target='seed_viewer'>" . $row[0] . "</a>";
83 : paarmann 1.1 $row[3] = "<a href='http://anno-3.nmpdr.org/anno/FIG/protein.cgi?user=master&prot=" . $row[3] . "' target='anno_seed'>" . $row[3] . "</a>";
84 :    
85 :     # count subsystems
86 :     unless ($row[2] eq '0') {
87 :     $row[2] = scalar(split /~/, $row[2]);
88 :     }
89 :     unless ($row[5] eq '0') {
90 :     $row[5] = scalar(split /~/, $row[5]);
91 :     }
92 :    
93 :     # push the row into the table data
94 :     push(@$table_data, \@row);
95 :    
96 :     # count some more
97 :     if ($row[6] eq 'same') {
98 :     $identical++;
99 :     } elsif ($row[6] eq 'samefunc') {
100 :     $same++;
101 :     } elsif ($row[6] eq 'different') {
102 :     $different++;
103 :     }
104 :     }
105 :     close FH;
106 :     my $seed_genome_name = $fig->orgname_of_orgid($seed_genome_id);
107 :    
108 :     # get feature information
109 :     my $features_rast = $fig->all_features_detailed_fast($genome_id);
110 :     my $features_seed = $fig->all_features_detailed_fast($seed_genome_id);
111 :    
112 :     # set page title
113 :     $self->title('Genome Statistics');
114 :    
115 :     # start content
116 :     my $html = "<h2>Genome Statistics for $genome_name</h2>";
117 :     $html .= "<p><b>RAST: $genome_name ($genome_id)</b> has been compared to <b>SEED: $seed_genome_name ($seed_genome_id)</b></p>";
118 :     $html .= "<table>";
119 :     $html .= "<tr><th><b>Total #features in RAST</b></th><td>" . scalar(@$features_rast) . "</td></tr>";
120 :     $html .= "<tr><th><b>Total #features in SEED</b></th><td>" . scalar(@$features_seed) . "</td></tr>";
121 :     $html .= "<tr><th><b>#matched features</b></th><td>" . scalar(@$table_data) . "</td></tr>";
122 :     $html .= "<tr><th><b>#identical features</b></th><td>$identical</td></tr>";
123 :     $html .= "<tr><th><b>#same features</b></th><td>$same</td></tr>";
124 :     $html .= "<tr><th><b>#different features</b></th><td>$different</td></tr>";
125 :     $html .= "</table>";
126 :    
127 :     $html .= "<br><br>";
128 :    
129 :     my $table = Table::new( { data => $table_data,
130 :     columns => ['RAST ID','Function RAST','#SS','SEED ID','Function SEED','#SS','Comp'],
131 :     show_perpage => 1,
132 :     perpage => 20,
133 :     show_topbrowse => 1,
134 :     show_bottombrowse => 1,
135 :     sortable => 1,
136 :     popup_menu => { titles => $titles, infos => $infos },
137 :     operands => { 'RAST ID' => 1,
138 :     'Function RAST' => 1,
139 :     'SEED ID' => 1,
140 :     'Function SEED' => 1,
141 :     'Comp' => 1 } } );
142 :    
143 :     $html .= $table;
144 :    
145 :     # return content
146 :     return $html;
147 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3