Merge branch 'master' of https://github.com/solgenomics/sgn
[sgn.git] / cgi-bin / phenome / annot_stats.pl
blobed8f40bd160c59d1ea8a8079901da2b78f191678
1 #!usr/bin/perl
2 use warnings;
3 use strict;
5 use CXGN::Page;
6 use CXGN::Login;
7 use CXGN::People;
8 use CXGN::Tools::WebImageCache;
9 use CXGN::Phenome::Locus;
10 use GD::Graph::lines;
11 use GD::Graph::linespoints;
12 use GD::Graph::area;
13 use GD::Graph::bars;
14 use CatalystX::GlobalContext '$c';
16 use CXGN::Page::FormattingHelpers qw/info_section_html
17 page_title_html
18 columnar_table_html
19 info_table_html
20 html_optional_show
21 html_alternate_show
23 my $dbh = $c->dbc->dbh;
25 my $logged_sp_person_id = CXGN::Login->new($dbh)->verify_session();
27 my $page = CXGN::Page->new("Phenome annotation stats","Naama");
29 $page->header();
31 my $form = CXGN::Page::WebForm->new();
33 my @lstats=CXGN::Phenome::Locus->get_locus_stats( $dbh );
36 my $image= get_graph(@lstats);
37 print info_section_html(title => 'Locus stats',
38 contents => $image,
41 $page->footer();
43 sub get_graph {
44 my @stats=@_;
45 my $basepath = $c->config->{"basepath"};
46 my $tempfile_dir = $c->config->{"tempfiles_subdir"};
47 my $cache = CXGN::Tools::WebImageCache->new;
48 $cache->set_basedir($basepath);
49 $cache->set_temp_dir($tempfile_dir."/temp_images");
50 $cache->set_key("Locus_num");
51 #$cache->set_map_name("locusnum");
53 $cache->set_force(1);
54 if (! $cache->is_valid()) {
56 my $graph = GD::Graph::area->new(600,400);
57 $graph->set(
58 x_label => 'Date',
59 y_label => 'Number of loci',
60 title => 'SGN locus database',
61 #cumulate =>'true',
62 y_max_value => 7000,
63 #y_tick_number => 8,
64 #y_label_skip => 2
65 ) or die $graph->error;
67 for my $i ( 0 .. $#stats ) {
68 my $aref = $stats[$i];
69 my $n = @$aref - 1;
70 for my $j ( 0 .. $n ) {
75 $graph->set_title_font('gdTinyFont');
76 my @bar_clr = ("orange");
79 $cache->set_image_data($graph->plot(\@stats)->png);
83 my $image = $cache->get_image_tag();
84 my $title = "SGN locus database";
85 return $image;