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

Annotation of /FigWebServices/start.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (view) (download)

1 : olson 1.1 #
2 : olson 1.8 # Copyright (c) 2003-2006 University of Chicago and Fellowship
3 :     # for Interpretations of Genomes. All Rights Reserved.
4 :     #
5 :     # This file is part of the SEED Toolkit.
6 :     #
7 :     # The SEED Toolkit is free software. You can redistribute
8 :     # it and/or modify it under the terms of the SEED Toolkit
9 :     # Public License.
10 :     #
11 :     # You should have received a copy of the SEED Toolkit Public License
12 :     # along with this program; if not write to the University of Chicago
13 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
14 :     # Genomes at veronika@thefig.info or download a copy from
15 :     # http://www.theseed.org/LICENSE.TXT.
16 :     #
17 :    
18 :     #
19 : olson 1.1 # New-style front end.
20 :     #
21 :     # User login
22 :     # Dropdown for subsystems.
23 :     # Dropdown for orgs.
24 :     # Text search
25 :     # Pattern search.
26 :     #
27 :    
28 :     use FIG;
29 :     use HTML;
30 :     use CGI;
31 :     use URI::Escape;
32 : redwards 1.5 use raelib; my $raelib=new raelib; # this is just used for the cookies.
33 : olson 1.1
34 : olson 1.7 my($fig, $cgi, $user) = FIG_CGI::init(debug_save => 0,
35 :     debug_load => 0,
36 :     print_params => 0);
37 : olson 1.1
38 :     my $html = [];
39 :    
40 : olson 1.7 #
41 :     # Cookie stuff should migrate to FIG_CGI
42 :     #
43 :     # my $user = $cgi->param('user') || [$raelib->cookie($cgi)]->[1]->{'user'} || "";
44 :    
45 :     #
46 :     # This should too, if it's needed.
47 :     # if (! $cgi->param('user')) { $cgi->param(-name=>'user', -value=> $user) }
48 : redwards 1.5
49 : olson 1.1
50 : redwards 1.2 #my $click_js = <<'EJS';
51 :     #put the javascript in FIG.js with all the others to keep the html clean and reduce redundancy
52 : olson 1.1
53 :     push(@$html, $cgi->start_head,
54 :     $cgi->title("Wecome to the SEED"),
55 :     q(<body onload="document.search_form.search_string.focus(); document.search_form.search_string.value = 'Enter search terms'">));
56 :    
57 :     push(@$html, $cgi->hidden("user"));
58 :    
59 :     #
60 :     # Command handlers
61 :     #
62 :    
63 : redwards 1.2 if ($cgi->param('search_string') && $cgi->param('search_string') ne "Enter search terms")
64 :     {
65 :     &do_text_search($cgi, $html);
66 :     }
67 :     if ($cgi->param('sel_genome') && $cgi->param('sel_genome') ne "Pick an organism")
68 :     {
69 :     &do_view_genome($cgi, $html);
70 :     }
71 :     if ($cgi->param('sel_subsystem') && $cgi->param('sel_subsystem') ne "Pick a subsystem")
72 :     {
73 :     &do_view_subsystem($cgi, $html);
74 :     }
75 :     if ($cgi->param('go_old'))
76 :     {
77 :     &do_go_old_seed($cgi, $html);
78 :     }
79 : olson 1.1
80 : overbeek 1.6 push(@$html, $cgi->start_form(-name => "search_form", -class => "firstform",
81 :     action => "start.cgi"));
82 : olson 1.1
83 :     gen_user_login($cgi, $html);
84 :    
85 :     gen_text_search($cgi, $html);
86 :     push(@$html, $cgi->p);
87 :    
88 :     gen_orglist_dropdown($cgi, $html);
89 :     push(@$html, $cgi->p);
90 :     gen_subsystem_dropdown($cgi, $html);
91 :    
92 :     push(@$html,
93 : redwards 1.2 $cgi->p({-class=>"center"},
94 : overbeek 1.4 $cgi->submit(-name => 'go', -value=>"Go!", -class=>"go"),
95 : redwards 1.2 ),
96 :     $cgi->p({class=>"center"},
97 : olson 1.1 $cgi->submit(-name => 'go_old',
98 :     -value => 'Advanced SEED entrypoint'),
99 : redwards 1.2 ),
100 :     $cgi->end_form(),
101 :     $cgi->a({href => "Html/help_front_page.html", class=>"help"}, "Help")
102 :     );
103 : olson 1.1
104 :     my @hdr = &HTML::compute_html_header(undef, undef, no_fig_search => 1 );
105 :    
106 :     push(@$html, $cgi->end_body);
107 :     open(T, ">/tmp/t.html");
108 :     print T join("", @$html);
109 :     close(T);
110 :    
111 :     &HTML::show_page($cgi, $html, 1, \@hdr);
112 :    
113 :     exit(0);
114 :    
115 :     sub gen_user_login
116 :     {
117 :     my($cgi, $html) = @_;
118 : redwards 1.5 #return if ($cgi->param('user'));
119 : redwards 1.2 my $inputclass='emptyuserinput';
120 :     if ($cgi->param('user')) {$inputclass='knownuserinput'}
121 :    
122 :     push(@$html, $cgi->p({id=>"userid"}, "User ID:",
123 :     $cgi->textfield(-name => 'user',
124 :     -default => "",
125 :     -class => $inputclass),
126 :     $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),
127 : olson 1.1 ));
128 :     }
129 :    
130 :     sub gen_subsystem_dropdown
131 :     {
132 :     my($cgi, $html) = @_;
133 :    
134 :     # push(@$html, $cgi->h2("Subsystems"));
135 :    
136 :     my @values = sort $fig->all_subsystems();
137 :    
138 :     my %labels;
139 :     for my $v (@values)
140 :     {
141 :     my $l = $v;
142 :     $l =~ s/_/ /g;
143 :     $labels{$v} = $l;
144 :     }
145 :    
146 :     $labels{_choose_sub} = "Pick a subsystem";
147 :     unshift(@values, "_choose_sub");
148 :    
149 :     push (@$html,
150 :     $cgi->popup_menu(-name => 'sel_subsystem',
151 :     -style => "width: 4in",
152 :     -values => \@values,
153 : redwards 1.2 -labels => \%labels,
154 :     -class => "sel_subsystem"),
155 :     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>),
156 : olson 1.1 );
157 :    
158 :    
159 :     }
160 :    
161 :     sub gen_orglist_dropdown
162 :     {
163 :     my($cgi, $html) = @_;
164 :    
165 : redwards 1.2 my @values;
166 :     my $label;
167 :     my $attribute;
168 :    
169 :     # this is just a hash that will put the bacteria first, then the euks, then the archs, and so on
170 :     my %sort=(
171 :     "Virus"=>'4',
172 :     "Eukaryota"=>'3',
173 :     "Bacteria"=>'1',
174 :     "Archaea"=>'2',
175 :     "unknown"=>'5',
176 :     "Environmental Sample"=>'9',
177 :     );
178 :    
179 :    
180 :     my %count;
181 :     foreach my $genome (
182 :     sort {$sort{$fig->genome_domain($a)} <=> $sort{$fig->genome_domain($b)}
183 :     || uc($fig->genus_species($a)) cmp uc($fig->genus_species($b))} $fig->genomes(1)) {
184 :     push @values, $genome;
185 :     $label->{$genome}=$fig->genus_species($genome), " ($genome)";
186 :     $attribute->{$genome}={class=>$fig->genome_domain($genome)}; $attribute->{$genome}=~ s/\s+//g;
187 :     }
188 : olson 1.1
189 :     unshift(@values, "_choose_org");
190 : redwards 1.2 $label->{_choose_org} = "Pick an organism";
191 : olson 1.1
192 :    
193 :     push (@$html, ($cgi->popup_menu(-name => 'sel_genome',
194 :     -style => "width: 4in",
195 :     -values => \@values,
196 : redwards 1.2 -labels => $label,
197 :     -class => "sel_genome",
198 :     -attributes => $attribute),
199 :     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>)));
200 : olson 1.1 }
201 :    
202 :     sub gen_text_search
203 :     {
204 :     my($cgi, $html) = @_;
205 :    
206 :    
207 :     push(@$html, ($cgi->textfield(-name => 'search_string',
208 :     -default => 'Enter search terms',
209 :     -style => "width: 4in",
210 :     -override => 1,
211 :     -onClick => 'check_first_search_click(this)',
212 :     -size => 60),
213 : redwards 1.2 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>),
214 : olson 1.1 ));
215 :    
216 :     }
217 :    
218 :    
219 :     sub do_view_subsystem
220 :     {
221 :     my($cgi, $html) = @_;
222 :    
223 :     #
224 :     # Just redirect to the subsystem page.
225 :     #
226 :    
227 :     my $sub = $cgi->param('sel_subsystem');
228 :     if ($sub eq "_choose_sub")
229 :     {
230 :     return;
231 :     }
232 :     #
233 :     # bring up clustered in phylogenetic sort
234 :     #
235 :    
236 :     my $esc_ssa = uri_escape($sub);
237 :    
238 :     my @params;
239 :     push(@params, "sort=by_phylo");
240 :     push(@params, "show_clusters=1");
241 :     push(@params, "request=show_ssa");
242 :     push(@params, "user=$user");
243 :     push(@params, "ssa_name=$esc_ssa");
244 :    
245 :     my $params = join("&", @params);
246 :     my $sub_url = $fig->cgi_url() . "/subsys.cgi?$params";
247 :     print $cgi->redirect($sub_url);
248 :     exit 0;
249 :     }
250 :    
251 :     sub do_view_genome
252 :     {
253 :     my($cgi, $html) = @_;
254 :    
255 :     #
256 :     # For now, redirect to the organism statistics page.
257 :     #
258 :    
259 :     my $genome = $cgi->param('sel_genome');
260 :     if ($genome eq "_choose_org")
261 :     {
262 :     return;
263 :     }
264 :    
265 :     my $sub_url = $fig->cgi_url() . "/genome_statistics.cgi?user=$user&genome=$genome";
266 : redwards 1.2 #warn "Redirect to $sub_url\n";
267 : olson 1.1 print $cgi->redirect($sub_url);
268 :     exit 0;
269 :     }
270 :    
271 :     sub do_text_search
272 :     {
273 :     my($cgi, $html) = @_;
274 :    
275 :     my $str = $cgi->param('search_string');
276 :    
277 :     my $esc_str = uri_escape($str);
278 :    
279 :     my $redir = $fig->cgi_url() . "/index.cgi?pattern=$esc_str&Search=1&user=$user";
280 :     print $cgi->redirect($redir);
281 :     }
282 :    
283 :     sub do_go_old_seed
284 :     {
285 :     my($cgi, $html) = @_;
286 :    
287 :     my $url = $fig->cgi_url() . "/index.cgi?user=$user";
288 :     print $cgi->redirect($url);
289 :     exit 0;
290 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3