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

Annotation of /FigWebServices/start.cgi

Parent Directory Parent Directory | Revision Log Revision Log


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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3