changes to the parameters of map overview constructors
[cview.git] / lib / CXGN / Cview / MapOverviews / ProjectStats.pm
bloba256d55273cbfae4ee3bdddffd6171dae4eff340
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::MapOverviews::ProjectStats;
29 use base "CXGN::Cview::MapOverviews";
31 use CXGN::Cview::Map::SGN::ProjectStats;
32 use CXGN::People::BACStatusLog;
33 use List::Util;
35 =head2 constructor new()
37 Synopsis:
38 Arguments:
39 Returns:
40 Side effects:
41 Description:
43 =cut
45 sub new {
46 my $class = shift;
47 my $args = shift;
49 my $map = CXGN::Cview::Map::SGN::ProjectStats->new($args->{dbh});
51 my $self = $class->SUPER::new($map, $args);
52 $self->{dbh}= $args->{dbh};
53 $self->set_horizontal_spacing(50);
54 $self->set_image_width(586);
55 $self->set_image_height(160);
56 $self->set_chr_height(80);
57 $self->{basepath}=$args->{basepath};
58 $self->{tempfiles_subdir} = $args->{tempfiles_subdir};
59 # print STDERR "Generating new map object...\n";
60 $self->set_map($map);
61 return $self;
64 =head2 function generate_image()
66 Synopsis:
67 Arguments:
68 Returns:
69 Side effects:
70 Description:
72 =cut
74 sub generate_image {
75 my $self = shift;
76 $self->render_map();
79 =head2 function send_image()
81 Synopsis:
82 Arguments:
83 Returns:
84 Side effects:
85 Description:
87 =cut
89 sub send_image {
90 my $self = shift;
91 print "Content-Type: image/png\n\n";
92 return $self->{map_image}->render_png();
95 =head2 function render_map()
97 Synopsis:
98 Arguments:
99 Returns:
100 Side effects:
101 Description:
103 =cut
105 sub render_map {
106 my $self = shift;
108 $self->get_cache()->set_key("project stats overview graph");
109 $self->get_cache()->set_force(1);
110 $self->get_cache()->set_expiration_time(40000); # set expiration time of cache to half a day.
111 $self->get_cache()->set_map_name("overview_map");
113 if ($self->get_cache()->is_valid()) { return; }
115 my $bac_status_log=CXGN::People::BACStatusLog->new($self->{dbh});
117 # print STDERR "WIDTH=".$self->get_image_width()." HEIGHT ".$self->get_image_height()."\n";
118 $self->{map_image}=CXGN::Cview::MapImage->new("", $self->get_image_width(), $self->get_image_height());
119 my @c = ();
120 my @c_len = $bac_status_log->get_chromosome_graph_lengths();
121 my @bacs_to_complete = $bac_status_log->get_number_bacs_to_complete();
122 my @c_percent_finished = $bac_status_log->get_chromosomes_percent_finished();
124 my @bacs_in_progress = $bac_status_log->get_number_bacs_in_progress();
125 my @bacs_submitted = $bac_status_log->get_number_bacs_uploaded();
127 my @bacs_phase = $bac_status_log->get_number_bacs_in_phase(3);
130 for my $i (1..12) {
131 $c[$i]= CXGN::Cview::Chromosome::Glyph -> new(1, 100, $self->get_horizontal_spacing()*($i-1)+17, 25);
132 my $m = CXGN::Cview::Marker->new($c[$i],0,0,0,0,0,0,$c_len[$i]);
133 $m -> hide();
134 $c[$i]->add_marker($m);
135 $c[$i]->set_caption($i);
136 $c[$i]->set_height($self->get_chr_height());
137 $c[$i]->set_url("/cview/view_chromosome.pl?map_version_id=agp&show_offsets=1&show_ruler=1&chr_nr=$i");
139 my $percent_in_progress = $bacs_in_progress[$i]/$bacs_to_complete[$i]*100;
141 my $percent_finished = $c_percent_finished[$i];
143 my $percent_htgs3 = $bacs_phase[$i]/$bacs_to_complete[$i]*100;
145 my $percent_available = $bacs_submitted[$i]/$bacs_to_complete[$i]*100;
147 #$percent_submitted = $percent_submitted - $percent_htgs3;
149 my $percent_in_progress_base_level = List::Util::max($percent_finished, $percent_htgs3, $percent_available);
151 $percent_in_progress += $percent_in_progress_base_level;
153 #print STDERR "Chromosome $i $percent_htgs3, $percent_available, $percent_finished, $percent_in_progress\n";
156 $c[$i]->set_fill_level(0, $percent_htgs3);
157 $c[$i]->set_fill_level(1, $percent_available);
158 $c[$i]->set_fill_level(2, $percent_finished);
159 $c[$i]->set_fill_level(3, $percent_in_progress);
160 $c[$i]->set_bac_count(0);
161 $self->{map_image}->add_chromosome($c[$i]);
163 my $white = $self->{map_image}->get_image()->colorResolve(255,255,255);
164 $self->{map_image}->get_image()->transparent($white);
168 $self->get_cache()->set_image_data( $self->{map_image}->render_png_string());
169 $self->get_cache()->set_image_map_data ($self->{map_image}->get_image_map("overview_map") );
173 =head2 function create_mini_overview()
175 Synopsis:
176 Arguments: none
177 Returns: nothing
178 Side effects: creates the mini overview png image that goes on the
179 homepage
180 Description:
182 =cut
184 sub create_mini_overview {
185 my $self = shift;
186 $self->set_image_width(400);
187 $self->set_image_height(100);
188 $self->set_chr_height(50);
189 $self->set_horizontal_spacing(30);
191 my $url = "/documents/tempfiles/frontpage/project_stats_overview.png";
192 my $path = File::Spec->catfile($self->{basepath}, $url);
194 $self->render_map();
195 $self->get_file_png($path);