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

Annotation of /FigWebServices/start.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (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 : overbeek 1.10 use CGI::Carp qw(fatalsToBrowser); # this makes debugging a lot easier by throwing errors out to the browser
29 : olson 1.1 use FIG;
30 :     use HTML;
31 :     use CGI;
32 : olson 1.9 use FIG_CGI;
33 : olson 1.1 use URI::Escape;
34 : redwards 1.5 use raelib; my $raelib=new raelib; # this is just used for the cookies.
35 : olson 1.1
36 : olson 1.7 my($fig, $cgi, $user) = FIG_CGI::init(debug_save => 0,
37 :     debug_load => 0,
38 :     print_params => 0);
39 : olson 1.1
40 :     my $html = [];
41 :    
42 : olson 1.7 #
43 :     # Cookie stuff should migrate to FIG_CGI
44 :     #
45 :     # my $user = $cgi->param('user') || [$raelib->cookie($cgi)]->[1]->{'user'} || "";
46 :    
47 :     #
48 :     # This should too, if it's needed.
49 :     # if (! $cgi->param('user')) { $cgi->param(-name=>'user', -value=> $user) }
50 : redwards 1.5
51 : olson 1.1
52 : redwards 1.2 #my $click_js = <<'EJS';
53 :     #put the javascript in FIG.js with all the others to keep the html clean and reduce redundancy
54 : olson 1.1
55 :     push(@$html, $cgi->start_head,
56 :     $cgi->title("Wecome to the SEED"),
57 :     q(<body onload="document.search_form.search_string.focus(); document.search_form.search_string.value = 'Enter search terms'">));
58 :    
59 :     push(@$html, $cgi->hidden("user"));
60 :    
61 :     #
62 :     # Command handlers
63 :     #
64 :    
65 : overbeek 1.10 # combinations:
66 :     #
67 :     # 1. text : c. search
68 :     # 2. text + org : c. search limited to org
69 :     # 3. text + subsys : a. search within subsystem
70 :     # 4. text + org + subsys : a. search within subsystem
71 :     # 5. org : d. genome stats
72 :     # 6. org + subsys : b. subsystem display focussed on organism
73 :     # 7. subsys : b. subsystem display
74 :    
75 :     if (
76 :     ($cgi->param('search_string') && $cgi->param('search_string') ne "Enter search terms") &&
77 :     ($cgi->param('sel_subsystem') && $cgi->param('sel_subsystem') ne "Pick a subsystem")
78 :     )
79 :     {
80 :     # type a.
81 :     # combo's 3 and 4. Genome is handled in the subroutine
82 :     &do_subsys_search($cgi, $html);
83 :     }
84 :     if ($cgi->param('sel_subsystem') && $cgi->param('sel_subsystem') ne "Pick a subsystem")
85 :     {
86 :     # type b.
87 :     # combo's 6 and 7. Genome is handled in the subroutine
88 :     &do_view_subsystem($cgi, $html);
89 :     }
90 : redwards 1.2 if ($cgi->param('search_string') && $cgi->param('search_string') ne "Enter search terms")
91 :     {
92 : overbeek 1.10 # type c
93 :     # combo's 1 and 2. Genome is handled in the subroutine
94 : redwards 1.2 &do_text_search($cgi, $html);
95 :     }
96 :     if ($cgi->param('sel_genome') && $cgi->param('sel_genome') ne "Pick an organism")
97 :     {
98 : overbeek 1.10 # type d
99 :     # combo 5 only
100 : redwards 1.2 &do_view_genome($cgi, $html);
101 :     }
102 :     if ($cgi->param('go_old'))
103 :     {
104 :     &do_go_old_seed($cgi, $html);
105 :     }
106 : olson 1.1
107 : overbeek 1.6 push(@$html, $cgi->start_form(-name => "search_form", -class => "firstform",
108 :     action => "start.cgi"));
109 : olson 1.1
110 :     gen_user_login($cgi, $html);
111 :    
112 :     gen_text_search($cgi, $html);
113 :     push(@$html, $cgi->p);
114 :    
115 :     gen_orglist_dropdown($cgi, $html);
116 :     push(@$html, $cgi->p);
117 :     gen_subsystem_dropdown($cgi, $html);
118 :    
119 :     push(@$html,
120 : redwards 1.2 $cgi->p({-class=>"center"},
121 : overbeek 1.4 $cgi->submit(-name => 'go', -value=>"Go!", -class=>"go"),
122 : redwards 1.2 ),
123 :     $cgi->p({class=>"center"},
124 : olson 1.1 $cgi->submit(-name => 'go_old',
125 :     -value => 'Advanced SEED entrypoint'),
126 : redwards 1.2 ),
127 :     $cgi->end_form(),
128 :     $cgi->a({href => "Html/help_front_page.html", class=>"help"}, "Help")
129 :     );
130 : olson 1.1
131 :     my @hdr = &HTML::compute_html_header(undef, undef, no_fig_search => 1 );
132 :    
133 :     push(@$html, $cgi->end_body);
134 :     open(T, ">/tmp/t.html");
135 :     print T join("", @$html);
136 :     close(T);
137 :    
138 :     &HTML::show_page($cgi, $html, 1, \@hdr);
139 :    
140 :     exit(0);
141 :    
142 :     sub gen_user_login
143 :     {
144 :     my($cgi, $html) = @_;
145 : redwards 1.5 #return if ($cgi->param('user'));
146 : redwards 1.2 my $inputclass='emptyuserinput';
147 :     if ($cgi->param('user')) {$inputclass='knownuserinput'}
148 :    
149 :     push(@$html, $cgi->p({id=>"userid"}, "User ID:",
150 :     $cgi->textfield(-name => 'user',
151 :     -default => "",
152 :     -class => $inputclass),
153 :     $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),
154 : olson 1.1 ));
155 :     }
156 :    
157 :     sub gen_subsystem_dropdown
158 :     {
159 :     my($cgi, $html) = @_;
160 :    
161 :     # push(@$html, $cgi->h2("Subsystems"));
162 :    
163 :     my @values = sort $fig->all_subsystems();
164 :    
165 :     my %labels;
166 :     for my $v (@values)
167 :     {
168 :     my $l = $v;
169 :     $l =~ s/_/ /g;
170 :     $labels{$v} = $l;
171 :     }
172 :    
173 :     $labels{_choose_sub} = "Pick a subsystem";
174 :     unshift(@values, "_choose_sub");
175 :    
176 :     push (@$html,
177 :     $cgi->popup_menu(-name => 'sel_subsystem',
178 :     -style => "width: 4in",
179 :     -values => \@values,
180 : redwards 1.2 -labels => \%labels,
181 :     -class => "sel_subsystem"),
182 :     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>),
183 : olson 1.1 );
184 :    
185 :    
186 :     }
187 :    
188 :     sub gen_orglist_dropdown
189 :     {
190 :     my($cgi, $html) = @_;
191 :    
192 : redwards 1.2 my @values;
193 :     my $label;
194 :     my $attribute;
195 :    
196 :     # this is just a hash that will put the bacteria first, then the euks, then the archs, and so on
197 :     my %sort=(
198 :     "Virus"=>'4',
199 :     "Eukaryota"=>'3',
200 :     "Bacteria"=>'1',
201 :     "Archaea"=>'2',
202 :     "unknown"=>'5',
203 :     "Environmental Sample"=>'9',
204 :     );
205 :    
206 :    
207 :     my %count;
208 :     foreach my $genome (
209 :     sort {$sort{$fig->genome_domain($a)} <=> $sort{$fig->genome_domain($b)}
210 :     || uc($fig->genus_species($a)) cmp uc($fig->genus_species($b))} $fig->genomes(1)) {
211 :     push @values, $genome;
212 :     $label->{$genome}=$fig->genus_species($genome), " ($genome)";
213 :     $attribute->{$genome}={class=>$fig->genome_domain($genome)}; $attribute->{$genome}=~ s/\s+//g;
214 :     }
215 : olson 1.1
216 :     unshift(@values, "_choose_org");
217 : redwards 1.2 $label->{_choose_org} = "Pick an organism";
218 : olson 1.1
219 :    
220 :     push (@$html, ($cgi->popup_menu(-name => 'sel_genome',
221 :     -style => "width: 4in",
222 :     -values => \@values,
223 : redwards 1.2 -labels => $label,
224 :     -class => "sel_genome",
225 :     -attributes => $attribute),
226 :     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>)));
227 : olson 1.1 }
228 :    
229 :     sub gen_text_search
230 :     {
231 :     my($cgi, $html) = @_;
232 :    
233 :    
234 :     push(@$html, ($cgi->textfield(-name => 'search_string',
235 :     -default => 'Enter search terms',
236 :     -style => "width: 4in",
237 :     -override => 1,
238 :     -onClick => 'check_first_search_click(this)',
239 :     -size => 60),
240 : 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>),
241 : olson 1.1 ));
242 :    
243 :     }
244 :    
245 :    
246 : overbeek 1.10 sub do_subsys_search
247 :     {
248 :     my($cgi, $html) = @_;
249 :    
250 :     #
251 :     # Just redirect to the subsystem seearch page from index.cgi.
252 :     #
253 :    
254 :     my $sub = $cgi->param('sel_subsystem');
255 :     if ($sub eq "_choose_sub")
256 :     {
257 :     return;
258 :     }
259 :     my $esc_ssa = uri_escape($sub);
260 :    
261 :     my $str = $cgi->param('search_string'). " " . $sub;
262 :     my $esc_str = uri_escape($str);
263 :    
264 :    
265 :     my @params;
266 :     push(@params, "subsearch=$esc_str");
267 :     push(@params, "user=$user");
268 :     #push(@params, "ssa_name=$esc_ssa");
269 :     push(@params, "Find PEGs=1");
270 :    
271 :     if ($cgi->param('sel_genome') ne "_choose_org")
272 :     {
273 :     push(@params, "genome=".$cgi->param('sel_genome'));
274 :     }
275 :     my $params = join("&", @params);
276 :    
277 :     #RAE: this was going to subsys.cgi, now we'll go to display subsys.cgi
278 :     #my $sub_url = $fig->cgi_url() . "/subsys.cgi?$params";
279 :     my $sub_url = $fig->cgi_url() . "/index.cgi?$params";
280 :     print $cgi->redirect($sub_url);
281 :     exit(0);
282 :     }
283 :    
284 : olson 1.1 sub do_view_subsystem
285 :     {
286 :     my($cgi, $html) = @_;
287 :    
288 :     #
289 :     # Just redirect to the subsystem page.
290 :     #
291 :    
292 :     my $sub = $cgi->param('sel_subsystem');
293 :     if ($sub eq "_choose_sub")
294 :     {
295 :     return;
296 :     }
297 : overbeek 1.10
298 :    
299 : olson 1.1 #
300 :     # bring up clustered in phylogenetic sort
301 :     #
302 :    
303 :     my $esc_ssa = uri_escape($sub);
304 :     my @params;
305 :     push(@params, "sort=by_phylo");
306 :     push(@params, "show_clusters=1");
307 :     push(@params, "request=show_ssa");
308 :     push(@params, "user=$user");
309 :     push(@params, "ssa_name=$esc_ssa");
310 : overbeek 1.10
311 :     if ($cgi->param('sel_genome') ne "_choose_org")
312 :     {
313 :     push(@params, "focus=".$cgi->param('sel_genome'));
314 :     }
315 : olson 1.1 my $params = join("&", @params);
316 : overbeek 1.10
317 :     #RAE: this was going to subsys.cgi, now we'll go to display subsys.cgi
318 :     #my $sub_url = $fig->cgi_url() . "/subsys.cgi?$params";
319 :     my $sub_url = $fig->cgi_url() . "/display_subsys.cgi?$params";
320 : olson 1.1 print $cgi->redirect($sub_url);
321 : overbeek 1.10 exit(0);
322 : olson 1.1 }
323 :    
324 :     sub do_view_genome
325 :     {
326 :     my($cgi, $html) = @_;
327 :    
328 :     #
329 :     # For now, redirect to the organism statistics page.
330 :     #
331 :    
332 :     my $genome = $cgi->param('sel_genome');
333 :     if ($genome eq "_choose_org")
334 :     {
335 :     return;
336 :     }
337 :    
338 :     my $sub_url = $fig->cgi_url() . "/genome_statistics.cgi?user=$user&genome=$genome";
339 : redwards 1.2 #warn "Redirect to $sub_url\n";
340 : olson 1.1 print $cgi->redirect($sub_url);
341 :     exit 0;
342 :     }
343 :    
344 :     sub do_text_search
345 :     {
346 :     my($cgi, $html) = @_;
347 :    
348 :     my $str = $cgi->param('search_string');
349 : overbeek 1.10
350 :     # limit searches by genome
351 :     my $search;
352 :     my $genome = $cgi->param('sel_genome');
353 :     if ($genome eq "_choose_org")
354 :     {
355 :     $search = "&Search=1";
356 :     }
357 :     else
358 :     {
359 :     $search = "&Search genome selected below=1&korgs=($genome)";
360 :     }
361 : olson 1.1
362 :     my $esc_str = uri_escape($str);
363 :    
364 : overbeek 1.10 my $redir = $fig->cgi_url() . "/index.cgi?pattern=$esc_str$search&user=$user";
365 : olson 1.1 print $cgi->redirect($redir);
366 :     }
367 :    
368 :     sub do_go_old_seed
369 :     {
370 :     my($cgi, $html) = @_;
371 :    
372 :     my $url = $fig->cgi_url() . "/index.cgi?user=$user";
373 :     print $cgi->redirect($url);
374 :     exit 0;
375 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3