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

Annotation of /FigWebServices/start.cgi

Parent Directory Parent Directory | Revision Log Revision Log


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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3