Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pdbfixer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pdbfixer
Commits
06591a81
Commit
06591a81
authored
Feb 12, 2015
by
peastman
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #40 from mpharrigan/py3
Py3
parents
d3f014a5
cad7e8ae
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
31 deletions
+50
-31
.travis.yml
+7
-0
pdbfixer/__init__.py
+3
-1
pdbfixer/pdbfixer.py
+3
-3
pdbfixer/ui.py
+19
-10
pdbfixer/uiserver.py
+1
-1
tests/test_build_and_simulate.py
+17
-16
No files found.
.travis.yml
View file @
06591a81
language
:
c
language
:
c
env
:
matrix
:
-
CONDA_PY=2.7
-
CONDA_PY=3.3
-
CONDA_PY=3.4
install
:
install
:
-
sudo apt-get update -qq
-
sudo apt-get update -qq
-
sudo apt-get install -qq python-dev python-pip python-yaml g++ ftp
-
sudo apt-get install -qq python-dev python-pip python-yaml g++ ftp
...
...
pdbfixer/__init__.py
View file @
06591a81
from
pdbfixer
import
PDBFixer
from
__future__
import
absolute_import
from
.pdbfixer
import
PDBFixer
pdbfixer/pdbfixer.py
View file @
06591a81
...
@@ -28,6 +28,7 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
...
@@ -28,6 +28,7 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
"""
from
__future__
import
absolute_import
__author__
=
"Peter Eastman"
__author__
=
"Peter Eastman"
__version__
=
"1.1"
__version__
=
"1.1"
...
@@ -207,7 +208,7 @@ class PDBFixer(object):
...
@@ -207,7 +208,7 @@ class PDBFixer(object):
self
.
source
=
url
self
.
source
=
url
file
=
urlopen
(
url
)
file
=
urlopen
(
url
)
# Read contents all at once and split into lines, since urlopen doesn't like it when we read one line at a time over the network.
# Read contents all at once and split into lines, since urlopen doesn't like it when we read one line at a time over the network.
contents
=
file
.
read
()
contents
=
file
.
read
()
.
decode
(
'utf-8'
)
lines
=
contents
.
split
(
'
\n
'
)
lines
=
contents
.
split
(
'
\n
'
)
file
.
close
()
file
.
close
()
structure
=
PdbStructure
(
lines
)
structure
=
PdbStructure
(
lines
)
...
@@ -1027,8 +1028,7 @@ class PDBFixer(object):
...
@@ -1027,8 +1028,7 @@ class PDBFixer(object):
def
main
():
def
main
():
if
len
(
sys
.
argv
)
<
2
:
if
len
(
sys
.
argv
)
<
2
:
# Display the UI.
# Display the UI.
from
.
import
ui
import
ui
ui
.
launchUI
()
ui
.
launchUI
()
else
:
else
:
# Run in command line mode.
# Run in command line mode.
...
...
pdbfixer/ui.py
View file @
06591a81
import
simtk.openmm.app
as
app
from
__future__
import
absolute_import
from
simtk.openmm.app.internal.pdbstructure
import
PdbStructure
import
simtk.unit
as
unit
from
pdbfixer
import
PDBFixer
,
substitutions
,
proteinResidues
,
dnaResidues
,
rnaResidues
import
uiserver
import
webbrowser
import
webbrowser
import
os.path
import
os.path
import
gzip
import
time
import
time
from
io
import
BytesIO
import
simtk.openmm.app
as
app
import
simtk.unit
as
unit
from
.pdbfixer
import
PDBFixer
,
proteinResidues
,
dnaResidues
,
rnaResidues
from
.
import
uiserver
try
:
try
:
from
urllib.request
import
urlopen
from
urllib.request
import
urlopen
from
io
import
StringIO
from
io
import
StringIO
...
@@ -27,7 +29,7 @@ def loadImageFile(name):
...
@@ -27,7 +29,7 @@ def loadImageFile(name):
if
name
not
in
cachedImages
:
if
name
not
in
cachedImages
:
imagePath
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'images'
)
imagePath
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'images'
)
file
=
os
.
path
.
join
(
imagePath
,
name
)
file
=
os
.
path
.
join
(
imagePath
,
name
)
cachedImages
[
name
]
=
open
(
file
)
.
read
()
cachedImages
[
name
]
=
open
(
file
,
'rb'
)
.
read
()
return
cachedImages
[
name
]
return
cachedImages
[
name
]
def
controlsCallback
(
parameters
,
handler
):
def
controlsCallback
(
parameters
,
handler
):
...
@@ -59,8 +61,15 @@ def startPageCallback(parameters, handler):
...
@@ -59,8 +61,15 @@ def startPageCallback(parameters, handler):
id
=
parameters
.
getfirst
(
'pdbid'
)
id
=
parameters
.
getfirst
(
'pdbid'
)
try
:
try
:
fixer
=
PDBFixer
(
pdbid
=
id
)
fixer
=
PDBFixer
(
pdbid
=
id
)
except
:
except
Exception
as
e
:
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"
))
import
traceback
print
(
traceback
.
format_exc
())
handler
.
sendResponse
(
header
+
"<p>Unable to download the PDB file. "
+
"This may indicate an invalid PDB identifier, "
+
"or an error in network connectivity.</p>"
+
"<p>{}</p>"
.
format
(
e
)
+
loadHtmlFile
(
"error.html"
))
displayDeleteChainsPage
()
displayDeleteChainsPage
()
def
deleteChainsPageCallback
(
parameters
,
handler
):
def
deleteChainsPageCallback
(
parameters
,
handler
):
...
...
pdbfixer/uiserver.py
View file @
06591a81
...
@@ -46,7 +46,7 @@ class _Handler(BaseHTTPRequestHandler):
...
@@ -46,7 +46,7 @@ class _Handler(BaseHTTPRequestHandler):
self
.
send_header
(
"Content-type"
,
type
)
self
.
send_header
(
"Content-type"
,
type
)
self
.
send_header
(
"Content-length"
,
str
(
len
(
response
)))
self
.
send_header
(
"Content-length"
,
str
(
len
(
response
)))
self
.
end_headers
()
self
.
end_headers
()
if
sys
.
version_info
.
major
>
2
:
if
sys
.
version_info
.
major
>
2
and
isinstance
(
response
,
str
)
:
response
=
bytes
(
response
,
'UTF-8'
)
response
=
bytes
(
response
,
'UTF-8'
)
self
.
wfile
.
write
(
response
)
self
.
wfile
.
write
(
response
)
...
...
tests/test_build_and_simulate.py
View file @
06591a81
from
__future__
import
print_function
import
pdbfixer
import
pdbfixer
import
simtk.openmm
import
simtk.openmm
...
@@ -79,7 +80,7 @@ def simulate(pdbcode, pdb_filename):
...
@@ -79,7 +80,7 @@ def simulate(pdbcode, pdb_filename):
del
context
,
integrator
del
context
,
integrator
print
"Simulation completed: potential =
%.3
f kcal/mol"
%
potential
print
(
"Simulation completed: potential =
%.3
f kcal/mol"
%
potential
)
return
return
...
@@ -105,8 +106,8 @@ def test_build_and_simulate():
...
@@ -105,8 +106,8 @@ def test_build_and_simulate():
failures
=
list
()
failures
=
list
()
for
pdbcode
in
pdbcodes_to_build
:
for
pdbcode
in
pdbcodes_to_build
:
print
"------------------------------------------------"
print
(
"------------------------------------------------"
)
print
pdbcode
print
(
pdbcode
)
output_pdb_filename
=
'output.pdb'
output_pdb_filename
=
'output.pdb'
...
@@ -152,14 +153,14 @@ def test_build_and_simulate():
...
@@ -152,14 +153,14 @@ def test_build_and_simulate():
except
Watchdog
:
except
Watchdog
:
message
=
"timed out in stage
%
s"
%
stage
message
=
"timed out in stage
%
s"
%
stage
print
message
print
(
message
)
failures
.
append
((
pdbcode
,
Exception
(
message
)))
failures
.
append
((
pdbcode
,
Exception
(
message
)))
except
Exception
as
e
:
except
Exception
as
e
:
print
"EXCEPTION DURING BUILD"
print
(
"EXCEPTION DURING BUILD"
)
#import traceback
#import traceback
#print traceback.print_exc()
#print traceback.print_exc()
print
str
(
e
)
print
(
str
(
e
)
)
failures
.
append
((
pdbcode
,
e
))
failures
.
append
((
pdbcode
,
e
))
watchdog
.
stop
()
watchdog
.
stop
()
...
@@ -173,14 +174,14 @@ def test_build_and_simulate():
...
@@ -173,14 +174,14 @@ def test_build_and_simulate():
except
Watchdog
:
except
Watchdog
:
message
=
"timed out in simulation"
message
=
"timed out in simulation"
print
message
print
(
message
)
failures
.
append
((
pdbcode
,
Exception
(
message
)))
failures
.
append
((
pdbcode
,
Exception
(
message
)))
except
Exception
as
e
:
except
Exception
as
e
:
print
"EXCEPTION DURING SIMULATE"
print
(
"EXCEPTION DURING SIMULATE"
)
#import traceback
#import traceback
#print traceback.print_exc()
#print traceback.print_exc()
print
str
(
e
)
print
(
str
(
e
)
)
failures
.
append
((
pdbcode
,
e
))
failures
.
append
((
pdbcode
,
e
))
watchdog
.
stop
()
watchdog
.
stop
()
...
@@ -189,21 +190,21 @@ def test_build_and_simulate():
...
@@ -189,21 +190,21 @@ def test_build_and_simulate():
# Clean up.
# Clean up.
os
.
remove
(
output_pdb_filename
)
os
.
remove
(
output_pdb_filename
)
print
"------------------------------------------------"
print
(
"------------------------------------------------"
)
if
len
(
failures
)
!=
0
:
if
len
(
failures
)
!=
0
:
print
""
print
(
""
)
print
"SUMMARY OF FAILURES:"
print
(
"SUMMARY OF FAILURES:"
)
print
""
print
(
""
)
for
failure
in
failures
:
for
failure
in
failures
:
(
pdbcode
,
exception
)
=
failure
(
pdbcode
,
exception
)
=
failure
print
"
%6
s :
%
s"
%
(
pdbcode
,
str
(
exception
))
print
(
"
%6
s :
%
s"
%
(
pdbcode
,
str
(
exception
)
))
print
""
print
(
""
)
raise
Exception
(
"Build test failed on one or more PDB files."
)
raise
Exception
(
"Build test failed on one or more PDB files."
)
else
:
else
:
print
"All tests succeeded."
print
(
"All tests succeeded."
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_build_and_simulate
()
test_build_and_simulate
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment