Commit 8d902d07 by Peter Eastman

Added option to download files directly from RCSB

parent 72f2ac89
...@@ -18,7 +18,7 @@ A heterogen is any residue other than a standard amino acid or nucleotide. Do y ...@@ -18,7 +18,7 @@ A heterogen is any residue other than a standard amino acid or nucleotide. Do y
<option value="water">Delete heterogens except water</option> <option value="water">Delete heterogens except water</option>
<option value="none">Delete all heterogens</option> <option value="none">Delete all heterogens</option>
</select> </select>
<h1>Add Missing Hyrogens</h1> <h1>Add Missing Hydrogens</h1>
Add missing hydrogen atoms? Add missing hydrogen atoms?
<p> <p>
<input type="checkbox" id="addCheckbox" name="add" checked> Add hydrogens appropriate for pH <input type="text" id="phfield" name="ph" value="7.0" size="5"> <input type="checkbox" id="addCheckbox" name="add" checked> Add hydrogens appropriate for pH <input type="text" id="phfield" name="ph" value="7.0" size="5">
......
<p>
<form method="post" action="/controls">
<input type="submit" name="newfile" value="Start Over"/>
</form>
<script>
setCurrentStep(1)
</script>
</body>
<html>
<script>
function enableInputs() {
if (document.getElementById("localtype").checked) {
document.getElementById("pdbfile").disabled = false;
document.getElementById("pdbid").disabled = true;
document.getElementById("submit").disabled = (document.getElementById("pdbfile").value == "");
}
else {
document.getElementById("pdbfile").disabled = true;
document.getElementById("pdbid").disabled = false;
document.getElementById("submit").disabled = (document.getElementById("pdbid").value.length != 4);
}
}
</script>
<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>
<form method="post" action="/" enctype="multipart/form-data"> <form method="post" action="/" enctype="multipart/form-data">
PDB File: <input type="file" name="pdbfile" onchange="document.getElementById('submit').disabled=false;"/> <input type="radio" name="type" id="localtype" value="local" onchange="enableInputs()" checked>Load a local file
<p> <p style="margin-left:50px">
PDB File: <input type="file" id="pdbfile" name="pdbfile" onchange="enableInputs()"/>
</p>
<input type="radio" name="type" id="remotetype" value="remote" onchange="enableInputs()">Download a file from RCSB
<p style="margin-left:50px">
PDB Identifier: <input type="text" id="pdbid" name="pdbid" size="4" onchange="enableInputs()" onkeyup="enableInputs()" oninput="enableInputs()" disabled>
</p>
<input type="submit" id="submit" value="Analyze File" disabled/> <input type="submit" id="submit" value="Analyze File" disabled/>
</form> </form>
<script> <script>
......
...@@ -4,6 +4,8 @@ from pdbfixer import PDBFixer, substitutions, proteinResidues, dnaResidues, rnaR ...@@ -4,6 +4,8 @@ from pdbfixer import PDBFixer, substitutions, proteinResidues, dnaResidues, rnaR
import uiserver import uiserver
import webbrowser import webbrowser
import os.path import os.path
import urllib2
import gzip
from cStringIO import StringIO from cStringIO import StringIO
def loadHtmlFile(name): def loadHtmlFile(name):
...@@ -19,11 +21,23 @@ def controlsCallback(parameters, handler): ...@@ -19,11 +21,23 @@ def controlsCallback(parameters, handler):
uiserver.server.shutdown() uiserver.server.shutdown()
def startPageCallback(parameters, handler): def startPageCallback(parameters, handler):
if 'pdbfile' in parameters: global fixer
global fixer if 'type' in parameters:
pdb = PdbStructure(parameters['pdbfile'].value.splitlines()) if parameters.getfirst('type') == 'local':
fixer = PDBFixer(pdb) pdb = PdbStructure(parameters['pdbfile'].value.splitlines())
displayDeleteChainsPage() fixer = PDBFixer(pdb)
displayDeleteChainsPage()
else:
id = parameters.getfirst('pdbid')
url = "ftp://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb/pdb"+id.lower()+".ent.gz"
try:
response = urllib2.urlopen(url)
content = gzip.GzipFile(fileobj=StringIO(response.read())).read()
pdb = PdbStructure(content.splitlines())
fixer = PDBFixer(pdb)
displayDeleteChainsPage()
except:
handler.sendResponse(header+"Unable to download the PDB file. This may indicate an invalid PDB identifier, or an error in network connectivity."+loadHtmlFile("error.html"))
def deleteChainsPageCallback(parameters, handler): def deleteChainsPageCallback(parameters, handler):
numChains = len(list(fixer.topology.chains())) numChains = len(list(fixer.topology.chains()))
......
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