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

Annotation of /FigWebServices/protein.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.245 - (view) (download)

1 : redwards 1.94 # -*- perl -*-
2 : olson 1.170 #
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 : paczian 1.218 use warnings;
20 :     use strict;
21 : olson 1.56
22 : paczian 1.218 use CGI qw(:standard);
23 :     use HTML::Template;
24 : olson 1.48 use Data::Dumper;
25 :    
26 : paczian 1.218 use FIG;
27 :     use FIG_Config;
28 :     use FIG_CGI;
29 :     use UserData;
30 :     use FigWebServices::SeedComponents;
31 : parrello 1.223 use PageBuilder;
32 :     use TemplateObject;
33 : parrello 1.232 use Tracer;
34 : parrello 1.223
35 :     print header();
36 : golsen 1.175
37 : paczian 1.218 eval {
38 :     &main();
39 :     };
40 : overbeek 1.184
41 : paczian 1.218 if($@) {
42 : parrello 1.223 print start_html();
43 : paczian 1.218 print STDERR "EXCEPTION: $@\n";
44 :     print "EXCEPTION: $@\n",end_html();
45 :     }
46 :    
47 :     1;
48 :    
49 : parrello 1.223
50 : paczian 1.218 sub main {
51 :     # initialize fig object
52 :     my ($fig, $cgi, $user) = FIG_CGI::init(debug_save => 0,
53 : parrello 1.220 debug_load => 0,
54 :     print_params => 0);
55 : parrello 1.233 ETracing($cgi);
56 : parrello 1.232 Trace("Processing protein page.") if T(2);
57 : parrello 1.223 # check if an external page is to be displayed, called with data from seed.
58 : paczian 1.218 if ($cgi->param('tool')) {
59 : parrello 1.232 Trace("Tool selected.") if T(2);
60 : parrello 1.223 # Get the template object.
61 :     my $to = TemplateObject->new($cgi, php => 'Tool');
62 :    
63 :     # Get the PEG.
64 :     my $pegID = $cgi->param('prot');
65 : parrello 1.220
66 :     my $parameters = { fig_object => $fig,
67 : parrello 1.223 peg_id => $pegID,
68 : parrello 1.220 table_style => 'plain',
69 :     fig_disk => $FIG_Config::fig_disk . "/",
70 : parrello 1.236 form_target => 'protein.cgi',
71 : parrello 1.243 title => "$pegID Protein Tool Page",
72 :     user => ($cgi->param('user') || ""),
73 : parrello 1.220 };
74 :    
75 : parrello 1.223 # Format the header information.
76 :     $to->titles($parameters);
77 :     # Spit out an index link.
78 :     $to->add(undef => "<br/>" . FigWebServices::SeedComponents::Protein::get_index_link() . "<br/><hr/>");
79 :    
80 :     # Call the tool.
81 :     $to->add(results => & FigWebServices::SeedComponents::Basic::call_tool($fig, $pegID));
82 :    
83 :     # Spit out another copy of the index link.
84 :     $to->add(undef => "<hr/>" . FigWebServices::SeedComponents::Protein::get_index_link());
85 : paczian 1.218
86 : parrello 1.223 # Output the page.
87 :     print $to->finish();
88 : paczian 1.218
89 :     # check for the new framework
90 :     } elsif ($cgi->param('new_framework')) {
91 : parrello 1.232 Trace("Using new framework.") if T(2);
92 : parrello 1.220 # display the new version
93 :     my @out = `./frame.cgi`;
94 :     print @out;
95 :     exit;
96 :    
97 : paczian 1.218 } else {
98 : parrello 1.220
99 :     # display the old version
100 :    
101 : parrello 1.223 # Get the template object.
102 :     my $to = TemplateObject->new($cgi, php => 'Protein', $cgi->param("request"));
103 :    
104 :     # Get the PEG.
105 :     my $pegID = $cgi->param('prot');
106 : paczian 1.228 if ($pegID !~ /^fig\|/) {
107 :     my @poss = $fig->by_alias($pegID);
108 :    
109 :     if (@poss > 0) {
110 :     $pegID = $poss[0];
111 :     }
112 :     }
113 : parrello 1.230 # Get the feature type.
114 :     my $featureType = $fig->ftype($pegID);
115 :     my $proteinMode = ($featureType eq 'peg');
116 :     if ($featureType eq 'peg') {
117 :     $featureType = 'Protein';
118 : parrello 1.242 } elsif ($featureType eq 'bs') {
119 :     $featureType = 'RiboSwitch';
120 : parrello 1.230 } else {
121 :     $featureType = uc $featureType;
122 :     }
123 : parrello 1.235 # Make sure the template knows.
124 : parrello 1.230 if ($to->mode()) {
125 :     $to->add(ftype => $featureType);
126 : parrello 1.236 $to->add(protein => $proteinMode);
127 :     Trace("Feature $pegID will be displayed as type $featureType with protein mode = $proteinMode.") if T(2);
128 : parrello 1.230 }
129 : parrello 1.235 # Built the parameter list for the framework stuff.
130 : parrello 1.220 my $parameters = { fig_object => $fig,
131 : parrello 1.223 peg_id => $pegID,
132 : parrello 1.220 table_style => 'plain',
133 :     fig_disk => $FIG_Config::fig_disk . "/",
134 : parrello 1.230 form_target => 'protein.cgi',
135 : parrello 1.236 ftype => $featureType,
136 : paczian 1.239 cgi => $cgi,
137 : parrello 1.236 title => "$featureType Page for $pegID"
138 : parrello 1.220 };
139 :    
140 : paczian 1.231 # check if the fig_id passed is valid
141 : parrello 1.234 Trace("Checking ID $pegID.") if T(3);
142 : paczian 1.231 unless ($fig->translatable($pegID)) {
143 :     $to->titles($parameters);
144 :     $to->add("<br/>" . FigWebServices::SeedComponents::Protein::get_index_link() . "<br/>") if $to->raw;
145 :     $to->add(FigWebServices::SeedComponents::Framework::get_js_css_links()) if $to->raw;
146 :     $to->add("<h2>The Protein with ID $pegID does not (no longer) exist.</h2>") if $to->raw;
147 :     $to->add("<br/>" . FigWebServices::SeedComponents::Protein::get_index_link() . "<br/>") if $to->raw;
148 :     print $to->finish();
149 :     exit 1;
150 :     }
151 :    
152 : parrello 1.220 my ($min, $max, $features) = FigWebServices::SeedComponents::Protein::get_region_data($parameters);
153 :     $parameters->{min} = $min;
154 :     $parameters->{max} = $max;
155 :     $parameters->{features} = $features;
156 :    
157 : parrello 1.223 # Format the header information.
158 :     $to->titles($parameters);
159 : parrello 1.240 # Delete the title.
160 :     delete $parameters->{title};
161 : parrello 1.223 # Spit out an index link.
162 :     $to->add("<br/>" . FigWebServices::SeedComponents::Protein::get_index_link() . "<br/>") if $to->raw;
163 :     $to->add(FigWebServices::SeedComponents::Framework::get_js_css_links()) if $to->raw;
164 : parrello 1.220
165 :     # check for request parameter
166 :     my $request = $cgi->param("request") || "";
167 :    
168 : parrello 1.223 # check for quick assign. Quick assigns do not work in Sprout, but if we're in Sprout and a
169 :     # fast assign is requested, we've already crashed when we tried to create the template.
170 : parrello 1.220 if ($request eq "fast_assign") {
171 : parrello 1.223 &FigWebServices::SeedComponents::Protein::make_assignment($fig,$cgi,$pegID);
172 : paczian 1.239 $cgi->delete("request");
173 :     $parameters->{cgi} = $cgi;
174 : parrello 1.220 $request = "";
175 :     }
176 : parrello 1.234 Trace("Request value is $request.") if T(3);
177 : parrello 1.230 if ($request eq "view_annotations") {
178 : parrello 1.223 $to->add(results => &FigWebServices::SeedComponents::Protein::view_annotations($fig,$cgi,$pegID));
179 : parrello 1.220 } elsif ($request eq "view_all_annotations") {
180 : parrello 1.223 $to->add(results => &FigWebServices::SeedComponents::Protein::view_all_annotations($fig,$cgi,$pegID));
181 : parrello 1.220 } elsif ($request eq "show_coupling_evidence") {
182 : parrello 1.223 $to->add(results => &FigWebServices::SeedComponents::Protein::show_coupling_evidence($fig,$cgi,$pegID));
183 : parrello 1.220 } elsif ($request eq "abstract_coupling") {
184 : parrello 1.223 $to->add(results => &FigWebServices::SeedComponents::Protein::show_abstract_coupling_evidence($fig,$cgi,$pegID));
185 : parrello 1.220 } elsif ($request eq "ec_to_maps") {
186 : parrello 1.223 $to->add(results => &FigWebServices::SeedComponents::Protein::show_ec_to_maps($fig,$cgi));
187 : parrello 1.220 } elsif ($request eq "link_to_map") {
188 : parrello 1.223 $to->add(results => &FigWebServices::SeedComponents::Protein::link_to_map($fig,$cgi));
189 : parrello 1.220 } elsif ($request eq "fusions") {
190 : parrello 1.223 $to->add(results => &FigWebServices::SeedComponents::Protein::show_fusions($fig,$cgi,$pegID));
191 :     } else {
192 : paczian 1.225 # this has to be done to support calls to previous or next peg
193 :     my $adjust = $cgi->param('previous PEG') ? -1 : $cgi->param('next PEG') ? 1 : 0;
194 :     if ( $adjust ) {
195 :     my ( $prefix, $protnum ) = $pegID =~ /^(.*\.)(\d+)$/;
196 :     if ( $prefix && $protnum ) {
197 :     my $prot2 = $prefix . ($protnum + $adjust);
198 :     if ( $fig->translatable($prot2 ) ) {
199 :     $pegID = $prot2;
200 :     $cgi->delete('prot');
201 :     $cgi->param(-name => 'prot', -value => $pegID);
202 :     $parameters->{peg_id} = $pegID;
203 :     }
204 :     }
205 :     ( $adjust < 0 ) && $cgi->delete('previous PEG');
206 :     ( $adjust > 0 ) && $cgi->delete('next PEG');
207 :     }
208 :    
209 : paczian 1.229 # initialize the return value variable
210 :     my $retval;
211 :    
212 : parrello 1.223 # normal page shown.
213 : parrello 1.234 Trace("Displaying normal page.") if T(3);
214 : paczian 1.229 $retval = FigWebServices::SeedComponents::Protein::get_title($parameters);
215 : parrello 1.230 $to->add("<br />") if $to->raw;
216 :     $to->add(title => $retval->{body});
217 :     $to->add("<br/><br/>") if $to->raw;
218 :     $to->add(assign => FigWebServices::SeedComponents::Protein::get_current_assignment($parameters));
219 : parrello 1.223 $to->add("<hr/>") if $to->raw;
220 :     $to->add(translink => FigWebServices::SeedComponents::Protein::get_translation_link());
221 :     $to->add("<hr/>") if $to->raw;
222 :     $to->add(context_graphic => FigWebServices::SeedComponents::Protein::get_peg_view($parameters));
223 : paczian 1.229 $parameters->{initial_value} = 'expanded';
224 : parrello 1.244 Trace("Formatting context.") if T(3);
225 : paczian 1.229 $retval = FigWebServices::SeedComponents::Protein::get_chromosome_context($parameters);
226 :     delete($parameters->{title});
227 :     delete($parameters->{id});
228 :     $to->add(context_table => "<br/><br/>".$retval->{title} . "<br/><br/>" . $retval->{body});
229 : parrello 1.223 $to->add("<br />") if $to->raw;
230 : parrello 1.244 Trace("Retrieving annotation links.") if T(3);
231 : parrello 1.243 $to->add(annotation_links => FigWebServices::SeedComponents::Protein::get_annotation_links($parameters));
232 : paczian 1.229 $to->add("<hr/>") if $to->raw;
233 : parrello 1.230 if ($proteinMode) {
234 : parrello 1.244 Trace("Processing subsystem connections.") if T(3);
235 : parrello 1.230 $parameters->{initial_value} = 'expanded';
236 :     $retval = FigWebServices::SeedComponents::Protein::get_subsystem_connections($parameters);
237 :     delete($parameters->{title});
238 :     delete($parameters->{id});
239 :     $to->add(subsys_connections => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
240 : parrello 1.244 Trace("Subsystem connections plotted.") if T(3);
241 : parrello 1.230 }
242 :     if ($proteinMode) {
243 : parrello 1.244 Trace("Processing AA sequence.") if T(3);
244 : parrello 1.230 $parameters->{initial_value} = 'collapsed';
245 :     $retval = FigWebServices::SeedComponents::Protein::get_aa_sequence($parameters);
246 :     delete($parameters->{title});
247 :     delete($parameters->{id});
248 :     $to->add(protein_sequence => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
249 : parrello 1.244 Trace("AA sequence plotted.") if T(3);
250 : parrello 1.230 }
251 : parrello 1.234 Trace("Generating DNA data.") if T(3);
252 : paczian 1.229 $parameters->{initial_value} = 'collapsed';
253 :     $retval = FigWebServices::SeedComponents::Protein::get_dna_sequence($parameters);
254 :     delete($parameters->{title});
255 :     delete($parameters->{id});
256 :     $to->add(dna_sequence => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
257 :     $parameters->{initial_value} = 'collapsed';
258 :     $retval = FigWebServices::SeedComponents::Protein::get_dna_sequence_adjacent($parameters);
259 : parrello 1.230 delete($parameters->{title});
260 :     delete($parameters->{id});
261 : paczian 1.229 $to->add(flanked_sequence => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
262 : parrello 1.230 if ($proteinMode) {
263 :     $parameters->{initial_value} = 'expanded';
264 :     $retval = FigWebServices::SeedComponents::Protein::get_assignments_for_identical_proteins($parameters);
265 :     delete($parameters->{title});
266 :     delete($parameters->{id});
267 :     $to->add(related_assignments => "<br/><br/>". $retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
268 :     }
269 :     if ($proteinMode) {
270 :     $parameters->{initial_value} = 'collapsed';
271 :     $retval = FigWebServices::SeedComponents::Protein::get_links($parameters);
272 :     delete($parameters->{title});
273 :     delete($parameters->{id});
274 :     $to->add(subsys_links => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
275 :     }
276 :     if ($proteinMode) {
277 :     $parameters->{initial_value} = 'collapsed';
278 :     $retval = FigWebServices::SeedComponents::Protein::get_functional_coupling($parameters);
279 :     delete($parameters->{title});
280 :     delete($parameters->{id});
281 :     $to->add(couplings => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
282 :     }
283 : parrello 1.234 Trace("Processing attribute data.") if T(3);
284 : paczian 1.229 $parameters->{initial_value} = 'collapsed';
285 :     $retval = FigWebServices::SeedComponents::Protein::get_attributes($parameters);
286 :     delete($parameters->{title});
287 :     delete($parameters->{id});
288 :     $to->add(attributes => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
289 : parrello 1.230 if ($proteinMode) {
290 :     $parameters->{initial_value} = 'collapsed';
291 :     $retval = FigWebServices::SeedComponents::Protein::get_protein_families($parameters);
292 :     delete($parameters->{title});
293 :     delete($parameters->{id});
294 :     $to->add(families => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
295 :     }
296 : parrello 1.226 $to->add("<br/><hr/>") if $to->raw;
297 : parrello 1.223 $to->add(compared_regions => FigWebServices::SeedComponents::Protein::get_compared_regions($parameters));
298 : paczian 1.229 $to->add("<hr/>") if $to->raw;
299 : parrello 1.223 $to->add(pubmed_url => FigWebServices::SeedComponents::Protein::get_pubmed_url($parameters));
300 :     $to->add("<br/><hr/>") if $to->raw;
301 : parrello 1.227 if (is_sprout($cgi)) {
302 : parrello 1.232 $retval = FigWebServices::SeedComponents::Protein::get_bbhs($parameters);
303 : overbeek 1.245 $to->add(bbhs => $retval);
304 : parrello 1.232 delete($parameters->{title});
305 :     delete($parameters->{id});
306 : overbeek 1.245 }
307 :    
308 :     $parameters->{initial_value} = 'collapsed';
309 :     $retval = FigWebServices::SeedComponents::Protein::get_similarities($parameters);
310 :     delete($parameters->{title});
311 :     delete($parameters->{id});
312 :     $to->add(similarities => $retval->{title} . "<br/><br/>" . $retval->{form} . "<br/>" . $retval->{body});
313 :    
314 : parrello 1.230 if ($proteinMode) {
315 :     $to->add("<br/><hr/>") if $to->raw;
316 :     $parameters->{initial_value} = 'expanded';
317 :     $retval = FigWebServices::SeedComponents::Protein::get_tools($parameters);
318 :     delete($parameters->{title});
319 :     delete($parameters->{id});
320 :     $to->add(tools => $retval->{body});
321 :     }
322 : parrello 1.220 $parameters->{noheadline} = undef;
323 :     }
324 :    
325 : parrello 1.223 $to->add("<br/><hr/>" . FigWebServices::SeedComponents::Protein::get_index_link()) if $to->raw;
326 : parrello 1.220
327 : parrello 1.223 print $to->finish();
328 : overbeek 1.2 }
329 : redwards 1.160 }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3