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. The following residues are missing heavy atoms, which will be added.
<p> <p>
<form method="post" action="/"> <form method="post" action="/">
...@@ -11,5 +8,8 @@ The following residues are missing heavy atoms, which will be added. ...@@ -11,5 +8,8 @@ The following residues are missing heavy atoms, which will be added.
<p> <p>
<input type="submit" value="Continue"/> <input type="submit" value="Continue"/>
</form> </form>
<script>
setCurrentStep(5)
</script>
</body> </body>
<html> <html>
<html>
<head><title>PDB Fixer</title>
<script> <script>
function validateForm() { function validateForm() {
if (document.getElementById("addCheckbox").checked) { if (document.getElementById("addCheckbox").checked) {
...@@ -11,8 +9,6 @@ function validateForm() { ...@@ -11,8 +9,6 @@ function validateForm() {
} }
} }
</script> </script>
</head>
<body>
Add missing hydrogen atoms? Add missing hydrogen atoms?
<p> <p>
<form method="post" action="/" onsubmit="return validateForm()"> <form method="post" action="/" onsubmit="return validateForm()">
...@@ -20,5 +16,8 @@ Add missing hydrogen atoms? ...@@ -20,5 +16,8 @@ Add missing hydrogen atoms?
<p> <p>
<input type="submit" value="Continue"/> <input type="submit" value="Continue"/>
</form> </form>
<script>
setCurrentStep(6)
</script>
</body> </body>
<html> <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? 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> <p>
<form method="post" action="/"> <form method="post" action="/">
...@@ -21,5 +9,8 @@ The SEQRES records in this PDB file include residues that are missing from the a ...@@ -21,5 +9,8 @@ The SEQRES records in this PDB file include residues that are missing from the a
<p> <p>
<input type="submit" value="Continue"/> <input type="submit" value="Continue"/>
</form> </form>
<script>
setCurrentStep(3)
</script>
</body> </body>
<html> <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? This PDB file contains non-standard residues. Do you want to convert them to the corresponding standard residues?
<p> <p>
<form method="post" action="/"> <form method="post" action="/">
...@@ -21,5 +9,8 @@ This PDB file contains non-standard residues. Do you want to convert them to th ...@@ -21,5 +9,8 @@ This PDB file contains non-standard residues. Do you want to convert them to th
<p> <p>
<input type="submit" value="Continue"/> <input type="submit" value="Continue"/>
</form> </form>
<script>
setCurrentStep(4)
</script>
</body> </body>
<html> <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. This PDB file contains %d chains. Select which ones to include.
<p> <p>
<form method="post" action="/"> <form method="post" action="/">
...@@ -21,5 +9,8 @@ This PDB file contains %d chains. Select which ones to include. ...@@ -21,5 +9,8 @@ This PDB file contains %d chains. Select which ones to include.
<p> <p>
<input type="submit" value="Continue"/> <input type="submit" value="Continue"/>
</form> </form>
<script>
setCurrentStep(2)
</script>
</body> </body>
<html> <html>
\ No newline at end of file
<html>
<head><title>PDB Fixer</title></head>
<body>
The fixed PDB file is ready to save. The fixed PDB file is ready to save.
<p> <p>
<form method="post" action="/"> <form method="post" action="/">
<input type="submit" name="save" value="Save File"/> <input type="submit" name="save" value="Save File"/>
<input type="submit" name="newfile" value="Process Another File"/> <input type="submit" name="newfile" value="Process Another File"/>
</form> </form>
<script>
setCurrentStep(7)
</script>
</body> </body>
<html> <html>
<html>
<head><title>PDBFixer</title></head>
<body>
<h1>Welcome To PDBFixer!</h1> <h1>Welcome To PDBFixer!</h1>
Select a PDB file to load. It will be analyzed for problems. Select a PDB file to load. It will be analyzed for problems.
<p> <p>
...@@ -9,5 +6,8 @@ PDB File: <input type="file" name="pdbfile" onchange="document.getElementById('s ...@@ -9,5 +6,8 @@ PDB File: <input type="file" name="pdbfile" onchange="document.getElementById('s
<p> <p>
<input type="submit" id="submit" value="Analyze File" disabled/> <input type="submit" id="submit" value="Analyze File" disabled/>
</form> </form>
<script>
setCurrentStep(1)
</script>
</body> </body>
</html> </html>
...@@ -11,6 +11,13 @@ def loadHtmlFile(name): ...@@ -11,6 +11,13 @@ def loadHtmlFile(name):
file = os.path.join(htmlPath, name) file = os.path.join(htmlPath, name)
return open(file).read() 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): def startPageCallback(parameters, handler):
if 'pdbfile' in parameters: if 'pdbfile' in parameters:
global fixer global fixer
...@@ -56,7 +63,7 @@ def saveFilePageCallback(parameters, handler): ...@@ -56,7 +63,7 @@ def saveFilePageCallback(parameters, handler):
def displayStartPage(): def displayStartPage():
uiserver.setCallback(startPageCallback) uiserver.setCallback(startPageCallback)
uiserver.setContent(loadHtmlFile("start.html")) uiserver.setContent(header+loadHtmlFile("start.html"))
def displayDeleteChainsPage(): def displayDeleteChainsPage():
uiserver.setCallback(deleteChainsPageCallback) uiserver.setCallback(deleteChainsPageCallback)
...@@ -79,7 +86,7 @@ def displayDeleteChainsPage(): ...@@ -79,7 +86,7 @@ def displayDeleteChainsPage():
else: else:
content = ', '.join(set(residues)) 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) 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(): def displayAddResiduesPage():
uiserver.setCallback(addResiduesPageCallback) uiserver.setCallback(addResiduesPageCallback)
...@@ -91,7 +98,7 @@ def displayAddResiduesPage(): ...@@ -91,7 +98,7 @@ def displayAddResiduesPage():
for i, key in enumerate(sorted(fixer.missingResidues)): for i, key in enumerate(sorted(fixer.missingResidues)):
residues = fixer.missingResidues[key] 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) 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(): def displayConvertResiduesPage():
uiserver.setCallback(convertResiduesPageCallback) uiserver.setCallback(convertResiduesPageCallback)
...@@ -106,7 +113,7 @@ def displayConvertResiduesPage(): ...@@ -106,7 +113,7 @@ def displayConvertResiduesPage():
table = "" table = ""
for i, residue in enumerate(fixer.nonstandardResidues): 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) 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(): def displayMissingAtomsPage():
uiserver.setCallback(missingAtomsPageCallback) uiserver.setCallback(missingAtomsPageCallback)
...@@ -128,17 +135,20 @@ def displayMissingAtomsPage(): ...@@ -128,17 +135,20 @@ def displayMissingAtomsPage():
if residue in fixer.missingTerminals: if residue in fixer.missingTerminals:
atoms.extend(atom for atom in fixer.missingTerminals[residue]) 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)) 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(): def displayAddHydrogensPage():
uiserver.setCallback(addHydrogensPageCallback) uiserver.setCallback(addHydrogensPageCallback)
uiserver.setContent(loadHtmlFile("addHydrogens.html")) uiserver.setContent(header+loadHtmlFile("addHydrogens.html"))
def displaySaveFilePage(): def displaySaveFilePage():
uiserver.setCallback(saveFilePageCallback) uiserver.setCallback(saveFilePageCallback)
uiserver.setContent(loadHtmlFile("saveFile.html")) uiserver.setContent(header+loadHtmlFile("saveFile.html"))
def launchUI(): def launchUI():
global header
header = loadHtmlFile("header.html")
uiserver.beginServing() uiserver.beginServing()
uiserver.setCallback(controlsCallback, "/controls")
displayStartPage() displayStartPage()
webbrowser.open('http://localhost:'+str(uiserver.server.server_address[1])) webbrowser.open('http://localhost:'+str(uiserver.server.server_address[1]))
\ No newline at end of file
...@@ -13,25 +13,34 @@ class _Handler(BaseHTTPRequestHandler): ...@@ -13,25 +13,34 @@ class _Handler(BaseHTTPRequestHandler):
parameters = parse_qs(self.path[queryStart+1:]) parameters = parse_qs(self.path[queryStart+1:])
else: else:
parameters = {} parameters = {}
result = callback(parameters, self) self.invokeCallback(parameters)
if not self.hasSentResponse: if not self.hasSentResponse:
self.sendResponse(content) self.sendResponse(content)
def do_POST(self): def do_POST(self):
self.hasSentResponse = False 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']})
parameters = cgi.FieldStorage(fp=self.rfile, headers=self.headers, environ={'REQUEST_METHOD':'POST', 'CONTENT_TYPE':self.headers['Content-Type']}) self.invokeCallback(parameters)
callback(parameters, self)
if not self.hasSentResponse: if not self.hasSentResponse:
self.sendResponse(content) 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): def sendResponse(self, response):
self.hasSentResponse = True self.hasSentResponse = True
self.send_response(200) self.send_response(200)
self.send_header("Content-type", "text/html") 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.end_headers()
self.wfile.write(content) self.wfile.write(response)
def sendDownload(self, download, filename): def sendDownload(self, download, filename):
self.hasSentResponse = True self.hasSentResponse = True
...@@ -46,7 +55,7 @@ class _ThreadingHTTPServer(ThreadingMixIn, HTTPServer): ...@@ -46,7 +55,7 @@ class _ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
pass pass
content = "" content = ""
callback = None callback = {}
server = _ThreadingHTTPServer(("localhost", 8000), _Handler) server = _ThreadingHTTPServer(("localhost", 8000), _Handler)
def beginServing(): def beginServing():
...@@ -56,7 +65,6 @@ def setContent(newContent): ...@@ -56,7 +65,6 @@ def setContent(newContent):
global content global content
content = newContent content = newContent
def setCallback(newCallback): def setCallback(newCallback, path="/"):
global callback 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