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

Annotation of /FigWebServices/start.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (view) (download)

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3