[Bio] / FigWebServices / ss_scoreboard.cgi Repository:
ViewVC logotype

View of /FigWebServices/ss_scoreboard.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (download) (annotate)
Mon Dec 5 19:12:12 2005 UTC (13 years, 11 months ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, rast_rel_2009_05_18, mgrast_dev_08022011, rast_rel_2014_0912, rast_rel_2008_06_18, myrast_rel40, rast_rel_2008_06_16, mgrast_dev_05262011, rast_rel_2008_12_18, mgrast_dev_04082011, rast_rel_2008_07_21, rast_rel_2010_0928, rast_2008_0924, mgrast_version_3_2, mgrast_dev_12152011, rast_rel_2008_04_23, mgrast_dev_06072011, rast_rel_2008_09_30, rast_rel_2009_0925, rast_rel_2010_0526, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, caBIG-05Apr06-00, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2010_0118, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, rast_rel_2009_02_05, rast_rel_2011_0119, mgrast_rel_2008_0625, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, rast_rel_2008_10_09, mgrast_dev_04012011, rast_release_2008_09_29, mgrast_rel_2008_0806, mgrast_rel_2008_0923, mgrast_rel_2008_0919, rast_rel_2009_07_09, rast_rel_2010_0827, mgrast_rel_2008_1110, myrast_33, rast_rel_2011_0928, rast_rel_2008_09_29, mgrast_rel_2008_0917, rast_rel_2008_10_29, mgrast_dev_04052011, mgrast_dev_02222011, caBIG-13Feb06-00, rast_rel_2009_03_26, mgrast_dev_10262011, rast_rel_2008_11_24, rast_rel_2008_08_07, HEAD
Changes since 1.8: +17 -0 lines
add license words

#
# Copyright (c) 2003-2006 University of Chicago and Fellowship
# for Interpretations of Genomes. All Rights Reserved.
#
# This file is part of the SEED Toolkit.
# 
# The SEED Toolkit is free software. You can redistribute
# it and/or modify it under the terms of the SEED Toolkit
# Public License. 
#
# You should have received a copy of the SEED Toolkit Public License
# along with this program; if not write to the University of Chicago
# at info@ci.uchicago.edu or the Fellowship for Interpretation of
# Genomes at veronika@thefig.info or download a copy from
# http://www.theseed.org/LICENSE.TXT.
#

use FIG;
use CGI;
use HTML;
use URI::Escape;

use strict;

my $cgi = new CGI;
my $fig = new FIG();

my @subs = sort $fig->all_subsystems();

my %all_genomes;

my $html = [];

push(@$html, $cgi->start_form(-action => "ss_scoreboard.cgi",
			      -method => "post"));
#
# Show the selection list for limiting to family.
#

my $taxonomic_groups = $fig->taxonomic_groups_of_complete(10);

my @group_names = sort grep { $_ ne "All" } map { $_->[0] } @$taxonomic_groups;

unshift(@group_names, "All");

#
# Display in a scrolling list.
#

push(@$html,
     $cgi->h2("Limit genomes shown to group:"),
     $cgi->scrolling_list(-name => 'limit_genome',
			  -values => [@group_names],
			  -default => "All",
			  -size => 5,
			  -multiple => 1),
     );


#
# Determine if we're limiting genomes, and only use
# genomes from that group if we are.
#

my @limit_genome = $cgi->param("limit_genome");
my %desired_genomes;

if (grep({$_ eq "All"} @limit_genome))
{
    @limit_genome = ();
}

if (@limit_genome)
{
    for my $limit_genome (@limit_genome)
    {
	my @list = grep({ $_->[0] eq $limit_genome } @$taxonomic_groups);
	for my $litem (@list)
	{
	    grep({ $desired_genomes{$_}++ }  @{$litem->[1]});
	}
    }
}

for my $subname (@subs)
{
    my $sub = $fig->get_subsystem($subname);
    next unless $sub;

    my @subg = $sub->get_genomes();
    for my $g (@subg)
    {
	next if @limit_genome and !$desired_genomes{$g};
	$all_genomes{$g}++;
    }
}

#
# Now display the list of subsystems. We'll do this in a table for now; it
# may take up a lot of space, but I think picking multiple subsystems from
# a dropdown might be clumsy.
#
# Hm. Maybe we'll do a dropdown first and see how it works...
#

my $list_size = @subs + 1;
$list_size = 10 if $list_size > 10;

push(@$html,
     $cgi->h2("Limit subsystems shown to ..."),
     $cgi->scrolling_list(-name => 'limit_subsystem',
			  -default => "All",
			  -values => ["All", @subs],
			  -size => $list_size,
			  -multiple => 1));

my @display_subs = $cgi->param("limit_subsystem");

if (!@display_subs or grep({ $_ eq "All"} @display_subs))
{
    @display_subs = @subs;
}

#
# Show the sort order options.
#

my @sort_options = qw(unsorted alphabetic by_phylo by_tax_id);

push(@$html, $cgi->h2("Select sort order"),
     $cgi->scrolling_list(-name => "sort_order",
			  -default => "alphabetic",
			  -values => [@sort_options],
			  -multiple => 0));

#
# And submit.
#

push(@$html,
     $cgi->p,
     $cgi->submit(-label => "Update scoreboard",
		  -name => 'update_button'));

#
# Show the table.
#
push(@$html, $cgi->hr, $cgi->h2("Scoreboard"));

my @col_hdrs = map { s/_/ /g; $_ } @display_subs;
unshift(@col_hdrs, "Genome", "Organism");

#
# Map col hdrs to links to vertical text
#

map {
    my $esc = uri_escape($_);
    my $tlink = "vert_text.cgi?str=$esc";
    my $alt = $_;

    $_ = "\@valign=\"bottom\":<img src=\"$tlink\" alt=\"$alt\">";
} @col_hdrs;

my @table;

push(@table, [@col_hdrs]);
@col_hdrs= ();

my @show_genomes = keys %all_genomes;

#
# Sort according to selected sort order.
#
# General plan here is to create a list of tuples
# [genome, <some annotation of genome>] and we sort on the
# annotation. Then we split the genome back out of the
# sorted list.
#

my $sort;
if ($sort = $cgi->param('sort_order'))
{
    if ($sort eq "by_phylo")
    {
	#
	# Annotate with the taxonomy of the genome.
	#
	my @annotated = map( { [$_, $fig->taxonomy_of($_)]} @show_genomes);
	@show_genomes = map( { $_->[0] }
			    sort( { $a->[1] cmp $b->[1] } @annotated));
    }
    elsif ($sort eq "by_tax_id")
    {
	#
	# Annotate with the genome id split on ".", and sort
	# numerically.
	#
	my @annotated = map( { [$_, split(/\./, $_,)]} @show_genomes);
	@show_genomes = map( { $_->[0] }
			    sort( { $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } @annotated));
    }
    elsif ($sort eq "alphabetic")
    {
	#
	# Annotate with genus/species and sort on that.
	#
	@show_genomes = map( { $_->[0] }
			    sort( { $a->[1] cmp $b->[1] }
				 map( { [$_, $fig->genus_species($_)]} @show_genomes)));
    }
}

#
# Create the table using the sorted list of genome ids.
#

for my $k (@show_genomes)
{
    my $c = $all_genomes{$k};
	
    my $row = [];

    #
    # Display genome id and name.
    #
    push(@$row, $k);
    push(@$row, &ext_genus_species($fig, $k));

    #
    # For each subsystem, look up the variant code and put in the table.
    #
    for my $subname (@display_subs)
    {
	my $sub = $fig->get_subsystem($subname);
	next unless $sub;
	my $vc = $sub->get_variant_code_for_genome($k);
	push(@$row, "\@align=\"center\":$vc");
    }
    push(@table, $row);
}


push(@$html, HTML::make_table(\@col_hdrs, \@table));

push(@$html, $cgi->end_form());

&HTML::show_page($cgi, $html);

sub ext_genus_species {
    my($fig,$genome) = @_;

    my $gs = $fig->genus_species($genome);
    my $c  = substr($fig->taxonomy_of($genome),0,1);
    return "$gs [$c]";
}
	

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3