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

Annotation of /FigWebServices/wc.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.19 - (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 : olson 1.15 our $cgi = new CGI;
29 : overbeek 1.1 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 : olson 1.15 our $html = [];
45 : overbeek 1.1
46 : olson 1.15 our $node = $cgi->param('node');
47 :     our $family = $cgi->param('family');
48 :     our $genome = $cgi->param('genome');
49 :     our $ali = $cgi->param('alignment');
50 :     our $tree = $cgi->param('tree');
51 :     our $request = $cgi->param('request');
52 :     our $keywords = $cgi->param('keywords');
53 :     our $function = $cgi->param('function');
54 :     our $reaction = $cgi->param('reaction');
55 :     our $dataD = $cgi->param('dataD');
56 :     our $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 : olson 1.15 our $csD;
64 : overbeek 1.14 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 : olson 1.15 our $dataDF = "$csD/$dataD";
78 : overbeek 1.2
79 : olson 1.15 our $parms = {};
80 : overbeek 1.2
81 :     $parms->{genome_types} = &CloseStrains::genome_types($dataDF);
82 :     $parms->{dataDF} = $dataDF;
83 : overbeek 1.17 $parms->{base} = $base;
84 : overbeek 1.1
85 :     if ($request eq "show_otus")
86 :     {
87 : overbeek 1.14 &show_otus($cgi,$csD,$base);
88 : overbeek 1.1 exit;
89 :     }
90 :     elsif (($request eq "show_options_for_otu") && $dataD)
91 :     {
92 : overbeek 1.14 $html = &CloseStrains::show_options_for_otu($cgi,$dataD,$dataDF,$base);
93 :     push(@$html,"<a target=_blank href=./wc.cgi?dataD=$dataD&base=$base&request=newick_tree>Newick Tree</a>\n");
94 :     }
95 :     elsif ($request eq "newick_tree")
96 :     {
97 :     if (open(TREE,"<$dataDF/estimated.phylogeny.nwk"))
98 :     {
99 :     my @tree = map { $_ =~ s/,/,\n/g; $_ } <TREE>;
100 :    
101 :     push(@$html,"<pre>",@tree,"</pre>");
102 :     close(TREE);
103 :     }
104 : overbeek 1.1 }
105 :     elsif ($request eq "show_signatures")
106 :     {
107 : overbeek 1.14 &CloseStrains::show_signatures($cgi,$parms,$html,$base);
108 : overbeek 1.1 }
109 : overbeek 1.10 elsif ($request eq "show_signatures_reactions")
110 :     {
111 : overbeek 1.14 &CloseStrains::show_signatures_reactions($cgi,$parms,$html,$base);
112 : overbeek 1.10 }
113 : overbeek 1.1 elsif ($request eq "compute_sigs")
114 :     {
115 : overbeek 1.14 &CloseStrains::compute_signatures($cgi,$parms,$html,$base);
116 : overbeek 1.1 }
117 : overbeek 1.10 elsif ($request eq "compute_signatures_reactions")
118 :     {
119 : overbeek 1.17 &CloseStrains::compute_signatures_reactions($cgi,$parms,$html,$base);
120 : overbeek 1.10 }
121 : overbeek 1.1 elsif (($request eq "show_func") && $function)
122 :     {
123 :     $function =~ s/^\s+//;
124 :     $function =~ s/\s+$//;
125 : overbeek 1.14 &CloseStrains::show_func($cgi,$parms,$html,$function,$base);
126 : overbeek 1.1 }
127 :     elsif (($request eq "show_family_pegs") && $family)
128 :     {
129 : overbeek 1.14 &CloseStrains::show_family_pegs($cgi,$parms,$html,$family,$base);
130 : overbeek 1.1 }
131 :     elsif (($request eq "show_virulence_functions") && (-s "$dataDF/virulence.functions"))
132 :     {
133 : overbeek 1.14 &CloseStrains::show_virulence_functions($cgi,$parms,$html,$base);
134 : overbeek 1.1 }
135 :     elsif (($request eq 'show_indexed_funcs') && $keywords)
136 :     {
137 : overbeek 1.14 &CloseStrains::show_indexed_funcs($cgi,$parms,$html,$keywords,$base);
138 : overbeek 1.1 }
139 :     elsif (($request eq "show_ali_or_occurs_tree") && $ali)
140 :     {
141 : overbeek 1.14 &CloseStrains::show_ali($cgi,$parms,$base); # NOTE: the alignment invokes Gary's alignment viewer,
142 : overbeek 1.1 # which prints the header, so we print everything in show_ali
143 :     exit;
144 :     }
145 :     elsif (($request eq "show_ali_or_occurs_tree") && $tree)
146 :     {
147 : overbeek 1.14 &CloseStrains::show_occurs_tree($cgi,$parms,$html,$base);
148 : overbeek 1.1 }
149 :     elsif (($request eq "show_family_tree") && $family)
150 :     {
151 : overbeek 1.14 &CloseStrains::show_family_tree($cgi,$parms,$html,$family,$base);
152 : overbeek 1.1 }
153 :     elsif (($request eq "show_node") && $node)
154 :     {
155 : overbeek 1.14 &CloseStrains::show_node($cgi,$parms,$html,$node,$base);
156 : overbeek 1.1 }
157 :     elsif ($request eq "show_otu_tree")
158 :     {
159 : overbeek 1.14 &CloseStrains::show_otu_tree($cgi,$parms,$html,'families',$base);
160 : overbeek 1.1 }
161 : overbeek 1.10 elsif ($request eq "show_reactions")
162 :     {
163 : overbeek 1.14 &CloseStrains::show_reactions($cgi,$parms,$html,$base);
164 : overbeek 1.10 }
165 :     elsif (($request eq "show_reaction_on_tree") && $reaction)
166 :     {
167 : overbeek 1.14 &CloseStrains::show_reaction_on_tree($cgi,$reaction,$parms,$html,$base);
168 : overbeek 1.10 }
169 :     elsif (($request eq "show_reaction_genome_data") && $reaction && $genome)
170 :     {
171 : overbeek 1.14 &CloseStrains::show_reaction_genome_data($cgi,$reaction,$genome,$dataDF,$parms,$html,$base);
172 : overbeek 1.10 }
173 :     elsif ($request eq "show_options_for_reactions")
174 :     {
175 : overbeek 1.14 &CloseStrains::show_options_for_reactions($cgi,$html,$dataD,$dataDF,$base);
176 :     # &CloseStrains::show_signatures_reactions($cgi,$parms,$html,$base);
177 : overbeek 1.11 }
178 :     elsif ($request eq "show_otu_tree_reactions")
179 :     {
180 : overbeek 1.16 &CloseStrains::show_otu_tree($cgi,$parms,$html,'reaction',$base);
181 : overbeek 1.10 }
182 : overbeek 1.1 elsif ($request eq "show_adjacency")
183 :     {
184 : overbeek 1.14 &CloseStrains::show_otu_tree($cgi,$parms,$html,'adjacency',$base);
185 : overbeek 1.1 }
186 :     elsif ($request eq "show_clusters")
187 :     {
188 : overbeek 1.14 &CloseStrains::show_clusters($cgi,$parms,$html,$base);
189 : overbeek 1.1 }
190 : overbeek 1.3 elsif ($request eq "show_help")
191 :     {
192 :     my $type = $cgi->param('type');
193 :     if ($type eq "signatures")
194 :     {
195 :     my $help_sig = &CloseStrains::help_sig();
196 :     push(@$html,"<pre>$help_sig</pre>\n");
197 :     }
198 : overbeek 1.10 elsif ($type eq "signatures_reactions")
199 :     {
200 :     my $help_sig_reactions = &CloseStrains::help_sig_reactions();
201 :     push(@$html,"<pre>$help_sig_reactions</pre>\n");
202 :     }
203 :     elsif ($type eq "reaction_on_tree")
204 :     {
205 :     my $help_reaction_on_tree = &CloseStrains::help_reaction_on_tree;
206 :     push(@$html,$help_reaction_on_tree);
207 :     }
208 : overbeek 1.6 elsif ($type eq "compute_signatures")
209 :     {
210 :     my $help_sig_output = &CloseStrains::help_sig_output();
211 :     push(@$html,"<pre>$help_sig_output</pre>\n");
212 :     }
213 : overbeek 1.10 elsif ($type eq "compute_signatures_reactions")
214 :     {
215 :     my $help_sig_output_reactions = &CloseStrains::help_sig_output_reactions();
216 :     push(@$html,"<pre>$help_sig_output_reactions</pre>\n");
217 :     }
218 : overbeek 1.6 elsif ($type eq "family")
219 :     {
220 :     my $help_family_output = &CloseStrains::help_family_output();
221 :     push(@$html,"<pre>$help_family_output</pre>\n");
222 :     }
223 :     elsif ($type eq "function")
224 :     {
225 :     my $help_function_output = &CloseStrains::help_function_output();
226 :     push(@$html,"<pre>$help_function_output</pre>\n");
227 :     }
228 : olson 1.19 elsif ($type eq "adjacency")
229 :     {
230 :     my $help_adjacency_output = &CloseStrains::help_adjacency_output();
231 :     push(@$html,"<pre>$help_adjacency_output</pre>\n");
232 :     }
233 : overbeek 1.3 }
234 : overbeek 1.1 else
235 :     {
236 :     push(@$html,"<h1>Invalid request</h1>");
237 :     }
238 :     &HTML::show_page($cgi,$html);
239 :     exit;
240 :    
241 :     sub show_otus {
242 : overbeek 1.14 my($cgi,$datadir,$base) = @_;
243 : overbeek 1.1
244 :     print $cgi->header;
245 :     if (opendir(GENERA,$csD))
246 :     {
247 :     my @genera = grep { $_ !~ /^\./ } readdir(GENERA);
248 :     closedir(GENERA);
249 :     print "<h1>What Changed?</h1>\n";
250 : 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";
251 : overbeek 1.1 print "<h2>Genera Available</h2>\n";
252 :     foreach my $g (sort @genera)
253 :     {
254 : overbeek 1.14 print "<h3><a target='_blank' href='wc.cgi?request=show_options_for_otu&dataD=$g&base=$base'>$g</a>\n";
255 : overbeek 1.1 }
256 :     }
257 :     else
258 :     {
259 :     print "<h1>The dataD parameter is invalid\n";
260 :     }
261 :     }
262 :    
263 :     sub virulence_functions_link {
264 :     my($cgi,$dataDF) = @_;
265 :    
266 :     if ((-s "$dataDF/virulence.functions") && ($dataDF =~ /([^\/]+)$/))
267 :     {
268 :     my $dataDQ = uri_escape($1);
269 : 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>";
270 : overbeek 1.1 }
271 :     return '';
272 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3