Posts mit dem Label Jmol werden angezeigt. Alle Posts anzeigen
Posts mit dem Label Jmol werden angezeigt. Alle Posts anzeigen

Mittwoch, 22. Juni 2011

Jmol 002: Control over Two Structures

I loaded two structures into a jmolApplet by the following code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>UI Controls example</title>
<script src="./jmolDir/Jmol.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
jmolInitialize("./jmolDir");
jmolApplet(400, "load 1AVD.pdb;\
load APPEND nwSurface.xyz;\
axes on;\
boundbox on;");
</script><br />
</body>
</html>
This results in the figure below.
A protein structure is placed above an array of carbon atoms which are supposed to illustrate the surface of a nanowire. What I would like to do now is to be able to rotate the protein with respect to the surface (i.e. keeping the surface in the same orientation regarding the indicated coordinate system).
Unfortunately, I dont know how to include Jmol on Blogspot, otherwise I naturally would have included it directly here as well.
The input from Bob Hanson at the Jmol Mailing list is actually pointing me into exactly the correct direction. This script was tested in a local version of Jmol but it should just as well be working in a browser.

load 1PDB.pdb
load APPEND nwSurface.xyz
select protein
set allowRotateSelected True
set dragSelected True

Now using <ALT>+<Left_Mouse> the user can rotate the protein structure without changing the surface and <ALT>+<SHIFT>+<Left_Mouse> to drag the structure over the surface.

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.