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

Annotation of /FigWebServices/frame.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (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 : disz 1.5 mkdir USER_DIR, 0777 unless (-e USER_DIR);
54 :    
55 : olson 1.1 # initialize content variables
56 :     my $document_base = "./Html/";
57 : olson 1.2 my $image_base = $document_base;
58 : olson 1.1 my $configuration = "";
59 :    
60 :     my $title = "";
61 :     my $menu = "";
62 :     my $session = "";
63 :     my $logo = "";
64 :     my $content = "";
65 : paczian 1.3 my $action = "";
66 : olson 1.1
67 : paczian 1.3
68 : olson 1.1 # initialize fig object
69 :     my ($fig, $cgi, $user) = FIG_CGI::init(debug_save => 0,
70 :     debug_load => 0,
71 :     print_params => 0);
72 : paczian 1.3
73 : olson 1.1 # initialize params hash
74 : paczian 1.3 my $params = { document_base => $document_base,
75 :     image_base => $image_base,
76 :     cgi => $cgi,
77 :     fig => $fig,
78 :     fig_disk => FIG_DISK,
79 :     fig_temp => FIG_TEMP,
80 :     fig_organisms => FIG_ORGANISMS,
81 :     fig_extbin => FIG_EXTBIN,
82 :     fig_nr => FIG_NR,
83 :     user_directory => USER_DIR
84 :     };
85 : olson 1.1
86 :     # check for logged in user
87 : olson 1.2 $user = "Guest";
88 : olson 1.1 if (defined($cgi->param("user"))) {
89 :     $user = $cgi->param("user");
90 :     }
91 :     $params->{user} = $user;
92 :    
93 : paczian 1.3 # load configuration
94 :     my $preferences = FigWebServices::SeedComponents::Framework::get_preferences($params);
95 :    
96 :     # set preferences params
97 :     my $preferences_params = { preferences => $preferences,
98 :     user => $user,
99 :     user_directory => USER_DIR };
100 :    
101 :     # check for new user
102 :     unless (exists($preferences->{'framework:start_page'})) {
103 :    
104 :     # set default preferences
105 :     $preferences = get_defaultpreferences($params);
106 :     $preferences_params->{preferences} = $preferences;
107 :    
108 :     # write preferences to file
109 :     FigWebServices::SeedComponents::Framework::set_preferences($preferences_params);
110 :     }
111 :    
112 :     # check for change of preferences
113 :     if (defined($cgi->param("set_startpage"))) {
114 :     $preferences->{'framework:start_page'} = $cgi->param("page");
115 :     FigWebServices::SeedComponents::Framework::set_preferences($preferences_params);
116 :     $content .= FigWebServices::SeedComponents::Framework::get_message("You have successfully set your startpage to this page.");
117 :     } elsif (defined($cgi->param("config"))) {
118 :     $preferences->{'framework:menu_layout'} = $cgi->param("layout");
119 :     FigWebServices::SeedComponents::Framework::set_preferences($preferences_params);
120 :     $content .= FigWebServices::SeedComponents::Framework::get_message("You have successfully changed your settings");
121 :     }
122 :    
123 :     # set configuration variable
124 :     $configuration = $preferences->{'framework:menu_layout'};
125 :    
126 :     # set background information for all forms to post
127 :     $params->{background_information} = "<input type='hidden' name='user' value='" . $user . "'>";
128 :    
129 :     # store user preferences
130 :     $params->{user_preferences} = $preferences;
131 :    
132 :     # create configuration button
133 :     my $config_button = qq~<td id='login'><img src="~ . $params->{image_base} . qq~config.gif" onclick="go_configmode();" class="login"></td>~;
134 :    
135 :     # disable configuration for user Guest
136 :     if ($user eq "Guest") {
137 :     $config_button = "";
138 :     }
139 :    
140 : olson 1.1 # set session html
141 :     $session = qq~
142 :     <form method='post' action='frame.cgi' name='login_form'>
143 :     <table width=100%>
144 :     <tr><td colspan=3 style="border-top: 1px solid #000088;"></td></tr>
145 :     <tr style="vertical-align: bottom;">
146 : paczian 1.3 <td width='40px' height='28px'><b>User:</b></td><td width='100%'><input type='text' name='user' value='~ . $user . qq~' style="width: 100px;"></td>~ . $config_button . qq~
147 : olson 1.1 </tr>
148 :     </table>
149 :     </form>
150 :     ~;
151 :    
152 : paczian 1.3 # check for action, otherwise set action to startpage
153 :     if (defined($cgi->param("action"))) {
154 :     $action = $cgi->param("action");
155 :     } else {
156 :    
157 :     # workaround for links to the protein page to pipe through frame.cgi
158 :     if (defined($cgi->param("prot"))) {
159 :     $action = "proteinpage";
160 :     } else {
161 :     $action = $params->{user_preferences}->{'framework:start_page'};
162 :     }
163 : olson 1.2 }
164 : paczian 1.3 $params->{action} = $action;
165 : olson 1.2
166 : paczian 1.3 #################
167 :     # Modify this section to add new actions
168 :     #################
169 : olson 1.1
170 :    
171 :     # process current action
172 : paczian 1.3 if ($action eq "welcome") {
173 :     $content .= FigWebServices::SeedComponents::Framework::get_welcome($params);
174 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
175 :     } elsif ($action eq "overview") {
176 :     $content .= FigWebServices::SeedComponents::Framework::get_overview($params);
177 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
178 :     } elsif ($action eq "show_organism") {
179 :     if ($cgi->param("organism_action") eq "statistics") {
180 :     $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~'">~;
181 :     } else {
182 :     $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~'">~;
183 :     }
184 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
185 :     } elsif ($action eq "align_sequences") {
186 :     $content .= FigWebServices::SeedComponents::Framework::get_alignsequences($params);
187 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
188 :     } elsif ($action eq "funcrole_candidates") {
189 :     $content .= FigWebServices::SeedComponents::Framework::get_funcrolecandidates($params);
190 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
191 :     } elsif ($action eq "locate_pegs") {
192 :     $content .= FigWebServices::SeedComponents::Framework::get_locatepegs($params);
193 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
194 :     } elsif ($action eq "export_assignments") {
195 :     $content .= FigWebServices::SeedComponents::Framework::get_exportassignments($params);
196 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
197 :     } elsif ($action eq "process_assignments") {
198 :     $content .= FigWebServices::SeedComponents::Framework::get_processassignments($params);
199 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
200 :     } elsif ($action eq "execute_blast") {
201 :     $content .= FigWebServices::SeedComponents::Basic::get_blastresult($params);
202 :     $menu .= FigWebServices::SeedComponents::Framework::get_actionmenu($params);
203 :     } elsif ($action eq "proteinpage") {
204 :     my ($main, $functions) = FigWebServices::SeedComponents::Protein::get_proteinpage($params);
205 :     $content .= $main;
206 :     $menu .= $functions;
207 : olson 1.1 }
208 :    
209 :     # generate common content
210 : paczian 1.3 $title .= FigWebServices::SeedComponents::Framework::get_title($params);
211 :     $logo .= FigWebServices::SeedComponents::Framework::get_logo($params);
212 :     $menu .= FigWebServices::SeedComponents::Framework::get_menu($params);
213 : olson 1.1
214 : paczian 1.3 # store current cgi
215 :     my @old_cgi;
216 :     my @names = $cgi->param;
217 :     foreach my $name (@names) {
218 :     unless (($name eq "layout") or ($name eq "config")) {
219 :     push(@old_cgi, { 'preserve_name' => $name, 'preserve_value' => $cgi->param($name) } );
220 :     }
221 :     }
222 :    
223 : olson 1.1 # create output template
224 :     my $template = HTML::Template->new(filename => TEMPLATE_PATH . 'frame.tmpl');
225 :    
226 :     # insert content into template
227 :     $template->param(document_base => $document_base);
228 :     $template->param(image_base => $image_base);
229 :     $template->param(configuration => $configuration);
230 :     $template->param(title => $title);
231 :     $template->param(menu => $menu);
232 :     $template->param(session => $session);
233 :     $template->param(logo => $logo);
234 :     $template->param(content => $content);
235 : paczian 1.3 $template->param(preserve => \@old_cgi);
236 : olson 1.1
237 :     # output the page
238 :     print header();
239 :     print $template->output();
240 :     }
241 : paczian 1.3
242 :     sub get_defaultpreferences {
243 :     my ($params) = @_;
244 :    
245 :     my $preferences = {};
246 :    
247 :     $preferences->{'framework:start_page'} = "welcome";
248 : paczian 1.4 $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,1;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;";
249 : paczian 1.3 $preferences->{'framework:sort_subsystem'} = "by_phylo";
250 :     $preferences->{'framework:show_clusters_subsystem'} = "1";
251 :    
252 :     return $preferences;
253 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3