src.server (17 March 2007)
index
/Users/baker/Desktop/pdb2pqr/trunk/pdb2pqr/src/server.py

CGI Server for PDB2PQR
 
This module contains the various functions necessary to run PDB2PQR
from a web server.
 
----------------------------
 
PDB2PQR -- An automated pipeline for the setup, execution, and analysis of
Poisson-Boltzmann electrostatics calculations
 
    Copyright (c) 2002-2007, Jens Erik Nielsen, University College Dublin; 
    Nathan A. Baker, Washington University in St. Louis; Paul Czodrowski & 
    Gerhard Klebe, University of Marburg
 
    All rights reserved.
 
    Redistribution and use in source and binary forms, with or without modification, 
    are permitted provided that the following conditions are met:
 
            * Redistributions of source code must retain the above copyright notice, 
              this list of conditions and the following disclaimer.
            * Redistributions in binary form must reproduce the above copyright notice, 
              this list of conditions and the following disclaimer in the documentation 
              and/or other materials provided with the distribution.
            * Neither the names of University College Dublin, Washington University in 
              St. Louis, or University of Marburg nor the names of its contributors may 
              be used to endorse or promote products derived from this software without 
              specific prior written permission.
 
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
    IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
    OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
    OF THE POSSIBILITY OF SUCH DAMAGE.
 
----------------------------

 
Modules
       
os
string
sys
time

 
Functions
       
cleanTmpdir()
Clean up the temp directory for CGI.  If the size of the directory
is greater than LIMIT, delete the older half of the files.  Since
the files are stored by system time of creation, this is an
easier task.
createError(name, details)
Create an error results page for CGI-based runs
 
Parameters
    name:    The result file root name, based on local time (string)
    details: The details of the error (string)
createResults(header, input, name, time, missedligands=[])
Create the results web page for CGI-based runs
 
Parameters
    header: The header of the PQR file (string)
    input:   A flag whether an input file has been created (int)
    tmpdir:  The resulting file directory (string)
    name:    The result file root name, based on local time (string)
    time:    The time taken to run the script (float)
    missedligands: A list of ligand names whose parameters could
             not be assigned. Optional. (list)
getLoads()
Get the system load information for output and logging
 
Returns
    loads:  A three entry list containing the 1, 5, and
            15 minute loads. If the load file is not found,
            return None.
getQuote(path)
Get a quote to display for the refresh page.
Uses fortune to generate a quote.
 
Parameters:
    path:   The path to the fortune script (str)
Returns:
    quote:   The quote to display (str)
logRun(options, nettime, size, ff, ip)
Log the CGI run for data analysis.  Log file format is as follows:
 
DATE  FF  SIZE  OPTIONS   TIME
 
Parameters
    options: The options used for this run (dict)
    nettime: The total time taken for the run (float)
    size:    The final number of non-HETATM atoms in the PDB file (int)
    ff:      The name of the ff used
    ip:      The ip address of the user
printAcceptance(name)
Print the first message to stdout (web browser) - set the
refresh to the <id>-tmp.html file.
 
Parameters
    name:    The ID of the HTML page to redirect to (string)
printProgress(name, refreshname, reftime, starttime)
Print the progress of the server
 
Parameters
    name:        The ID of the HTML page to write to (string)
    refreshname: The name of the HTML page to refresh to (string)
    reftime:     The length of time to set the refresh wait to (int)
    starttime:   The time as returned by time.time() that the run started (float)
setID(time)
Given a floating point time.time(), generate an ID.
Use the tenths of a second to differentiate.
 
Parameters
    time:  The current time.time() (float)
Returns
    id  :  The file id (string)
startServer(name)
Start the PDB2PQR server.  This function is necessary so
that useful information can be displayed to the user - otherwise
nothing would be returned until the complete run finishes.
 
Parameters
    name:    The ID name of the final file to create (string)
Returns
    pqrpath: The complete path to the pqr file (string)

 
Data
        LIMIT = 500.0
LOADPATH = '/proc/loadavg'
LOGPATH = '/Users/baker/pdb2pqr///tmp//usage.txt'
REFRESHTIME = 20
SRCPATH = '/Users/baker/pdb2pqr//'
STYLESHEET = 'http://pincushion.wustl.edu/pdb2pqr//pdb2pqr.css'
TMPDIR = 'tmp/'
WEBNAME = 'index.html'
WEBSITE = 'http://pincushion.wustl.edu/pdb2pqr//'
__author__ = 'Todd Dolinsky'
__date__ = '17 March 2007'

 
Author
        Todd Dolinsky