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

Annotation of /FigWebServices/frame.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (view) (download)

1 : olson 1.1 ##################################################
2 :     # includes
3 :     ##################################################
4 :     use warnings;
5 :     use strict;
6 :    
7 :     use CGI qw(:standard);
8 :     use HTML::Template;
9 : paczian 1.3 use Data::Dumper;
10 : olson 1.1
11 :     use FIG;
12 :     use FIG_Config;
13 :     use FIG_CGI;
14 : paczian 1.3 use UserData;
15 : olson 1.1
16 : olson 1.2 use FigWebServices::SeedComponents;
17 : olson 1.1
18 :     ##################################################
19 :     # handle exceptions
20 :     ##################################################
21 :    
22 :     eval {
23 :     &main();
24 :     };
25 :    
26 :     if($@) {
27 :     print header(),start_html();
28 : paczian 1.3 print STDERR "EXCEPTION: $@\n";
29 :     print "EXCEPTION: $@\n",end_html();
30 : olson 1.1 }
31 :    
32 :     1;
33 :    
34 :     ##################################################
35 :     # main subroutine
36 :     ##################################################
37 :    
38 :     sub main {
39 :    
40 : paczian 1.3 # set environment variables
41 :     if (! $ENV{"BLASTMAT"}) { $ENV{"BLASTMAT"} = "$FIG_Config::blastmat" }
42 :    
43 : olson 1.1 # constant variables
44 : olson 1.2 use constant DOCUMENT_ROOT => "$FIG_Config::fig/CGI/Html/";
45 : olson 1.1 use constant TEMPLATE_PATH => DOCUMENT_ROOT;
46 : paczian 1.3 use constant USER_DIR => "$FIG_Config::global/Users/";
47 :     use constant FIG_DISK => "$FIG_Config::fig_disk/";
48 :     use constant FIG_TEMP => "$FIG_Config::temp/";
49 :     use constant FIG_ORGANISMS => "$FIG_Config::organisms/";
50 :     use constant FIG_EXTBIN => "$FIG_Config::ext_bin/";
51 :     use constant FIG_NR => "$FIG_Config::global/nr";
52 : olson 1.1
53 : paczian 1.6 # check if the user directory exists, else create it
54 : disz 1.5 mkdir USER_DIR, 0777 unless (-e USER_DIR);
55 :    
56 : olson 1.1 # initialize content variables
57 :     my $document_base = "./Html/";
58 : olson 1.2 my $image_base = $document_base;
59 : olson 1.1 my $configuration = "";
60 :    
61 :     my $title = "";
62 :     my $menu = "";
63 :     my $session = "";
64 :     my $logo = "";
65 :     my $content = "";
66 : paczian 1.3 my $action = "";
67 : olson 1.1
68 : paczian 1.3
69 : olson 1.1 # initialize fig object
70 :     my ($fig, $cgi, $user) = FIG_CGI::init(debug_save => 0,
71 :     debug_load => 0,
72 :     print_params => 0);
73 : paczian 1.3
74 : olson 1.1 # initialize params hash
75 : paczian 1.3 my $params = { document_base => $document_base,
76 :     image_base => $image_base,
77 :     cgi => $cgi,
78 :     fig => $fig,
79 :     fig_disk => FIG_DISK,
80 :     fig_temp => FIG_TEMP,
81 :     fig_organisms => FIG_ORGANISMS,
82 :     fig_extbin => FIG_EXTBIN,
83 :     fig_nr => FIG_NR,
84 :     user_directory => USER_DIR
85 :     };
86 : olson 1.1
87 :     # check for logged in user
88 : olson 1.2 $user = "Guest";
89 : olson 1.1 if (defined($cgi->param("user"))) {
90 :     $user = $cgi->param("user");
91 :     }
92 :     $params->{user} = $user;
93 :    
94 : paczian 1.3 # load configuration
95 :     my $preferences = FigWebServices::SeedComponents::Framework::get_preferences($params);
96 :    
97 :     # set preferences params
98 :     my $preferences_params = { preferences => $preferences,
99 :     user => $user,
100 :     user_directory => USER_DIR };
101 :    
102 :     # check for new user
103 :     unless (exists($preferences->{'framework:start_page'})) {
104 :    
105 :     # set default preferences
106 :     $preferences = get_defaultpreferences($params);
107 :     $preferences_params->{preferences} = $preferences;
108 :    
109 :     # write preferences to file
110 :     FigWebServices::SeedComponents::Framework::set_preferences($preferences_params);
111 :     }
112 :    
113 :     # check for change of preferences
114 :     if (defined($cgi->param("set_startpage"))) {
115 :     $preferences->{'framework:start_page'} = $cgi->param("page");
116 :     FigWebServices::SeedComponents::Framework::set_preferences($preferences_params);
117 :     $content .= FigWebServices::SeedComponents::Framework::get_message("You have successfully set your startpage to this page.");
118 :     } elsif (defined($cgi->param("config"))) {
119 :     $preferences->{'framework:menu_layout'} = $cgi->param("layout");
120 :     FigWebServices::SeedComponents::Framework::set_preferences($preferences_params);
121 :     $content .= FigWebServices::SeedComponents::Framework::get_message("You have successfully changed your settings");
122 :     }
123 :    
124 :     # set configuration variable
125 :     $configuration = $preferences->{'framework:menu_layout'};
126 :    
127 :     # set background information for all forms to post
128 :     $params->{background_information} = "<input type='hidden' name='user' value='" . $user . "'>";
129 :    
130 :     # store user preferences
131 :     $params->{user_preferences} = $preferences;
132 :    
133 :     # create configuration button
134 :     my $config_button = qq~<td id='login'><img src="~ . $params->{image_base} . qq~config.gif" onclick="go_configmode();" class="login"></td>~;
135 :    
136 : paczian 1.6 # check for action, otherwise set action to startpage
137 :     if (defined($cgi->param("action"))) {
138 :     $action = $cgi->param("action");
139 :     } else {
140 :    
141 :     # workaround for links to the protein page to pipe through frame.cgi
142 :     if (defined($cgi->param("prot"))) {
143 :     $action = "proteinpage";
144 :     } else {
145 :     $action = $params->{user_preferences}->{'framework:start_page'};
146 :     }
147 :     }
148 :     $params->{action} = $action;
149 :    
150 : paczian 1.3 # disable configuration for user Guest
151 :     if ($user eq "Guest") {
152 :     $config_button = "";
153 :     }
154 : paczian 1.6
155 : olson 1.1 # set session html
156 :     $session = qq~
157 : paczian 1.7 <form method='post' action='./frame.cgi' name='login_form'>
158 : paczian 1.9 <table width=100%>
159 :     <tr style="height: 15px;"><td></td></tr>
160 : paczian 1.6 <tr><td colspan=3 style="border-top: 1px solid lightblue;"></td></tr>
161 : olson 1.1 <tr style="vertical-align: bottom;">
162 : paczian 1.9 <td width='40px' height='15px' style="font-size: 12pt;"><b>User:</b></td><td width='100%'><input type='text' name='user' value='~ . $user . qq~' style="width: 100px;">~;
163 : paczian 1.6
164 :     # store current cgi
165 :     my @old_cgi;
166 :     my @names = $cgi->param;
167 :     foreach my $name (@names) {
168 : paczian 1.7 unless (($name eq "layout") or ($name eq "config") or ($name eq "Resubmit")) {
169 : paczian 1.6 push(@old_cgi, { 'preserve_name' => $name, 'preserve_value' => $cgi->param($name) } );
170 :    
171 :     # store current params in login form
172 :     unless ($name eq "user") {
173 :     $session .= "<input type='hidden' name='" . $name . "' value='" . $cgi->param($name) . "'>";
174 :     }
175 :     }
176 :     }
177 :    
178 :     # finish session html
179 :     $session .= qq~</td>~ . $config_button . qq~
180 : olson 1.1 </tr>
181 :     </table>
182 :     </form>
183 :     ~;
184 :    
185 : paczian 1.3 #################
186 :     # Modify this section to add new actions
187 :     #################
188 : olson 1.1
189 :    
190 :     # process current action
191 : paczian 1.3 if ($action eq "welcome") {
192 :     $content .= FigWebServices::SeedComponents::Framework::get_welcome($params);
193 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
194 :     } elsif ($action eq "overview") {
195 :     $content .= FigWebServices::SeedComponents::Framework::get_overview($params);
196 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
197 :     } elsif ($action eq "show_organism") {
198 :     if ($cgi->param("organism_action") eq "statistics") {
199 :     $content .= qq~<img src="~ . $params->{image_base} . qq~clear.gif" onload="window.top.location='genome_statistics.cgi?genome=~ . $cgi->param("genome") . qq~&user=~ . $user . qq~'">~;
200 :     } else {
201 :     $content .= qq~<img src="~ . $params->{image_base} . qq~clear.gif" onload="window.top.location='genome_statistics.cgi?genome=~ . $cgi->param("genome") . qq~&request=show_subsystems&user=~ . $user . qq~'">~;
202 :     }
203 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
204 :     } elsif ($action eq "align_sequences") {
205 :     $content .= FigWebServices::SeedComponents::Framework::get_alignsequences($params);
206 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
207 :     } elsif ($action eq "funcrole_candidates") {
208 :     $content .= FigWebServices::SeedComponents::Framework::get_funcrolecandidates($params);
209 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
210 :     } elsif ($action eq "locate_pegs") {
211 :     $content .= FigWebServices::SeedComponents::Framework::get_locatepegs($params);
212 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
213 :     } elsif ($action eq "export_assignments") {
214 :     $content .= FigWebServices::SeedComponents::Framework::get_exportassignments($params);
215 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
216 :     } elsif ($action eq "process_assignments") {
217 :     $content .= FigWebServices::SeedComponents::Framework::get_processassignments($params);
218 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
219 :     } elsif ($action eq "execute_blast") {
220 :     $content .= FigWebServices::SeedComponents::Basic::get_blastresult($params);
221 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
222 :     } elsif ($action eq "proteinpage") {
223 :     my ($main, $functions) = FigWebServices::SeedComponents::Protein::get_proteinpage($params);
224 :     $content .= $main;
225 :     $menu .= $functions;
226 : olson 1.1 }
227 :    
228 :     # generate common content
229 : paczian 1.3 $title .= FigWebServices::SeedComponents::Framework::get_title($params);
230 :     $logo .= FigWebServices::SeedComponents::Framework::get_logo($params);
231 :     $menu .= FigWebServices::SeedComponents::Framework::get_menu($params);
232 :    
233 : olson 1.1 # create output template
234 : paczian 1.7 my $template = HTML::Template->new(filename => TEMPLATE_PATH . 'frame.tmpl', die_on_bad_params => 0);
235 : olson 1.1
236 :     # insert content into template
237 :     $template->param(document_base => $document_base);
238 :     $template->param(image_base => $image_base);
239 :     $template->param(configuration => $configuration);
240 :     $template->param(title => $title);
241 :     $template->param(menu => $menu);
242 :     $template->param(session => $session);
243 :     $template->param(logo => $logo);
244 :     $template->param(content => $content);
245 : paczian 1.3 $template->param(preserve => \@old_cgi);
246 : olson 1.1
247 :     # output the page
248 :     print header();
249 :     print $template->output();
250 :     }
251 : paczian 1.3
252 :     sub get_defaultpreferences {
253 :     my ($params) = @_;
254 :    
255 :     my $preferences = {};
256 :    
257 :     $preferences->{'framework:start_page'} = "welcome";
258 : paczian 1.6 $preferences->{'framework:menu_layout'} = "extlinks,element,1,1,blue;intlinks,element,1,1,blue;services,element,1,1,blue;neighborhood,group,1,0,0,1,0,0,1,1,0,0,0,1,1;contig_context,section,0;identicalproteins,section,0;compare_region,section,0;subsystems_connections,section,0;relatedlinks,section,0;proteinfamilies,section,0;identicalproteins_table,group,1,1,1,1,1;proteinfamilies_table,group,1,1,1;subsystems_connections_table,group,1,1,1;relatedlinks_table,group,1,1,1,1,1;similarities_table,group,1,1,1,1,1,1,1,1,1,1,1;";
259 : paczian 1.3 $preferences->{'framework:sort_subsystem'} = "by_phylo";
260 :     $preferences->{'framework:show_clusters_subsystem'} = "1";
261 : paczian 1.7 $preferences->{'framework:proteinpage_order'} = { general => 0,
262 :     assign_for_equiv_prots => 1,
263 :     context_graphic => 2,
264 :     compare_region => 3,
265 :     contig_context => 4,
266 :     subsys_connections => 5,
267 :     links => 6,
268 :     similarities => 7,
269 :     kv_pairs => 8
270 :     };
271 : paczian 1.3
272 :     return $preferences;
273 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3