Commit d1c0f578 by Peter Eastman

Further UI improvements

parent 3515f0da
<html>
<head><title>PDB Fixer</title></head>
<body>
The following residues are missing heavy atoms, which will be added.
<p>
<form method="post" action="/">
......@@ -11,5 +8,8 @@ The following residues are missing heavy atoms, which will be added.
<p>
<input type="submit" value="Continue"/>
</form>
<script>
setCurrentStep(5)
</script>
</body>
<html>
<html>
<head><title>PDB Fixer</title>
<script>
function validateForm() {
if (document.getElementById("addCheckbox").checked) {
......@@ -11,8 +9,6 @@ function validateForm() {
}
}
</script>
</head>
<body>
Add missing hydrogen atoms?
<p>
<form method="post" action="/" onsubmit="return validateForm()">
......@@ -20,5 +16,8 @@ Add missing hydrogen atoms?
<p>
<input type="submit" value="Continue"/>
</form>
<script>
setCurrentStep(6)
</script>
</body>
<html>
\ No newline at end of file
<html>
<head>
<title>PDB Fixer</title>
<script>
function setCheckboxes(selected) {
checkboxes = document.getElementById("table").getElementsByTagName("input");
for (var i = 0; i < checkboxes.length; i++)
checkboxes[i].checked = selected
}
</script>
</head>
<body>
The SEQRES records in this PDB file include residues that are missing from the atom data section. Do you want to add the missing residues?
<p>
<form method="post" action="/">
......@@ -21,5 +9,8 @@ The SEQRES records in this PDB file include residues that are missing from the a
<p>
<input type="submit" value="Continue"/>
</form>
<script>
setCurrentStep(3)
</script>
</body>
<html>
<html>
<head>
<title>PDB Fixer</title>
<script>
function setCheckboxes(selected) {
checkboxes = document.getElementById("table").getElementsByTagName("input");
for (var i = 0; i < checkboxes.length; i++)
checkboxes[i].checked = selected
}
</script>
</head>
<body>
This PDB file contains non-standard residues. Do you want to convert them to the corresponding standard residues?
<p>
<form method="post" action="/">
......@@ -21,5 +9,8 @@ This PDB file contains non-standard residues. Do you want to convert them to th
<p>
<input type="submit" value="Continue"/>
</form>
<script>
setCurrentStep(4)
</script>
</body>
<html>
\ No newline at end of file
<html>
<head>
<title>PDBFixer</title>
<script>
function setCurrentStep(step) {
for (var i = 1; i < step; i++)
document.getElementById("step"+i).style.color="black"
document.getElementById("step"+step).style.color="red"
for (var i = step+1; i < 8; i++)
document.getElementById("step"+i).style.color="gray"
if (step == 1)
document.getElementById("newfile").disabled=true
}
function setCheckboxes(selected) {
checkboxes = document.getElementById("table").getElementsByTagName("input");
for (var i = 0; i < checkboxes.length; i++)
checkboxes[i].checked = selected
}
</script>
</head>
<body>
<div style="background-color:LightSkyBlue;font-style:italic;font-size:xx-large;text-align:center">PDBFixer</div>
<span style="background-color:LightSkyBlue;font-style:italic;font-size:large;float:right;height:100%;padding:0px 10px">
<form method="post" action="/controls">
<input type="submit" name="newfile" value="New File" id="newfile"/>
<input type="submit" name="quit" value="Quit" style="float:right"/>
</form>
<p id="step1">Load File</p>
<p id="step2">Select Chains</p>
<p id="step3">Add Residues</p>
<p id="step4">Convert Residues</p>
<p id="step5">Add Heavy Atoms</p>
<p id="step6">Add Hydrogens</p>
<p id="step7">Save File</p>
</span>
<p/>
\ No newline at end of file
<html>
<head>
<title>PDBFixer</title>
</head>
<body>
<h1 style="text-align:center">See You Again Soon!</h1>
PDBFixer has exited. You can close your browser window.
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>PDB Fixer</title>
<script>
function setCheckboxes(selected) {
checkboxes = document.getElementById("table").getElementsByTagName("input");
for (var i = 0; i < checkboxes.length; i++)
checkboxes[i].checked = selected
}
</script>
</head>
<body>
This PDB file contains %d chains. Select which ones to include.
<p>
<form method="post" action="/">
......@@ -21,5 +9,8 @@ This PDB file contains %d chains. Select which ones to include.
<p>
<input type="submit" value="Continue"/>
</form>
<script>
setCurrentStep(2)
</script>
</body>
<html>
\ No newline at end of file
<html>
<head><title>PDB Fixer</title></head>
<body>
The fixed PDB file is ready to save.
<p>
<form method="post" action="/">
<input type="submit" name="save" value="Save File"/>
<input type="submit" name="newfile" value="Process Another File"/>
</form>
<script>
setCurrentStep(7)
</script>
</body>
<html>
<html>
<head><title>PDBFixer</title></head>
<body>
<h1>Welcome To PDBFixer!</h1>
Select a PDB file to load. It will be analyzed for problems.
<p>
......@@ -9,5 +6,8 @@ PDB File: <input type="file" name="pdbfile" onchange="document.getElementById('s
<p>
<input type="submit" id="submit" value="Analyze File" disabled/>
</form>
<script>
setCurrentStep(1)
</script>
</body>
</html>
......@@ -11,6 +11,13 @@ def loadHtmlFile(name):
file = os.path.join(htmlPath, name)
return open(file).read()
def controlsCallback(parameters, handler):
if 'newfile' in parameters:
displayStartPage()
if 'quit' in parameters:
handler.sendResponse(loadHtmlFile("quit.html"))
uiserver.server.shutdown()
def startPageCallback(parameters, handler):
if 'pdbfile' in parameters:
global fixer
......@@ -56,7 +63,7 @@ def saveFilePageCallback(parameters, handler):
def displayStartPage():
uiserver.setCallback(startPageCallback)
uiserver.setContent(loadHtmlFile("start.html"))
uiserver.setContent(header+loadHtmlFile("start.html"))
def displayDeleteChainsPage():
uiserver.setCallback(deleteChainsPageCallback)
......@@ -79,7 +86,7 @@ def displayDeleteChainsPage():
else:
content = ', '.join(set(residues))
table += ' <tr><td>%d</td><td>%d</td><td>%s</td><td><input type="checkbox" name="include%d" checked></td></tr>\n' % (chain.index+1, len(residues), content, i)
uiserver.setContent(loadHtmlFile("removeChains.html") % (numChains, table))
uiserver.setContent(header+loadHtmlFile("removeChains.html") % (numChains, table))
def displayAddResiduesPage():
uiserver.setCallback(addResiduesPageCallback)
......@@ -91,7 +98,7 @@ def displayAddResiduesPage():
for i, key in enumerate(sorted(fixer.missingResidues)):
residues = fixer.missingResidues[key]
table += ' <tr><td>%d</td><td>%d to %d</td><td>%s</td><td><input type="checkbox" name="add%d" checked></td></tr>\n' % (key[0]+1, key[1]+1, key[1]+len(residues), ', '.join(residues), i)
uiserver.setContent(loadHtmlFile("addResidues.html") % table)
uiserver.setContent(header+loadHtmlFile("addResidues.html") % table)
def displayConvertResiduesPage():
uiserver.setCallback(convertResiduesPageCallback)
......@@ -106,7 +113,7 @@ def displayConvertResiduesPage():
table = ""
for i, residue in enumerate(fixer.nonstandardResidues):
table += ' <tr><td>%d</td><td>%s %d</td><td>%s</td><td><input type="checkbox" name="convert%d" checked></td></tr>\n' % (residue.chain.index+1, residue.name, indexInChain[residue], substitutions[residue.name], i)
uiserver.setContent(loadHtmlFile("convertResidues.html") % table)
uiserver.setContent(header+loadHtmlFile("convertResidues.html") % table)
def displayMissingAtomsPage():
uiserver.setCallback(missingAtomsPageCallback)
......@@ -128,17 +135,20 @@ def displayMissingAtomsPage():
if residue in fixer.missingTerminals:
atoms.extend(atom for atom in fixer.missingTerminals[residue])
table += ' <tr><td>%d</td><td>%s %d</td><td>%s</td></tr>\n' % (residue.chain.index+1, residue.name, indexInChain[residue], ', '.join(atoms))
uiserver.setContent(loadHtmlFile("addHeavyAtoms.html")% table)
uiserver.setContent(header+loadHtmlFile("addHeavyAtoms.html")% table)
def displayAddHydrogensPage():
uiserver.setCallback(addHydrogensPageCallback)
uiserver.setContent(loadHtmlFile("addHydrogens.html"))
uiserver.setContent(header+loadHtmlFile("addHydrogens.html"))
def displaySaveFilePage():
uiserver.setCallback(saveFilePageCallback)
uiserver.setContent(loadHtmlFile("saveFile.html"))
uiserver.setContent(header+loadHtmlFile("saveFile.html"))
def launchUI():
global header
header = loadHtmlFile("header.html")
uiserver.beginServing()
uiserver.setCallback(controlsCallback, "/controls")
displayStartPage()
webbrowser.open('http://localhost:'+str(uiserver.server.server_address[1]))
\ No newline at end of file
webbrowser.open('http://localhost:'+str(uiserver.server.server_address[1]))
......@@ -13,25 +13,34 @@ class _Handler(BaseHTTPRequestHandler):
parameters = parse_qs(self.path[queryStart+1:])
else:
parameters = {}
result = callback(parameters, self)
self.invokeCallback(parameters)
if not self.hasSentResponse:
self.sendResponse(content)
def do_POST(self):
self.hasSentResponse = False
if callback is not None:
parameters = cgi.FieldStorage(fp=self.rfile, headers=self.headers, environ={'REQUEST_METHOD':'POST', 'CONTENT_TYPE':self.headers['Content-Type']})
callback(parameters, self)
parameters = cgi.FieldStorage(fp=self.rfile, headers=self.headers, environ={'REQUEST_METHOD':'POST', 'CONTENT_TYPE':self.headers['Content-Type']})
self.invokeCallback(parameters)
if not self.hasSentResponse:
self.sendResponse(content)
def log_message(self, format, *args):
return
def invokeCallback(self, parameters):
path = self.path
if '?' in path:
path = path[:path.find('?')]
if path in callback:
callback[path](parameters, self)
def sendResponse(self, response):
self.hasSentResponse = True
self.send_response(200)
self.send_header("Content-type", "text/html")
self.send_header("Content-length", str(len(content)))
self.send_header("Content-length", str(len(response)))
self.end_headers()
self.wfile.write(content)
self.wfile.write(response)
def sendDownload(self, download, filename):
self.hasSentResponse = True
......@@ -46,7 +55,7 @@ class _ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
pass
content = ""
callback = None
callback = {}
server = _ThreadingHTTPServer(("localhost", 8000), _Handler)
def beginServing():
......@@ -56,7 +65,6 @@ def setContent(newContent):
global content
content = newContent
def setCallback(newCallback):
def setCallback(newCallback, path="/"):
global callback
callback = newCallback
callback[path] = newCallback
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment