Get rid of some warnings in CXGN::Cview::Chromosome::Vector
[cview.git] / lib / CXGN / Cview / Map_overviews / ProjectStats.pm
blob82704e382ad564f5cfae0b2f7d08ba0bbc8fdc7c
3 =head1 NAME
5 CXGN::Cview::Map_overviews::ProjectStats - a class to display the tomato genome sequence project status.
7 =head1 SYNOPSYS
9 see L<CXGN::Cview::Map_overviews>.
11 =head1 DESCRIPTION
13 This class implements the project status overview graph found on the SGN homepage and the /about/tomato_sequencing.pl page, where each chromosome is represented by a glyph that is filled to the fraction of the estimated number of BACs needed to complete the chromosome sequence.
15 =head1 AUTHOR(S)
17 Lukas Mueller (lam87@cornell.edu)
19 =head1 FUNCTIONS
21 This class implements the following functions:
23 =cut
25 use strict;
27 package CXGN::Cview::Map_overviews::ProjectStats;
29 use CXGN::Cview::Map_overviews;
30 use CXGN::Cview::Map::SGN::ProjectStats;
31 use CXGN::People::BACStatusLog;
32 use List::Util;
35 use base qw( CXGN::Cview::Map_overviews );
37 =head2 constructor new()
39 Synopsis:
40 Arguments:
41 Returns:
42 Side effects:
43 Description:
45 =cut
47 sub new {
48 my $class = shift;
49 my $force = shift;
51 my $self = $class->SUPER::new($force);
53 $self->set_horizontal_spacing(50);
54 $self->set_image_width(586);
55 $self->set_image_height(160);
56 $self->set_chr_height(80);
58 # print STDERR "Generating new map object...\n";
59 $self->set_map(CXGN::Cview::Map::SGN::ProjectStats->new($self));
60 return $self;
63 =head2 function generate_image()
65 Synopsis:
66 Arguments:
67 Returns:
68 Side effects:
69 Description:
71 =cut
73 sub generate_image {
74 my $self = shift;
75 $self->render_map();
78 =head2 function send_image()
80 Synopsis:
81 Arguments:
82 Returns:
83 Side effects:
84 Description:
86 =cut
88 sub send_image {
89 my $self = shift;
90 print "Content-Type: image/png\n\n";
91 return $self->{map_image}->render_png();
94 =head2 function render_map()
96 Synopsis:
97 Arguments:
98 Returns:
99 Side effects:
100 Description:
102 =cut
104 sub render_map {
105 my $self = shift;
107 $self->get_cache()->set_key("project stats overview graph");
108 $self->get_cache()->set_force(1);
109 $self->get_cache()->set_expiration_time(40000); # set expiration time of cache to half a day.
110 $self->get_cache()->set_map_name("overview_map");
112 if ($self->get_cache()->is_valid()) { return; }
114 my $bac_status_log=CXGN::People::BACStatusLog->new($self);
116 # print STDERR "WIDTH=".$self->get_image_width()." HEIGHT ".$self->get_image_height()."\n";
117 $self->{map_image}=CXGN::Cview::MapImage->new("", $self->get_image_width(), $self->get_image_height());
118 my @c = ();
119 my @c_len = $bac_status_log->get_chromosome_graph_lengths();
120 my @bacs_to_complete = $bac_status_log->get_number_bacs_to_complete();
121 my @c_percent_finished = $bac_status_log->get_chromosomes_percent_finished();
123 my @bacs_in_progress = $bac_status_log->get_number_bacs_in_progress();
124 my @bacs_submitted = $bac_status_log->get_number_bacs_uploaded();
126 my @bacs_phase = $bac_status_log->get_number_bacs_in_phase(3);
129 for my $i (1..12) {
130 $c[$i]= CXGN::Cview::Chromosome::Glyph -> new(1, 100, $self->get_horizontal_spacing()*($i-1)+17, 25);
131 my $m = CXGN::Cview::Marker->new($c[$i],0,0,0,0,0,0,$c_len[$i]);
132 $m -> hide();
133 $c[$i]->add_marker($m);
134 $c[$i]->set_caption($i);
135 $c[$i]->set_height($self->get_chr_height());
136 $c[$i]->set_url("/cview/view_chromosome.pl?map_version_id=agp&show_offsets=1&show_ruler=1&chr_nr=$i");
138 my $percent_in_progress = $bacs_in_progress[$i]/$bacs_to_complete[$i]*100;
140 my $percent_finished = $c_percent_finished[$i];
142 my $percent_htgs3 = $bacs_phase[$i]/$bacs_to_complete[$i]*100;
144 my $percent_available = $bacs_submitted[$i]/$bacs_to_complete[$i]*100;
146 #$percent_submitted = $percent_submitted - $percent_htgs3;
148 my $percent_in_progress_base_level = List::Util::max($percent_finished, $percent_htgs3, $percent_available);
150 $percent_in_progress += $percent_in_progress_base_level;
152 #print STDERR "Chromosome $i $percent_htgs3, $percent_available, $percent_finished, $percent_in_progress\n";
155 $c[$i]->set_fill_level(0, $percent_htgs3);
156 $c[$i]->set_fill_level(1, $percent_available);
157 $c[$i]->set_fill_level(2, $percent_finished);
158 $c[$i]->set_fill_level(3, $percent_in_progress);
159 $c[$i]->set_bac_count(0);
160 $self->{map_image}->add_chromosome($c[$i]);
162 my $white = $self->{map_image}->get_image()->colorResolve(255,255,255);
163 $self->{map_image}->get_image()->transparent($white);
167 $self->get_cache()->set_image_data( $self->{map_image}->render_png_string());
168 $self->get_cache()->set_image_map_data ($self->{map_image}->get_image_map("overview_map") );
172 =head2 function create_mini_overview()
174 Synopsis:
175 Arguments: none
176 Returns: nothing
177 Side effects: creates the mini overview png image that goes on the
178 homepage
179 Description:
181 =cut
183 sub create_mini_overview {
184 my $self = shift;
185 $self->set_image_width(400);
186 $self->set_image_height(100);
187 $self->set_chr_height(50);
188 $self->set_horizontal_spacing(30);
190 my $url = "/documents/tempfiles/frontpage/project_stats_overview.png";
191 my $path = File::Spec->catfile($self->get_vhost()->get_conf("basepath"), $url);
193 $self->render_map();
194 $self->get_file_png($path);
199 =head2 DEPRECATED CLASS CXGN::Cview::Map_overviews::project_stats
201 Synopsis:
202 Arguments:
203 Returns:
204 Side effects:
205 Description: This class is deprecated. It now inherits from
206 CXGN::Cview::Map_overviews::ProjectStats
207 Use CXGN::Cview::Map_overview::ProjectStats
208 directly.
210 =cut
215 package CXGN::Cview::Map_overviews::project_stats;
217 use base qw | CXGN::Cview::Map_overviews::ProjectStats |;
219 sub new {
220 my $class = shift;
221 my $self = $class->SUPER::new(@_);
222 return $self;
225 return 1;