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

Annotation of /FigWebServices/start.cgi

Parent Directory Parent Directory | Revision Log Revision Log


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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3