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

Annotation of /FigWebServices/protein.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.236 - (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 :     title => "$pegID Protein Tool Page"
72 : parrello 1.220 };
73 :    
74 : parrello 1.223 # Format the header information.
75 :     $to->titles($parameters);
76 :     # Spit out an index link.
77 :     $to->add(undef => "<br/>" . FigWebServices::SeedComponents::Protein::get_index_link() . "<br/><hr/>");
78 :    
79 :     # Call the tool.
80 :     $to->add(results => & FigWebServices::SeedComponents::Basic::call_tool($fig, $pegID));
81 :    
82 :     # Spit out another copy of the index link.
83 :     $to->add(undef => "<hr/>" . FigWebServices::SeedComponents::Protein::get_index_link());
84 : paczian 1.218
85 : parrello 1.223 # Output the page.
86 :     print $to->finish();
87 : paczian 1.218
88 :     # check for the new framework
89 :     } elsif ($cgi->param('new_framework')) {
90 : parrello 1.232 Trace("Using new framework.") if T(2);
91 : parrello 1.220 # display the new version
92 :     my @out = `./frame.cgi`;
93 :     print @out;
94 :     exit;
95 :    
96 : paczian 1.218 } else {
97 : parrello 1.220
98 :     # display the old version
99 :    
100 : parrello 1.223 # Get the template object.
101 :     my $to = TemplateObject->new($cgi, php => 'Protein', $cgi->param("request"));
102 :    
103 :     # Get the PEG.
104 :     my $pegID = $cgi->param('prot');
105 : paczian 1.228 if ($pegID !~ /^fig\|/) {
106 :     my @poss = $fig->by_alias($pegID);
107 :    
108 :     if (@poss > 0) {
109 :     $pegID = $poss[0];
110 :     }
111 :     }
112 : parrello 1.230 # Get the feature type.
113 :     my $featureType = $fig->ftype($pegID);
114 :     my $proteinMode = ($featureType eq 'peg');
115 :     if ($featureType eq 'peg') {
116 :     $featureType = 'Protein';
117 :     } else {
118 :     $featureType = uc $featureType;
119 :     }
120 : parrello 1.235 # Make sure the template knows.
121 : parrello 1.230 if ($to->mode()) {
122 :     $to->add(ftype => $featureType);
123 : parrello 1.236 $to->add(protein => $proteinMode);
124 :     Trace("Feature $pegID will be displayed as type $featureType with protein mode = $proteinMode.") if T(2);
125 : parrello 1.230 }
126 : parrello 1.235 # Built the parameter list for the framework stuff.
127 : parrello 1.220 my $parameters = { fig_object => $fig,
128 : parrello 1.223 peg_id => $pegID,
129 : parrello 1.220 table_style => 'plain',
130 :     fig_disk => $FIG_Config::fig_disk . "/",
131 : parrello 1.230 form_target => 'protein.cgi',
132 : parrello 1.236 ftype => $featureType,
133 :     title => "$featureType Page for $pegID"
134 : parrello 1.220 };
135 :    
136 : paczian 1.231 # check if the fig_id passed is valid
137 : parrello 1.234 Trace("Checking ID $pegID.") if T(3);
138 : paczian 1.231 unless ($fig->translatable($pegID)) {
139 :     $to->titles($parameters);
140 :     $to->add("<br/>" . FigWebServices::SeedComponents::Protein::get_index_link() . "<br/>") if $to->raw;
141 :     $to->add(FigWebServices::SeedComponents::Framework::get_js_css_links()) if $to->raw;
142 :     $to->add("<h2>The Protein with ID $pegID does not (no longer) exist.</h2>") if $to->raw;
143 :     $to->add("<br/>" . FigWebServices::SeedComponents::Protein::get_index_link() . "<br/>") if $to->raw;
144 :     print $to->finish();
145 :     exit 1;
146 :     }
147 :    
148 : parrello 1.220 my ($min, $max, $features) = FigWebServices::SeedComponents::Protein::get_region_data($parameters);
149 :     $parameters->{min} = $min;
150 :     $parameters->{max} = $max;
151 :     $parameters->{features} = $features;
152 :    
153 : parrello 1.223 # Format the header information.
154 :     $to->titles($parameters);
155 :     # Spit out an index link.
156 :     $to->add("<br/>" . FigWebServices::SeedComponents::Protein::get_index_link() . "<br/>") if $to->raw;
157 :     $to->add(FigWebServices::SeedComponents::Framework::get_js_css_links()) if $to->raw;
158 : parrello 1.220
159 :     # check for request parameter
160 :     my $request = $cgi->param("request") || "";
161 :    
162 : parrello 1.223 # check for quick assign. Quick assigns do not work in Sprout, but if we're in Sprout and a
163 :     # fast assign is requested, we've already crashed when we tried to create the template.
164 : parrello 1.220 if ($request eq "fast_assign") {
165 : parrello 1.223 &FigWebServices::SeedComponents::Protein::make_assignment($fig,$cgi,$pegID);
166 : parrello 1.220 $request = "";
167 :     }
168 : parrello 1.234 Trace("Request value is $request.") if T(3);
169 : parrello 1.230 if ($request eq "view_annotations") {
170 : parrello 1.223 $to->add(results => &FigWebServices::SeedComponents::Protein::view_annotations($fig,$cgi,$pegID));
171 : parrello 1.220 } elsif ($request eq "view_all_annotations") {
172 : parrello 1.223 $to->add(results => &FigWebServices::SeedComponents::Protein::view_all_annotations($fig,$cgi,$pegID));
173 : parrello 1.220 } elsif ($request eq "show_coupling_evidence") {
174 : parrello 1.223 $to->add(results => &FigWebServices::SeedComponents::Protein::show_coupling_evidence($fig,$cgi,$pegID));
175 : parrello 1.220 } elsif ($request eq "abstract_coupling") {
176 : parrello 1.223 $to->add(results => &FigWebServices::SeedComponents::Protein::show_abstract_coupling_evidence($fig,$cgi,$pegID));
177 : parrello 1.220 } elsif ($request eq "ec_to_maps") {
178 : parrello 1.223 $to->add(results => &FigWebServices::SeedComponents::Protein::show_ec_to_maps($fig,$cgi));
179 : parrello 1.220 } elsif ($request eq "link_to_map") {
180 : parrello 1.223 $to->add(results => &FigWebServices::SeedComponents::Protein::link_to_map($fig,$cgi));
181 : parrello 1.220 } elsif ($request eq "fusions") {
182 : parrello 1.223 $to->add(results => &FigWebServices::SeedComponents::Protein::show_fusions($fig,$cgi,$pegID));
183 :     } else {
184 : paczian 1.225 # this has to be done to support calls to previous or next peg
185 :     my $adjust = $cgi->param('previous PEG') ? -1 : $cgi->param('next PEG') ? 1 : 0;
186 :     if ( $adjust ) {
187 :     my ( $prefix, $protnum ) = $pegID =~ /^(.*\.)(\d+)$/;
188 :     if ( $prefix && $protnum ) {
189 :     my $prot2 = $prefix . ($protnum + $adjust);
190 :     if ( $fig->translatable($prot2 ) ) {
191 :     $pegID = $prot2;
192 :     $cgi->delete('prot');
193 :     $cgi->param(-name => 'prot', -value => $pegID);
194 :     $parameters->{peg_id} = $pegID;
195 :     }
196 :     }
197 :     ( $adjust < 0 ) && $cgi->delete('previous PEG');
198 :     ( $adjust > 0 ) && $cgi->delete('next PEG');
199 :     }
200 :    
201 : paczian 1.229 # initialize the return value variable
202 :     my $retval;
203 :    
204 : parrello 1.223 # normal page shown.
205 : parrello 1.234 Trace("Displaying normal page.") if T(3);
206 : paczian 1.229 $retval = FigWebServices::SeedComponents::Protein::get_title($parameters);
207 : parrello 1.230 $to->add("<br />") if $to->raw;
208 :     $to->add(title => $retval->{body});
209 :     $to->add("<br/><br/>") if $to->raw;
210 :     $to->add(assign => FigWebServices::SeedComponents::Protein::get_current_assignment($parameters));
211 : parrello 1.223 $to->add("<hr/>") if $to->raw;
212 :     $to->add(translink => FigWebServices::SeedComponents::Protein::get_translation_link());
213 :     $to->add("<hr/>") if $to->raw;
214 :     $to->add(context_graphic => FigWebServices::SeedComponents::Protein::get_peg_view($parameters));
215 : paczian 1.229 $parameters->{initial_value} = 'expanded';
216 :     $retval = FigWebServices::SeedComponents::Protein::get_chromosome_context($parameters);
217 :     delete($parameters->{title});
218 :     delete($parameters->{id});
219 :     $to->add(context_table => "<br/><br/>".$retval->{title} . "<br/><br/>" . $retval->{body});
220 : parrello 1.223 $to->add("<br />") if $to->raw;
221 : parrello 1.224 $to->add(annotation_links => FigWebServices::SeedComponents::Protein::get_annotation_links($parameters));
222 : paczian 1.229 $to->add("<hr/>") if $to->raw;
223 : parrello 1.230 if ($proteinMode) {
224 :     $parameters->{initial_value} = 'expanded';
225 :     $retval = FigWebServices::SeedComponents::Protein::get_subsystem_connections($parameters);
226 :     delete($parameters->{title});
227 :     delete($parameters->{id});
228 :     $to->add(subsys_connections => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
229 :     }
230 :     if ($proteinMode) {
231 :     $parameters->{initial_value} = 'collapsed';
232 :     $retval = FigWebServices::SeedComponents::Protein::get_aa_sequence($parameters);
233 :     delete($parameters->{title});
234 :     delete($parameters->{id});
235 :     $to->add(protein_sequence => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
236 :     }
237 : parrello 1.234 Trace("Generating DNA data.") if T(3);
238 : paczian 1.229 $parameters->{initial_value} = 'collapsed';
239 :     $retval = FigWebServices::SeedComponents::Protein::get_dna_sequence($parameters);
240 :     delete($parameters->{title});
241 :     delete($parameters->{id});
242 :     $to->add(dna_sequence => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
243 :     $parameters->{initial_value} = 'collapsed';
244 :     $retval = FigWebServices::SeedComponents::Protein::get_dna_sequence_adjacent($parameters);
245 : parrello 1.230 delete($parameters->{title});
246 :     delete($parameters->{id});
247 : paczian 1.229 $to->add(flanked_sequence => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
248 : parrello 1.230 if ($proteinMode) {
249 :     $parameters->{initial_value} = 'expanded';
250 :     $retval = FigWebServices::SeedComponents::Protein::get_assignments_for_identical_proteins($parameters);
251 :     delete($parameters->{title});
252 :     delete($parameters->{id});
253 :     $to->add(related_assignments => "<br/><br/>". $retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
254 :     }
255 :     if ($proteinMode) {
256 :     $parameters->{initial_value} = 'collapsed';
257 :     $retval = FigWebServices::SeedComponents::Protein::get_links($parameters);
258 :     delete($parameters->{title});
259 :     delete($parameters->{id});
260 :     $to->add(subsys_links => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
261 :     }
262 :     if ($proteinMode) {
263 :     $parameters->{initial_value} = 'collapsed';
264 :     $retval = FigWebServices::SeedComponents::Protein::get_functional_coupling($parameters);
265 :     delete($parameters->{title});
266 :     delete($parameters->{id});
267 :     $to->add(couplings => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
268 :     }
269 : parrello 1.234 Trace("Processing attribute data.") if T(3);
270 : paczian 1.229 $parameters->{initial_value} = 'collapsed';
271 :     $retval = FigWebServices::SeedComponents::Protein::get_attributes($parameters);
272 :     delete($parameters->{title});
273 :     delete($parameters->{id});
274 :     $to->add(attributes => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
275 : parrello 1.230 if ($proteinMode) {
276 :     $parameters->{initial_value} = 'collapsed';
277 :     $retval = FigWebServices::SeedComponents::Protein::get_protein_families($parameters);
278 :     delete($parameters->{title});
279 :     delete($parameters->{id});
280 :     $to->add(families => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
281 :     }
282 : parrello 1.226 $to->add("<br/><hr/>") if $to->raw;
283 : parrello 1.223 $to->add(compared_regions => FigWebServices::SeedComponents::Protein::get_compared_regions($parameters));
284 : paczian 1.229 $to->add("<hr/>") if $to->raw;
285 : parrello 1.223 $to->add(pubmed_url => FigWebServices::SeedComponents::Protein::get_pubmed_url($parameters));
286 :     $to->add("<br/><hr/>") if $to->raw;
287 : parrello 1.227 if (is_sprout($cgi)) {
288 : parrello 1.232 $retval = FigWebServices::SeedComponents::Protein::get_bbhs($parameters);
289 :     $to->add(similarities => $retval);
290 :     delete($parameters->{title});
291 :     delete($parameters->{id});
292 : parrello 1.227 } else {
293 : paczian 1.229 $parameters->{initial_value} = 'expanded';
294 :     $retval = FigWebServices::SeedComponents::Protein::get_similarities($parameters);
295 :     delete($parameters->{title});
296 :     delete($parameters->{id});
297 :     $to->add(similarities => $retval->{title} . "<br/><br/>" . $retval->{form} . "<br/>" . $retval->{body});
298 : parrello 1.227 }
299 : parrello 1.230 if ($proteinMode) {
300 :     $to->add("<br/><hr/>") if $to->raw;
301 :     $parameters->{initial_value} = 'expanded';
302 :     $retval = FigWebServices::SeedComponents::Protein::get_tools($parameters);
303 :     delete($parameters->{title});
304 :     delete($parameters->{id});
305 :     $to->add(tools => $retval->{body});
306 :     }
307 : parrello 1.220 $parameters->{noheadline} = undef;
308 :     }
309 :    
310 : parrello 1.223 $to->add("<br/><hr/>" . FigWebServices::SeedComponents::Protein::get_index_link()) if $to->raw;
311 : parrello 1.220
312 : parrello 1.223 print $to->finish();
313 : overbeek 1.2 }
314 : redwards 1.160 }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3