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

View of /FigWebServices/list_subsys.cgi

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.1 - (download) (annotate)
Fri Aug 11 21:10:42 2006 UTC (13 years, 10 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, 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, rast_rel_2009_03_26, mgrast_dev_10262011, rast_rel_2008_11_24, rast_rel_2008_08_07, HEAD

# -*- perl -*-
# 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 FIG_Config;
use FIGjs;  # mouseover()
use GD;
use MIME::Base64;

my $fig = new FIG;

use Subsystem;

use URI::Escape;  # uri_escape()
use HTML;
use strict;
use tree_utilities;

use CGI;
use CGI::Carp qw(fatalsToBrowser); # this makes debugging a lot easier by throwing errors out to the browser

my $cgi = new CGI;

$ENV{"PATH"} = "$FIG_Config::bin:$FIG_Config::ext_bin:" . $ENV{"PATH"};

if (0)
    my $VAR1;
    eval(join("",`cat /tmp/ssa_parms`));
    $cgi = $VAR1;
#   print STDERR &Dumper($cgi);

if (0)
    print $cgi->header;
    my @params = $cgi->param;
    print "<pre>\n";
    foreach $_ (@params)
        print "$_\t:",join(",",$cgi->param($_)),":\n";

    if (0)
        if (open(TMP,">/tmp/ssa_parms"))
            print TMP &Dumper($cgi);

my $html = [];
push @$html, "<TITLE>SEED Subsystems</TITLE>\n"; # RAE: every page deserves a title

my $user = $cgi->param('user'); 




sub show_initial {
    # a new first page written by Rob
    my($fig,$cgi,$html) = @_;

    # we get this information here and set things so that when we create the links later everything is already set.
    my $sort = $cgi->param('sortby');
    unless ($sort) {$sort="Classification"}
    my $show_clusters=$cgi->param('show_clusters');
    my $sort_ss=$cgi->param('sort');
    my $minus=$cgi->param('show_minus1');
    my $show_genomes=$cgi->param('showgenomecounts');
    # now set the values into $cgi so that we have them for later
    $cgi->param('sortby', $sort); # this is the table sort
    $cgi->param('show_clusters', $show_clusters); # whether or not to show the clusters
    $cgi->param('sort', $sort_ss); # this is the sort of the organisms in display
    $cgi->param('show_minus1', $minus); # whether to show -1 variants
    $cgi->param('showgenomecounts', $show_genomes); # whether to show genomes on the first page
    my @ssa = map {
     my $ss=$_;
     my ($version, $curator, $pedigree, $roles)=$fig->subsystem_info($ss->[0]);
     push @$ss, scalar(@$roles), $version;
     push @$ss, scalar(@{$fig->subsystem_genomes($ss->[0])}) if ($cgi->param('showgenomecounts'));
     $fig->subsystem_classification($ss->[0], [$cgi->param($ss->[0].".class1"), $cgi->param($ss->[0].".class2")]) if ($cgi->param($ss->[0].".class1"));
     unshift @$ss, @{$fig->subsystem_classification($ss->[0])};
     if ($ss->[3] eq $user) {$ss->[3] = [$ss->[3], "td style='background-color: #BA55D3'"]}
    # sort the cells
    if ($sort eq "Classification")     {@ssa=sort {uc($a->[0]) cmp uc($b->[0]) || uc($a->[1]) cmp uc($b->[1]) || uc($a->[2]) cmp uc($b->[2])} @ssa}
    elsif ($sort eq "Subsystem")       {@ssa=sort {uc($a->[2]) cmp uc($b->[2])} @ssa}
    elsif ($sort eq "Curator")         {@ssa=sort {uc($a->[3]) cmp uc($b->[3])} @ssa}
    elsif ($sort eq "Number of Roles") {@ssa=sort {$a->[4] <=> $b->[4]} @ssa}
    elsif ($sort eq "Version")         {@ssa=sort {$a->[5] <=> $b->[5]} @ssa}
    ##### Add the ability to change empty classifications
    # get the complete list of classifications
    my %class1=(""=>1); my %class2=(""=>1);
    map {$class1{$_->[0]}++; $class2{$_->[1]}++} @ssa;

    # replace empty classifications with the popup_menus and create links
    # Disabled this because it is causing the page to load _very_ slowly as the browser has to render all the menus
    # two alternatives: put only a popup for the first field if both are empty and then a popup for the second if neither are empty
    # or put textfields to allow people to cut/paste.
    map {
     my $ss=$_;
     unless (1 || $ss->[0])  # remove the '1 ||' from this line to reinstate the menus
      $ss->[0] = $cgi->popup_menu(-name=>$ss->[2].".class1", -values=>[sort {$a cmp $b} keys %class1]);
      $ss->[1] = $cgi->popup_menu(-name=>$ss->[2].".class2", -values=>[sort {$a cmp $b} keys %class2]);
     $ss->[2]=&ssa_link($fig, $ss->[2], $user);
    } @ssa;

    my $col_hdrs=[["Classification", "th colspan=2 style='text-align: center'"], "Subsystem", "Curator", "Number of Roles", "Version"];
    push @$col_hdrs, "Number of Genomes" if ($cgi->param('showgenomecounts'));
    my $tab=HTML->merge_table_rows(\@ssa);
    my $url = &FIG::cgi_url . "/subsys.cgi?user=$user&request=manage_ss";
    my $target = "window$$";
    my %sortmenu=(
        by_variant=>"Variant Code",

     $cgi->start_form(-action => "subsys.cgi"),
     "<div class='ssinstructions'>\n",
     "Please choose one of the subsystems from this list, or begin working on your own by entering a name in the box at the bottom of the page. ",
     "We suggest that you take some time to look at the subsystems others have developed before working on your own.",
     "<ul><li>Please do not ever edit someone else's spreadsheet</li>\n<li>Please do not open multiple windows to process the same spreadsheet.</li>",
     "<li>Feel free to open a subsystem spreadsheet and then open multiple other SEED windows to access data and modify annotations.</li>",
     "<li>You can access someone else's subsystem spreadsheet using your ID</li>",
     "<li>To change the classification of an unclassified subsystem, choose the desired classification from the menus and click Update Table View</li>");

    push @$html, "<li>You can <a href='$url&manage=mine'>manage your subsystems</a></li>" if ($user);
     "<li>You can <a href='$url'>manage all subsystems</a></li>",
     "<div class='page_settings' style='width: 75%; margin-left: auto; margin-right: auto'>Please enter your username: ", $cgi->textfield(-name=>"user"), "\n",
     "<table border=1>\n",
     "<tr><th>Settings for this page</th><th>Settings for the links to the next page.<br>Change these and click Update Table View.</th></tr>\n",
        "<td valign=center>Sort table by</td><td valign=center>",  
        $cgi->popup_menu(-name=>'sortby', -values=>['Classification', 'Subsystem', 'Curator', 'Number of Roles', 'Version'], -default=>$sort), "</td></tr></table\n",
        "<td valign=center>Show clusters</td><td valign=center>", $cgi->checkbox(-name=>'show_clusters', -label=>''), "</td>\n", 
        "<td valign=center>Default Spreadsheet Sorted By:</td><td valign=center>", 
        $cgi->popup_menu(-name => 'sort', -values => [keys %sortmenu], -labels=>\%sortmenu),
     $cgi->submit('Update Table View'), $cgi->reset, $cgi->p,

#    $cgi->h3('To start a new subsystem'), $cgi->p("Please enter the name of the subsystem that you would like to start. You will be provided with a blank",
#    " form that you can fill in with the roles and genomes to create a subsystem like those above."),
#    $cgi->start_form(-action => "subsys.cgi",
#                                 -target => $target,
#                                 -method => 'post'),
#    $cgi->hidden(-name => 'user', -value => $user, -override => 1),
#    $cgi->hidden(-name => 'request', -value => 'new_ssa', -override => 1),
#    "Name of New Subsystem: ",
#    $cgi->textfield(-name => "ssa_name", -size => 50),
#    $cgi->hidden(-name => 'can_alter', -value => 1, -override => 1),
#    $cgi->br,
#    $cgi->submit('start new subsystem'),

# RAE: I think this should be placed as a method in
# Subsystems.pm and called subsystems I know about or something.
# Cowardly didn't do though :-)
sub existing_subsystem_annotations {
    my($fig) = @_;
    my @ssa = ();
    if (opendir(SSA,"$FIG_Config::data/Subsystems"))
        @ssa = map { $ssa = $_; $name = $ssa; $ssa =~ s/[ \/]/_/g; [$name,&subsystem_curator($ssa)] } grep { $_ !~ /^\./ } readdir(SSA);
    # RAE Adding sort of current subsystems
    if ($cgi->param('colsort') && $cgi->param('colsort') eq "curator")
     # sort by the ss curator
     return sort { (lc $a->[1]) cmp (lc $b->[1]) || (lc $a->[0]) cmp (lc $b->[0]) } @ssa;
     return sort { (lc $a->[0]) cmp (lc $b->[0]) } @ssa;

sub ssa_link {
    my($fig,$ssa,$user) = @_;
    my $name = $ssa; $name =~ s/_/ /g;
    my $target = "window$$";
    if ($name =~ /([a-zA-Z]{3})/)
        $target .= ".$1";

    my $esc_ssa = uri_escape($ssa);
    my $show_clusters = 1;
    my $minus  = 0;
    my $url = &FIG::cgi_url . "/display_subsys.cgi?ssa_name=$esc_ssa&show_clusters=$show_clusters&show_minus1=$minus";
    return "<a href=$url target=$target>$name</a>";

sub subsystem_curator {
    my($ssa) = @_;

    my $curator = $fig->subsystem_curator($ssa);

    if ($curator !~ /^master:/) { $curator = "master:$curator" }
    return $curator;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3