jmol.py :  » Business-Application » PDB2PQR » pdb2pqr-1.6 » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Business Application » PDB2PQR 
PDB2PQR » pdb2pqr 1.6 » jmol.py
#!@WHICHPYTHON@
"""
    Jmol applet generator
"""

__date__ = "5 July 2007"
__author__ = "Samir Unni"
__version__ = "0.0.1"

import string, sys, os, pickle, cgi, cgitb, locale, shutil
from sys import stdout,stderr,stdin
from src.aconf import *

def jmolGen():
    """
        Write the contents of the (static) page containing the Jmol applet to a
        file, then output a dynamic page that redirects to that static page.
    """

    file = stdout
    file.write("Content-type: text/html\n\n")
    cgitb.enable()
    

    form = cgi.FieldStorage()

    visType = form["vistype"].value
    jobid = form["jobid"].value
    pqrFileName = form["pqrfilename"].value
    scriptName = "myscript.spt"
    jmolPage = "jmol.html"
    jmolJsFile = "Jmol.js"
    jmolAppFile = "JmolApplet.jar"
    jmolColorMin = form["jmolcolormin"].value
    jmolColorMax = form["jmolcolormax"].value

    try:
        jmolType = form["jmoltype"].value
    except KeyError:
        pass

    dxFilePath = "%s-%s.dx" % (pqrFileName[:-4], jmolType)

    shutil.copyfile(jmolJsFile, '%s%s%s/%s' % (INSTALLDIR, TMPDIR, jobid, jmolJsFile))
    shutil.copyfile(jmolAppFile, '%s%s%s/%s' % (INSTALLDIR, TMPDIR, jobid, jmolAppFile))

    script = open('%s%s%s/%s' % (INSTALLDIR, TMPDIR, jobid, scriptName), 'w')
    script.write('load %s\n' % pqrFileName)
    script.write('isosurface s1 colorscheme bwr color absolute %s %s sasurface map \"%s\"\n' % ( jmolColorMin, jmolColorMax, dxFilePath) )
    script.write('write isosurface pot.jvxl')
    script.close()

    jmolpage = open('%s%s%s/%s' % (INSTALLDIR, TMPDIR, jobid, jmolPage), 'w')
    jmolpage.write('<html>\n')
    jmolpage.write('<head><script type=\"text/javascript\" src=\"%s\"></script>\n' % jmolJsFile)
    jmolpage.write('<title>Jmol visualization for %s</title>\n' % pqrFileName)
    jmolpage.write('<link href=\"../../pdb2pqr.css\" type=\"text/css\" rel=\"stylesheet\">\n')
    jmolpage.write('</head>\n')
    jmolpage.write('<body>\n')
    jmolpage.write('<h3>Please be patient while the applet loads and while the surface is rendered and colored by electrostatic potential</h3>\n')
    jmolpage.write('<script type=\"text/javascript\">\n')
    jmolpage.write('jmolApplet(600, \"script myscript.spt\");\n')
    jmolpage.write('</script>\n')
    jmolpage.write('<h3>You can perform simple operations like a MouseOver; or right-clicking on the biomolecule then making your selections.</h3>\n')
    jmolpage.write('<script type=\"text/javascript\">\n')
    jmolpage.write('var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");\n')
    jmolpage.write('document.write(unescape(\"%3Cscript src=\'\" + gaJsHost + \"google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E\"));\n')
    jmolpage.write('</script>\n')
    jmolpage.write('<script type=\"text/javascript\">\n')
    jmolpage.write('try {\n')
    jmolpage.write('var pageTracker = _gat._getTracker(\"UA-11026338-3\");\n')
    jmolpage.write('pageTracker._trackPageview();\n')
    jmolpage.write('} catch(err) {}</script>\n')
    jmolpage.write('</body>\n')
    jmolpage.write('</html>\n')

    jmolpage.close()


    sys.stdout.write('<html> <body>')
    sys.stdout.write('<meta http-equiv=\"refresh\" content=\"1;url=%s\">' % ('tmp/%s/%s' % (jobid, jmolPage)))
    sys.stdout.write('</body> </html>')
    sys.stdout.flush()

jmolGen()

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.