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

View of /FigWebServices/start.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (download) (annotate)
Thu Jun 29 15:52:59 2006 UTC (13 years, 4 months ago) by overbeek
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
Changes since 1.9: +93 -9 lines
RAE: updated start interface

#
# 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.
#

#
# New-style front end.
#
# User login
# Dropdown for subsystems.
# Dropdown for orgs.
# Text search 
# Pattern search.
#

use CGI::Carp qw(fatalsToBrowser); # this makes debugging a lot easier by throwing errors out to the browser
use FIG;
use HTML;
use CGI;
use FIG_CGI;
use URI::Escape;
use raelib; my $raelib=new raelib; # this is just used for the cookies.

my($fig, $cgi, $user) = FIG_CGI::init(debug_save => 0,
				      debug_load => 0,
				      print_params => 0);

my $html = [];

#
# Cookie stuff should migrate to FIG_CGI
#
# my $user = $cgi->param('user') || [$raelib->cookie($cgi)]->[1]->{'user'} || "";

#
# This should too, if it's needed.
# if (! $cgi->param('user')) { $cgi->param(-name=>'user', -value=> $user) }


#my $click_js = <<'EJS';
#put the javascript in FIG.js with all the others to keep the html clean and reduce redundancy
    
push(@$html, $cgi->start_head,
     $cgi->title("Wecome to the SEED"),
     q(<body onload="document.search_form.search_string.focus(); document.search_form.search_string.value = 'Enter search terms'">));

push(@$html, $cgi->hidden("user"));

#
# Command handlers
#

# combinations:
#
# 1. text                  : c. search
# 2. text + org            : c. search limited to org
# 3. text + subsys         : a. search within subsystem
# 4. text + org + subsys   : a. search within subsystem
# 5. org                   : d. genome stats
# 6. org  + subsys         : b. subsystem display focussed on organism
# 7. subsys                : b. subsystem display

if (
    ($cgi->param('search_string') && $cgi->param('search_string') ne "Enter search terms") &&
    ($cgi->param('sel_subsystem') && $cgi->param('sel_subsystem') ne "Pick a subsystem")
   )
{
 # type a.
 # combo's 3 and 4. Genome is handled in the subroutine
 &do_subsys_search($cgi, $html);
}
if ($cgi->param('sel_subsystem') && $cgi->param('sel_subsystem') ne "Pick a subsystem")
{
 # type b.
 # combo's 6 and 7. Genome is handled in the subroutine
 &do_view_subsystem($cgi, $html);
}
if ($cgi->param('search_string') && $cgi->param('search_string') ne "Enter search terms")
{
 # type c
 # combo's 1 and 2. Genome is handled in the subroutine
 &do_text_search($cgi, $html);
}
if ($cgi->param('sel_genome') && $cgi->param('sel_genome') ne "Pick an organism")
{
 # type d
 # combo 5 only
 &do_view_genome($cgi, $html);
}
if ($cgi->param('go_old'))
{
 &do_go_old_seed($cgi, $html);
}

push(@$html, $cgi->start_form(-name => "search_form", -class => "firstform",
			      action => "start.cgi"));

gen_user_login($cgi, $html);

gen_text_search($cgi, $html);
push(@$html, $cgi->p);

gen_orglist_dropdown($cgi, $html);
push(@$html, $cgi->p);
gen_subsystem_dropdown($cgi, $html);

push(@$html,
     $cgi->p({-class=>"center"},
     $cgi->submit(-name => 'go', -value=>"Go!", -class=>"go"),
     ),
     $cgi->p({class=>"center"},
     $cgi->submit(-name => 'go_old',
		  -value => 'Advanced SEED entrypoint'),
     ),
     $cgi->end_form(),
     $cgi->a({href => "Html/help_front_page.html", class=>"help"}, "Help")
    );

my @hdr = &HTML::compute_html_header(undef, undef, no_fig_search => 1 );

push(@$html, $cgi->end_body);
open(T, ">/tmp/t.html");
print T join("", @$html);
close(T);

&HTML::show_page($cgi, $html, 1, \@hdr);

exit(0);

sub gen_user_login
{
    my($cgi, $html) = @_;
    #return if ($cgi->param('user'));
    my $inputclass='emptyuserinput';
    if ($cgi->param('user')) {$inputclass='knownuserinput'}
    
    push(@$html, $cgi->p({id=>"userid"}, "User ID:",
		 $cgi->textfield(-name => 'user',
				  -default => "",
				  -class => $inputclass),
		 $cgi->a({id=>"help", onMouseover=>"javascript:if(!this.tooltip) this.tooltip=new Popup_Tooltip(this, 'Help', '<b>Please use something like JohnDoe</b><br>Your username is unique to you but is not a security measure.<br>Please do not uses spaces or special characters in the username', ''); this.tooltip.addHandler(); return false;"}, Help),
		  ));
}

sub gen_subsystem_dropdown
{
    my($cgi, $html) = @_;

#    push(@$html, $cgi->h2("Subsystems"));

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

    my %labels;
    for my $v (@values)
    {
	my $l = $v;
	$l =~ s/_/ /g;
	$labels{$v} = $l;
    }

    $labels{_choose_sub} = "Pick a subsystem";
    unshift(@values, "_choose_sub");
    
    push (@$html,
	  $cgi->popup_menu(-name => 'sel_subsystem',
			   -style => "width: 4in",
			   -values => \@values,
			   -labels => \%labels,
			   -class => "sel_subsystem"),
          q(<a id="help" onMouseover="javascript:if(!this.tooltip) this.tooltip=new Popup_Tooltip(this, 'Help', '<b>Please choose a subsystem from this list</b>', ''); this.tooltip.addHandler(); return false;" >Help</a>),
	 );
	  
		   
}

sub gen_orglist_dropdown
{
    my($cgi, $html) = @_;

    my @values; 
    my $label;
    my $attribute;

    # this is just a hash that will put the bacteria first, then the euks, then the archs, and so on
    my %sort=(
	"Virus"=>'4',
	"Eukaryota"=>'3',
	"Bacteria"=>'1',
	"Archaea"=>'2',
	"unknown"=>'5',
	"Environmental Sample"=>'9',
    );


    my %count;
    foreach my $genome (
     sort {$sort{$fig->genome_domain($a)} <=> $sort{$fig->genome_domain($b)} 
           || uc($fig->genus_species($a)) cmp uc($fig->genus_species($b))} $fig->genomes(1)) {
	   	push @values, $genome;
           	$label->{$genome}=$fig->genus_species($genome), " ($genome)";
	   	$attribute->{$genome}={class=>$fig->genome_domain($genome)}; $attribute->{$genome}=~ s/\s+//g;
    } 

    unshift(@values, "_choose_org");
    $label->{_choose_org} = "Pick an organism";

    
    push (@$html, ($cgi->popup_menu(-name => 'sel_genome',
				    -style => "width: 4in",
				    -values => \@values,
				    -labels => $label,
				    -class => "sel_genome",
				    -attributes => $attribute),
    q(<a id="help" onMouseover="javascript:if(!this.tooltip) this.tooltip=new Popup_Tooltip(this, 'Help', '<b>Please choose an organism from this list.</b><br>The list shows the current organisms in the SEED database.<br>They have been grouped and colored so that <span class=\\'Bacteria\\'>Bacteria</span> appear first, and then <span class=\\'Archaea\\'>Archaea</span>, <span class=\\'Eukaryota\\'>Eukaryota</span>, <span class=\\'Viruses\\'>Viruses</span>, <span class=\\'unknown\\'>unclassified sequences</span>, and then <span class=\\'EnvironmentalSample\\'>Environmental Samples</span>.<br> Your search will be restricted to just the organism you choose, or if you do not enter a search term you will be taken to that organisms homepage.',''); this.tooltip.addHandler(); return false;" >Help</a>)));
}

sub gen_text_search
{
    my($cgi, $html) = @_;


    push(@$html, ($cgi->textfield(-name => 'search_string',
				  -default => 'Enter search terms',
				  -style => "width: 4in",
				  -override => 1,
				  -onClick => 'check_first_search_click(this)',
				  -size => 60),
	q(<a id="help" onMouseover="javascript:if(!this.tooltip) this.tooltip=new Popup_Tooltip(this, 'Help', '<b>Please enter some text to search.</b> You may enter the full or partial name of a functional role, an organism, or any other data.', ''); this.tooltip.addHandler(); return false;" >Help</a>),
		 ));
	  
}


sub do_subsys_search
{
    my($cgi, $html) = @_;

    #
    # Just redirect to the subsystem seearch page from index.cgi.
    #

    my $sub = $cgi->param('sel_subsystem');
    if ($sub eq "_choose_sub")
    {
	return;
    }
    my $esc_ssa = uri_escape($sub);
   
    my $str = $cgi->param('search_string'). " " . $sub;
    my $esc_str = uri_escape($str);
   
   
    my @params;
    push(@params, "subsearch=$esc_str");
    push(@params, "user=$user");
    #push(@params, "ssa_name=$esc_ssa");
    push(@params, "Find PEGs=1");
    
    if ($cgi->param('sel_genome')  ne "_choose_org")
    {
        push(@params, "genome=".$cgi->param('sel_genome'));
    }
    my $params = join("&", @params);
    
    #RAE: this was going to subsys.cgi, now we'll go to display subsys.cgi
    #my $sub_url = $fig->cgi_url() . "/subsys.cgi?$params";
    my $sub_url = $fig->cgi_url() . "/index.cgi?$params";
    print $cgi->redirect($sub_url);
    exit(0);
}

sub do_view_subsystem
{
    my($cgi, $html) = @_;

    #
    # Just redirect to the subsystem page.
    #

    my $sub = $cgi->param('sel_subsystem');
    if ($sub eq "_choose_sub")
    {
	return;
    }
    
    
    #
    # bring up clustered in phylogenetic sort
    #

    my $esc_ssa = uri_escape($sub);
    my @params;
    push(@params, "sort=by_phylo");
    push(@params, "show_clusters=1");
    push(@params, "request=show_ssa");
    push(@params, "user=$user");
    push(@params, "ssa_name=$esc_ssa");
    
    if ($cgi->param('sel_genome')  ne "_choose_org")
    {
        push(@params, "focus=".$cgi->param('sel_genome'));
    }
    my $params = join("&", @params);
    
    #RAE: this was going to subsys.cgi, now we'll go to display subsys.cgi
    #my $sub_url = $fig->cgi_url() . "/subsys.cgi?$params";
    my $sub_url = $fig->cgi_url() . "/display_subsys.cgi?$params";
    print $cgi->redirect($sub_url);
    exit(0);
}

sub do_view_genome
{
    my($cgi, $html) = @_;

    #
    # For now, redirect to the organism statistics page.
    #

    my $genome = $cgi->param('sel_genome');
    if ($genome eq "_choose_org")
    {
	return;
    }

    my $sub_url = $fig->cgi_url() . "/genome_statistics.cgi?user=$user&genome=$genome";
    #warn "Redirect to $sub_url\n";
    print $cgi->redirect($sub_url);
    exit 0;
}

sub do_text_search
{
    my($cgi, $html) = @_;

    my $str = $cgi->param('search_string');
    
    # limit searches by genome
    my $search;
    my $genome =  $cgi->param('sel_genome');
    if ($genome eq "_choose_org")
    {
        $search = "&Search=1";
    }
    else
    {
        $search = "&Search genome selected below=1&korgs=($genome)";
    }

    my $esc_str = uri_escape($str);
    
    my $redir = $fig->cgi_url() . "/index.cgi?pattern=$esc_str$search&user=$user";
    print $cgi->redirect($redir);
}
    
sub do_go_old_seed
{
    my($cgi, $html) = @_;
    
    my $url = $fig->cgi_url() . "/index.cgi?user=$user";
    print $cgi->redirect($url);
    exit 0;
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3