Modify Jpred for JABAWS
[jabaws.git] / binaries / src / jpred / lib / Jpred.pm
1 package Jpred;
2
3 =head1 NAME
4
5 jpred.pm -- Jpred module to define all necessary global and environment variables
6
7 =cut
8
9 use warnings;
10 use strict;
11
12 BEGIN {
13   use Exporter;
14   our @ISA = ('Exporter');
15   our @EXPORT = qw(
16   $WEBSERVER
17   $WEBSERVERCGI
18   $SERVERROOT
19   $SRSSERVER
20   $CHKLOG
21   $RESULTS
22   $PDBLNK
23   $CSS
24   $IMAGES
25   $JNET
26   $TIMEOUT
27   $BATCHLIM
28   $DUNDEE
29   $JPREDUSER
30   $JPREDEMAIL
31   $MAILHOST
32   $JPREDROOT
33   $BINDIR
34   $LIBDIR
35   $JOBDIR
36   $PREFIX
37   $RESOURCE
38   $BLASTDB
39   $SWALL
40   $SWALLFILT
41   $PDB
42   $PDB_DAT
43   $JPREDHEAD
44   $JPREDFOOT
45   xsystem
46   setup_jpred_env
47   );
48   our @EXPORT_OK = @EXPORT;
49 }
50
51 # library path for Mail::CheckUser dependency for jpred_form.
52 # for some reason doesn't work if in PERL5LIB
53 use lib '/sw/lib/perl5.10.1/lib/perl5';
54
55 # URIs
56 #our $WEBSERVER    = 'http://www.compbio.dundee.ac.uk/www-jpred';
57 our $WEBSERVER    = 'http://webserv1.cluster.lifesci.dundee.ac.uk:3209';
58 our $WEBSERVERCGI = "$WEBSERVER/cgi-bin";
59
60 #$SERVERROOT = "$WEBSERVER/~www-jpred";
61 our $SERVERROOT = "$WEBSERVER";
62 our $SRSSERVER  = 'http://srs.ebi.ac.uk/srs6bin/cgi-bin';
63 our $CHKLOG     = "$WEBSERVERCGI/chklog?";
64 our $RESULTS    = "$SERVERROOT/results";
65 our $PDBLNK     = "http://www.ebi.ac.uk/pdbsum/";
66 our $CSS        = "$SERVERROOT/jpred.css";
67 our $IMAGES     = "$SERVERROOT/images";
68 our $JNET       = "$SERVERROOT/about.html#jnet";
69
70 # This is the time (in seconds) the job is allowed to take
71 our $TIMEOUT  = 60 * 60;    # now is 60mins
72 our $BATCHLIM = 200;
73
74 our $DUNDEE = "http://www.dundee.ac.uk";
75
76 # e-mail details
77 our $JPREDUSER  = 'www-jpred';
78 our $JPREDEMAIL = 'www-jpred@compbio.dundee.ac.uk';
79 our $MAILHOST   = 'smtp.lifesci.dundee.ac.uk';        # CC 19/05/06 - updated to current smtp host from weevil
80
81 # Server paths
82 #our $JPREDROOT = '/homes/www-jpred/live';
83 #our $JPREDROOT = '/homes/www-jpred/devel';
84 our $JPREDROOT = '/home/asherstnev/Projects/Jpred.project/jpred/branches/portable';
85
86 # Directory for binaries either on the cluster or on the www server
87 our $BINDIR = "$JPREDROOT/bin";
88
89 # path to perl modules
90 our $LIBDIR = "$JPREDROOT/lib";
91
92 # Cluster paths
93 our $JOBDIR = "$JPREDROOT/public_html/results";       # directory for output
94
95 # Cluster names
96 our $PREFIX   = "jp_";                                # Prefix for job submissions (qstat will only display 10 chars of job name)
97 our $RESOURCE = "www_service2";                       # Resource for the submission to use
98
99 # Variables for external programs
100 # psiblast
101 $ENV{BLASTMAT} = "$JPREDROOT/data/blast";
102 our $BLASTDB = $JPREDROOT . "/databases";
103 $ENV{BLASTDB} = $BLASTDB;
104 our $SWALL     = "$BLASTDB/uniref90";
105 our $SWALLFILT = "$SWALL.filt";
106 our $PDB       = '/db/blastdb/pdb';
107 our $PDB_DAT   = '/db/blastdb/DB.dat';
108
109 # ncoils matrix location
110 $ENV{COILSDIR} = "$JPREDROOT/data/coils";
111
112 sub setup_jpred_env {
113   my $newJPREDROOT = shift;
114
115   $JPREDROOT = $newJPREDROOT if (defined $newJPREDROOT);
116
117   $BINDIR = "$JPREDROOT/bin";
118   $LIBDIR = "$JPREDROOT/lib";
119   $JOBDIR = "$JPREDROOT/public_html/results";
120
121   $ENV{BLASTMAT} = "$JPREDROOT/data/blast";
122   $BLASTDB = $JPREDROOT . "/databases";
123   $ENV{BLASTDB} = $BLASTDB;
124   $SWALL     = "$BLASTDB/uniref90";
125   $SWALLFILT = "$SWALL.filt";
126 }
127
128 # Error checking system call
129 sub xsystem {
130   my ($command) = @_;
131   my $rc = 0xffff & system $command;
132   if ( $rc == 0 ) {
133     return;
134   } elsif ( $rc == 0xff00 ) {
135     print "'$command' failed!\n";
136     die "Jpred failed\n";
137   } elsif ( ( $rc & 0xff ) == 0 ) {
138     $rc >>= 8;
139     die "'$command' did something else! (exited $rc)\n";
140   } else {
141     if ( $rc & 0x80 ) {
142       $rc &= ~0x80;
143       print "'$command' dumped core!\n";
144       die "Jpred failed\n";
145     }
146   }
147 }
148
149 # The header and footer for any HTML produced dynamically
150 our $JPREDHEAD = "      <div id=\"header\">
151
152          <a href=\"$DUNDEE\">
153          <img class=\"uod\" src=\"$IMAGES/logo_white_small.gif\" height=\"100\" width=\"108\" title=\"University of Dundee\" alt=\"University of Dundee Logo\" />
154          </a>
155         <a href=\"$SERVERROOT/index.html\"> 
156         <img src=\"$IMAGES/jpred3.png\" border=\"0\" height=\"102\" width=\"520\" title=\"Jpred Logo\" alt=\"Jpred Logo\" />
157         </a>
158          <a href=\"http://www.compbio.dundee.ac.uk\">
159             <img src=\"$IMAGES/group.png\" border=\"0\" height=\"102\" width=\"70\" title=\"Group Link\" alt=\"The Barton Group\" />
160          </a>
161
162          <div id=\"navigation\">
163             <table border=\"0\" cellpadding=\"0\" width=\"100%\">
164                <tr>
165                   <td class=\"nav_table\"><a class=\"nav\" href=\"$SERVERROOT/index.html\">Home</a></td>
166
167                   <td class=\"nav_table\"><a class=\"nav\" href=\"$SERVERROOT/about.html\">About</a></td>
168                   <td class=\"nav_table\"><a class=\"nav\" href=\"$SERVERROOT/new.html\">News</a></td>
169                   <td class=\"nav_table\"><a class=\"nav\" href=\"$SERVERROOT/faq.html\">FAQ</a></td>
170                   <td class=\"nav_table\"><a class=\"nav\" href=\"$SERVERROOT/help.html\">Help</a></td>
171                   <td class=\"nav_table\"><a class=\"nav\" href=\"$SERVERROOT/contact.html\">Contact</a></td>
172                </tr>
173
174              </table>
175          </div> <!-- End #navigation -->
176       </div> <!-- End #header -->
177 ";
178
179 our $JPREDFOOT = '
180       <script type="text/javascript">
181          var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
182          document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));
183       </script>
184       <script type="text/javascript">
185          try{
186             var pageTracker = _gat._getTracker("UA-5356328-1");
187             pageTracker._trackPageview();
188          } catch(err) {}
189       </script>
190 ';
191 1;
192
193 =head1 DESCRIPTION
194
195 This module defines all the global and envirnmental variables required by the Jpred server scripts and binaries.
196
197 =head1 AUTHOR
198
199 I'm not sure who originally wrote this module, but I guess all of the following contributed:
200
201 James Cuff
202 Jon Barber
203 Chris Cole <christian@cole.name> (current maintainer)
204
205 =cut