4 organism_tree.mas - mason component for printing organism phylo trees
8 Queries the database for web_visible (see chado: organismprop table ) sgn organisms, and buids a species tree from the phylonode table using the L<CXGN::Phylo::Tree> framework
12 Naama Menda <nm249@cornell.edu>
33 use CXGN::Phylo::OrganismTree;
34 use CXGN::Tools::WebImageCache;
36 my $cache = CXGN::Tools::WebImageCache->new();
37 $cache->set_temp_dir($uri_dir);
38 $cache->set_basedir($tmp_dir);
40 my $file_key_name = $root . "-" . (join '-', keys %$species_hashref);
41 $cache->set_key($file_key_name);
42 $cache->set_expiration_time(86400);
43 my $map_name= $root . "_map";
45 $cache->set_map_name($map_name);
47 my $newick_file = $tmp_dir . "/" . $uri_dir . "/" . $root . ".newick";
49 if ( !$cache->is_valid() ) {
51 my $tree = CXGN::Phylo::OrganismTree->new($schema);
52 my $newick_string = $tree->build_tree($root, $species_hashref);
54 open(my $FH, ">$newick_file" ) or die $! . "cannot open file $newick_file for writing! \n\n";
55 print $FH $newick_string;
57 my $image_map = $tree->get_renderer()->get_html_image_map($map_name);
58 my $image_png = $tree->render_png(undef, 1);
60 $cache->set_image_data($image_png);
61 $cache->set_image_map_data($image_map);
64 my $image_html= $cache->get_image_html();
66 open( my $MF, "<$newick_file" );
68 $tree_string .= $_ while <$MF>;
71 if ($image_only) { print $image_html; return; }
75 <&| /page/info_section.mas,
77 subtitle => 'click on organism name to see more details ',
78 empty_message => 'Tree not available',
83 <form action="/tools/tree_browser/" method="post"><input type="hidden" name="tree_string" value=" <% $tree_string %> "><input type="submit" value="show in treebrowser" /></form>