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

Annotation of /FigWebServices/start.cgi

Parent Directory Parent Directory | Revision Log Revision Log


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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3