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

View of /FigWebServices/start.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (download) (annotate)
Tue Oct 18 20:55:51 2005 UTC (14 years, 4 months ago) by overbeek
Branch: MAIN
Changes since 1.5: +2 -1 lines
fix relative path stuff.

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

use FIG;
use HTML;
use CGI;
use URI::Escape;
use raelib; my $raelib=new raelib; # this is just used for the cookies.

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

my $html = [];

my $user = $cgi->param('user') || [$raelib->cookie($cgi)]->[1]->{'user'} || "";
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
#

if ($cgi->param('search_string') && $cgi->param('search_string') ne "Enter search terms")
{
 &do_text_search($cgi, $html);
}
if ($cgi->param('sel_genome') && $cgi->param('sel_genome') ne "Pick an organism")
{
 &do_view_genome($cgi, $html);
}
if ($cgi->param('sel_subsystem') && $cgi->param('sel_subsystem') ne "Pick a subsystem")
{
 &do_view_subsystem($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_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");

    my $params = join("&", @params);
    my $sub_url = $fig->cgi_url() . "/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');

    my $esc_str = uri_escape($str);
    
    my $redir = $fig->cgi_url() . "/index.cgi?pattern=$esc_str&Search=1&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