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

Annotation of /FigWebServices/wc.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (view) (download)

1 : overbeek 1.1 # -*- perl -*-
2 :     #
3 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
4 :     # for Interpretations of Genomes. All Rights Reserved.
5 :     #
6 :     # This file is part of the SEED Toolkit.
7 :     #
8 :     # The SEED Toolkit is free software. You can redistribute
9 :     # it and/or modify it under the terms of the SEED Toolkit
10 :     # Public License.
11 :     #
12 :     # You should have received a copy of the SEED Toolkit Public License
13 :     # along with this program; if not write to the University of Chicago
14 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
15 :     # Genomes at veronika@thefig.info or download a copy from
16 :     # http://www.theseed.org/LICENSE.TXT.
17 :     #
18 :    
19 : olson 1.13 eval {
20 :     require FIG_Config;
21 :     };
22 :    
23 : overbeek 1.1 use URI::Escape; # uri_escape
24 :     use gjoseqlib;
25 :     use HTML;
26 :     use strict;
27 :     use CGI;
28 :     my $cgi = new CGI;
29 :     use SeedEnv;
30 :     use tree_utilities;
31 :     use CloseStrains;
32 :    
33 :     if (0) {
34 :     print $cgi->header;
35 :     my @params = $cgi->param;
36 :     print "<pre>\n";
37 :     foreach $_ (@params) {
38 :     print "$_\t:",join(",",$cgi->param($_)),":\n";
39 :     }
40 :     print "\n",join('&',map { "$_=" . $cgi->param($_) } @params),"\n";
41 :     exit;
42 :     }
43 :    
44 :     my $html = [];
45 :    
46 :     my $node = $cgi->param('node');
47 :     my $family = $cgi->param('family');
48 : overbeek 1.10 my $genome = $cgi->param('genome');
49 : overbeek 1.1 my $ali = $cgi->param('alignment');
50 :     my $tree = $cgi->param('tree');
51 :     my $request = $cgi->param('request');
52 :     my $keywords = $cgi->param('keywords');
53 :     my $function = $cgi->param('function');
54 : overbeek 1.10 my $reaction = $cgi->param('reaction');
55 : overbeek 1.1 my $dataD = $cgi->param('dataD');
56 : overbeek 1.14 my $base = $cgi->param('base');
57 : olson 1.13 #
58 :     # If we are operating in RAST, the csD sits within the
59 :     # RAST job directory and the dataD setting is the
60 :     # RAST job number.
61 :     #
62 :    
63 : overbeek 1.14 my $csD;
64 :     if ($base)
65 :     {
66 :     $csD = $base;
67 :     }
68 :     else
69 :     {
70 :     $csD = "/homes/overbeek/Ross/MakeCS.Kbase/Data/CS";
71 :     }
72 : olson 1.13 if ($FIG_Config::rast_jobs && -d $FIG_Config::rast_jobs)
73 :     {
74 :     $csD = "$FIG_Config::rast_jobs/$dataD/CloseStrains";
75 :     }
76 :    
77 : overbeek 1.2 my $dataDF = "$csD/$dataD";
78 :    
79 :     my $parms = {};
80 :    
81 :     $parms->{genome_types} = &CloseStrains::genome_types($dataDF);
82 :     $parms->{dataDF} = $dataDF;
83 : overbeek 1.1
84 :     if ($request eq "show_otus")
85 :     {
86 : overbeek 1.14 &show_otus($cgi,$csD,$base);
87 : overbeek 1.1 exit;
88 :     }
89 :     elsif (($request eq "show_options_for_otu") && $dataD)
90 :     {
91 : overbeek 1.14 $html = &CloseStrains::show_options_for_otu($cgi,$dataD,$dataDF,$base);
92 :     push(@$html,"<a target=_blank href=./wc.cgi?dataD=$dataD&base=$base&request=newick_tree>Newick Tree</a>\n");
93 :     }
94 :     elsif ($request eq "newick_tree")
95 :     {
96 :     if (open(TREE,"<$dataDF/estimated.phylogeny.nwk"))
97 :     {
98 :     my @tree = map { $_ =~ s/,/,\n/g; $_ } <TREE>;
99 :    
100 :     push(@$html,"<pre>",@tree,"</pre>");
101 :     close(TREE);
102 :     }
103 : overbeek 1.1 }
104 :     elsif ($request eq "show_signatures")
105 :     {
106 : overbeek 1.14 &CloseStrains::show_signatures($cgi,$parms,$html,$base);
107 : overbeek 1.1 }
108 : overbeek 1.10 elsif ($request eq "show_signatures_reactions")
109 :     {
110 : overbeek 1.14 &CloseStrains::show_signatures_reactions($cgi,$parms,$html,$base);
111 : overbeek 1.10 }
112 : overbeek 1.1 elsif ($request eq "compute_sigs")
113 :     {
114 : overbeek 1.14 &CloseStrains::compute_signatures($cgi,$parms,$html,$base);
115 : overbeek 1.1 }
116 : overbeek 1.10 elsif ($request eq "compute_signatures_reactions")
117 :     {
118 :     &CloseStrains::compute_signatures_reactions($cgi,$parms,$html);
119 :     }
120 : overbeek 1.1 elsif (($request eq "show_func") && $function)
121 :     {
122 :     $function =~ s/^\s+//;
123 :     $function =~ s/\s+$//;
124 : overbeek 1.14 &CloseStrains::show_func($cgi,$parms,$html,$function,$base);
125 : overbeek 1.1 }
126 :     elsif (($request eq "show_family_pegs") && $family)
127 :     {
128 : overbeek 1.14 &CloseStrains::show_family_pegs($cgi,$parms,$html,$family,$base);
129 : overbeek 1.1 }
130 :     elsif (($request eq "show_virulence_functions") && (-s "$dataDF/virulence.functions"))
131 :     {
132 : overbeek 1.14 &CloseStrains::show_virulence_functions($cgi,$parms,$html,$base);
133 : overbeek 1.1 }
134 :     elsif (($request eq 'show_indexed_funcs') && $keywords)
135 :     {
136 : overbeek 1.14 &CloseStrains::show_indexed_funcs($cgi,$parms,$html,$keywords,$base);
137 : overbeek 1.1 }
138 :     elsif (($request eq "show_ali_or_occurs_tree") && $ali)
139 :     {
140 : overbeek 1.14 &CloseStrains::show_ali($cgi,$parms,$base); # NOTE: the alignment invokes Gary's alignment viewer,
141 : overbeek 1.1 # which prints the header, so we print everything in show_ali
142 :     exit;
143 :     }
144 :     elsif (($request eq "show_ali_or_occurs_tree") && $tree)
145 :     {
146 : overbeek 1.14 &CloseStrains::show_occurs_tree($cgi,$parms,$html,$base);
147 : overbeek 1.1 }
148 :     elsif (($request eq "show_family_tree") && $family)
149 :     {
150 : overbeek 1.14 &CloseStrains::show_family_tree($cgi,$parms,$html,$family,$base);
151 : overbeek 1.1 }
152 :     elsif (($request eq "show_node") && $node)
153 :     {
154 : overbeek 1.14 &CloseStrains::show_node($cgi,$parms,$html,$node,$base);
155 : overbeek 1.1 }
156 :     elsif ($request eq "show_otu_tree")
157 :     {
158 : overbeek 1.14 &CloseStrains::show_otu_tree($cgi,$parms,$html,'families',$base);
159 : overbeek 1.1 }
160 : overbeek 1.10 elsif ($request eq "show_reactions")
161 :     {
162 : overbeek 1.14 &CloseStrains::show_reactions($cgi,$parms,$html,$base);
163 : overbeek 1.10 }
164 :     elsif (($request eq "show_reaction_on_tree") && $reaction)
165 :     {
166 : overbeek 1.14 &CloseStrains::show_reaction_on_tree($cgi,$reaction,$parms,$html,$base);
167 : overbeek 1.10 }
168 :     elsif (($request eq "show_reaction_genome_data") && $reaction && $genome)
169 :     {
170 : overbeek 1.14 &CloseStrains::show_reaction_genome_data($cgi,$reaction,$genome,$dataDF,$parms,$html,$base);
171 : overbeek 1.10 }
172 :     elsif ($request eq "show_options_for_reactions")
173 :     {
174 : overbeek 1.14 &CloseStrains::show_options_for_reactions($cgi,$html,$dataD,$dataDF,$base);
175 :     # &CloseStrains::show_signatures_reactions($cgi,$parms,$html,$base);
176 : overbeek 1.11 }
177 :     elsif ($request eq "show_otu_tree_reactions")
178 :     {
179 : overbeek 1.14 &CloseStrains::show_otu_tree($cgi,$parms,$html,'reactions',$base);
180 : overbeek 1.10 }
181 : overbeek 1.1 elsif ($request eq "show_adjacency")
182 :     {
183 : overbeek 1.14 &CloseStrains::show_otu_tree($cgi,$parms,$html,'adjacency',$base);
184 : overbeek 1.1 }
185 :     elsif ($request eq "show_clusters")
186 :     {
187 : overbeek 1.14 &CloseStrains::show_clusters($cgi,$parms,$html,$base);
188 : overbeek 1.1 }
189 : overbeek 1.3 elsif ($request eq "show_help")
190 :     {
191 :     my $type = $cgi->param('type');
192 :     if ($type eq "signatures")
193 :     {
194 :     my $help_sig = &CloseStrains::help_sig();
195 :     push(@$html,"<pre>$help_sig</pre>\n");
196 :     }
197 : overbeek 1.10 elsif ($type eq "signatures_reactions")
198 :     {
199 :     my $help_sig_reactions = &CloseStrains::help_sig_reactions();
200 :     push(@$html,"<pre>$help_sig_reactions</pre>\n");
201 :     }
202 :     elsif ($type eq "reaction_on_tree")
203 :     {
204 :     my $help_reaction_on_tree = &CloseStrains::help_reaction_on_tree;
205 :     push(@$html,$help_reaction_on_tree);
206 :     }
207 : overbeek 1.6 elsif ($type eq "compute_signatures")
208 :     {
209 :     my $help_sig_output = &CloseStrains::help_sig_output();
210 :     push(@$html,"<pre>$help_sig_output</pre>\n");
211 :     }
212 : overbeek 1.10 elsif ($type eq "compute_signatures_reactions")
213 :     {
214 :     my $help_sig_output_reactions = &CloseStrains::help_sig_output_reactions();
215 :     push(@$html,"<pre>$help_sig_output_reactions</pre>\n");
216 :     }
217 : overbeek 1.6 elsif ($type eq "family")
218 :     {
219 :     my $help_family_output = &CloseStrains::help_family_output();
220 :     push(@$html,"<pre>$help_family_output</pre>\n");
221 :     }
222 :     elsif ($type eq "function")
223 :     {
224 :     my $help_function_output = &CloseStrains::help_function_output();
225 :     push(@$html,"<pre>$help_function_output</pre>\n");
226 :     }
227 : overbeek 1.3 }
228 : overbeek 1.1 else
229 :     {
230 :     push(@$html,"<h1>Invalid request</h1>");
231 :     }
232 :     &HTML::show_page($cgi,$html);
233 :     exit;
234 :    
235 :     sub show_otus {
236 : overbeek 1.14 my($cgi,$datadir,$base) = @_;
237 : overbeek 1.1
238 :     print $cgi->header;
239 :     if (opendir(GENERA,$csD))
240 :     {
241 :     my @genera = grep { $_ !~ /^\./ } readdir(GENERA);
242 :     closedir(GENERA);
243 :     print "<h1>What Changed?</h1>\n";
244 : olson 1.13 # print "<h2><a target='_blank' href=\"http://bioseed.mcs.anl.gov/~overbeek/what_changed.html\">Getting Started: a short Tutorial</a></h2>\n";
245 : overbeek 1.1 print "<h2>Genera Available</h2>\n";
246 :     foreach my $g (sort @genera)
247 :     {
248 : overbeek 1.14 print "<h3><a target='_blank' href='wc.cgi?request=show_options_for_otu&dataD=$g&base=$base'>$g</a>\n";
249 : overbeek 1.1 }
250 :     }
251 :     else
252 :     {
253 :     print "<h1>The dataD parameter is invalid\n";
254 :     }
255 :     }
256 :    
257 :     sub virulence_functions_link {
258 :     my($cgi,$dataDF) = @_;
259 :    
260 :     if ((-s "$dataDF/virulence.functions") && ($dataDF =~ /([^\/]+)$/))
261 :     {
262 :     my $dataDQ = uri_escape($1);
263 : overbeek 1.14 return "<a target='_blank' href='wc.cgi?request=show_virulence_functions&base=$base&dataD=$dataDQ'>Some Posssible Functions Associated with Virulence</a>";
264 : overbeek 1.1 }
265 :     return '';
266 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3