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

Annotation of /FigWebServices/frame.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (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.8 <table width=100% border=1>
159 : paczian 1.6 <tr><td colspan=3 style="border-top: 1px solid lightblue;"></td></tr>
160 : olson 1.1 <tr style="vertical-align: bottom;">
161 : paczian 1.6 <td width='40px' height='28px'><b>User:</b></td><td width='100%'><input type='text' name='user' value='~ . $user . qq~' style="width: 100px;">~;
162 :    
163 :     # store current cgi
164 :     my @old_cgi;
165 :     my @names = $cgi->param;
166 :     foreach my $name (@names) {
167 : paczian 1.7 unless (($name eq "layout") or ($name eq "config") or ($name eq "Resubmit")) {
168 : paczian 1.6 push(@old_cgi, { 'preserve_name' => $name, 'preserve_value' => $cgi->param($name) } );
169 :    
170 :     # store current params in login form
171 :     unless ($name eq "user") {
172 :     $session .= "<input type='hidden' name='" . $name . "' value='" . $cgi->param($name) . "'>";
173 :     }
174 :     }
175 :     }
176 :    
177 :     # finish session html
178 :     $session .= qq~</td>~ . $config_button . qq~
179 : olson 1.1 </tr>
180 :     </table>
181 :     </form>
182 :     ~;
183 :    
184 : paczian 1.3 #################
185 :     # Modify this section to add new actions
186 :     #################
187 : olson 1.1
188 :    
189 :     # process current action
190 : paczian 1.3 if ($action eq "welcome") {
191 :     $content .= FigWebServices::SeedComponents::Framework::get_welcome($params);
192 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
193 :     } elsif ($action eq "overview") {
194 :     $content .= FigWebServices::SeedComponents::Framework::get_overview($params);
195 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
196 :     } elsif ($action eq "show_organism") {
197 :     if ($cgi->param("organism_action") eq "statistics") {
198 :     $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~'">~;
199 :     } else {
200 :     $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~'">~;
201 :     }
202 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
203 :     } elsif ($action eq "align_sequences") {
204 :     $content .= FigWebServices::SeedComponents::Framework::get_alignsequences($params);
205 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
206 :     } elsif ($action eq "funcrole_candidates") {
207 :     $content .= FigWebServices::SeedComponents::Framework::get_funcrolecandidates($params);
208 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
209 :     } elsif ($action eq "locate_pegs") {
210 :     $content .= FigWebServices::SeedComponents::Framework::get_locatepegs($params);
211 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
212 :     } elsif ($action eq "export_assignments") {
213 :     $content .= FigWebServices::SeedComponents::Framework::get_exportassignments($params);
214 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
215 :     } elsif ($action eq "process_assignments") {
216 :     $content .= FigWebServices::SeedComponents::Framework::get_processassignments($params);
217 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
218 :     } elsif ($action eq "execute_blast") {
219 :     $content .= FigWebServices::SeedComponents::Basic::get_blastresult($params);
220 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
221 :     } elsif ($action eq "proteinpage") {
222 :     my ($main, $functions) = FigWebServices::SeedComponents::Protein::get_proteinpage($params);
223 :     $content .= $main;
224 :     $menu .= $functions;
225 : olson 1.1 }
226 :    
227 :     # generate common content
228 : paczian 1.3 $title .= FigWebServices::SeedComponents::Framework::get_title($params);
229 :     $logo .= FigWebServices::SeedComponents::Framework::get_logo($params);
230 :     $menu .= FigWebServices::SeedComponents::Framework::get_menu($params);
231 :    
232 : olson 1.1 # create output template
233 : paczian 1.7 my $template = HTML::Template->new(filename => TEMPLATE_PATH . 'frame.tmpl', die_on_bad_params => 0);
234 : olson 1.1
235 :     # insert content into template
236 :     $template->param(document_base => $document_base);
237 :     $template->param(image_base => $image_base);
238 :     $template->param(configuration => $configuration);
239 :     $template->param(title => $title);
240 :     $template->param(menu => $menu);
241 :     $template->param(session => $session);
242 :     $template->param(logo => $logo);
243 :     $template->param(content => $content);
244 : paczian 1.3 $template->param(preserve => \@old_cgi);
245 : olson 1.1
246 :     # output the page
247 :     print header();
248 :     print $template->output();
249 :     }
250 : paczian 1.3
251 :     sub get_defaultpreferences {
252 :     my ($params) = @_;
253 :    
254 :     my $preferences = {};
255 :    
256 :     $preferences->{'framework:start_page'} = "welcome";
257 : 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;";
258 : paczian 1.3 $preferences->{'framework:sort_subsystem'} = "by_phylo";
259 :     $preferences->{'framework:show_clusters_subsystem'} = "1";
260 : paczian 1.7 $preferences->{'framework:proteinpage_order'} = { general => 0,
261 :     assign_for_equiv_prots => 1,
262 :     context_graphic => 2,
263 :     compare_region => 3,
264 :     contig_context => 4,
265 :     subsys_connections => 5,
266 :     links => 6,
267 :     similarities => 7,
268 :     kv_pairs => 8
269 :     };
270 : paczian 1.3
271 :     return $preferences;
272 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3