Dienstag, 21. Juni 2011

Jmol 001: Loading a Structure File from Disk Through CGI

The function below allow the user to load a structure into a Jmol applet.
#!/usr/bin/python

print "Content-type: text/html\n\n"

import cgi
import cgitb
cgitb.enable()

def getJmolPage(target):
newpage = ''
newpage += '<html>\n'
newpage += ' <head>\n'
newpage += ' <title>Load PDB Form</title>\n'
newpage += ' <script src="./jmolDir/Jmol.js" type="text/javascript"></scri
pt>\n'
newpage += ' </head> \n'
newpage += ' <body> \n'
newpage += ' <script type="text/javascript">\n'
newpage += ' jmolInitialize("./jmolDir");\n'
newpage += ' jmolApplet(400, "load ../x_output/%s.pdb");\n'
newpage += ' </script><br />\n'
newpage += ' </body>\n'
newpage += '</html>\n'

return newpage % (target)

if __name__ == '__main__':
form = cgi.FieldStorage()
target = form['PDBID'].value
print getJmolPage(target)
Note, all HTML code had to be escaped in order to be posted on the blog.

Keine Kommentare:

Kommentar veröffentlichen