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
<option value="water">Delete heterogens except water</option>
<option value="none">Delete all heterogens</option>
</select>
<h1>Add Missing Hyrogens</h1>
<h1>Add Missing Hydrogens</h1>
Add missing hydrogen atoms?
<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">
......
<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>
Select a PDB file to load. It will be analyzed for problems.
<p>
<form method="post" action="/" enctype="multipart/form-data">
PDB File: <input type="file" name="pdbfile" onchange="document.getElementById('submit').disabled=false;"/>
<p>
<input type="radio" name="type" id="localtype" value="local" onchange="enableInputs()" checked>Load a local file
<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/>
</form>
<script>
......
......@@ -4,6 +4,8 @@ from pdbfixer import PDBFixer, substitutions, proteinResidues, dnaResidues, rnaR
import uiserver
import webbrowser
import os.path
import urllib2
import gzip
from cStringIO import StringIO
def loadHtmlFile(name):
......@@ -19,11 +21,23 @@ def controlsCallback(parameters, handler):
uiserver.server.shutdown()
def startPageCallback(parameters, handler):
if 'pdbfile' in parameters:
global fixer
pdb = PdbStructure(parameters['pdbfile'].value.splitlines())
fixer = PDBFixer(pdb)
displayDeleteChainsPage()
global fixer
if 'type' in parameters:
if parameters.getfirst('type') == 'local':
pdb = PdbStructure(parameters['pdbfile'].value.splitlines())
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):
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