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

Annotation of /FigWebServices/protein.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.250 - (view) (download)

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3