Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
8d276c26
Commit
8d276c26
authored
Feb 27, 2015
by
peastman
Browse files
Merge pull request #839 from peastman/decode
PdbStructure handles byte streams correctly in Python 3
parents
decb586c
9fee45f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
0 deletions
+8
-0
wrappers/python/simtk/openmm/app/internal/pdbstructure.py
wrappers/python/simtk/openmm/app/internal/pdbstructure.py
+2
-0
wrappers/python/tests/TestPdbFile.py
wrappers/python/tests/TestPdbFile.py
+6
-0
No files found.
wrappers/python/simtk/openmm/app/internal/pdbstructure.py
View file @
8d276c26
...
...
@@ -150,6 +150,8 @@ class PdbStructure(object):
self
.
_reset_residue_numbers
()
# Read one line at a time
for
pdb_line
in
input_stream
:
if
not
isinstance
(
pdb_line
,
str
):
pdb_line
=
pdb_line
.
decode
(
'utf-8'
)
# Look for atoms
if
(
pdb_line
.
find
(
"ATOM "
)
==
0
)
or
(
pdb_line
.
find
(
"HETATM"
)
==
0
):
self
.
_add_atom
(
Atom
(
pdb_line
,
self
))
...
...
wrappers/python/tests/TestPdbFile.py
View file @
8d276c26
...
...
@@ -60,6 +60,12 @@ class TestPdbFile(unittest.TestCase):
self
.
assertEqual
(
atom1
.
name
,
atom2
.
name
)
self
.
assertEqual
(
atom1
.
residue
.
name
,
atom2
.
residue
.
name
)
def
test_BinaryStream
(
self
):
"""Test reading a stream that was opened in binary mode."""
pdb
=
PDBFile
(
open
(
'systems/triclinic.pdb'
,
'rb'
))
self
.
assertEqual
(
len
(
pdb
.
positions
),
8
)
def
assertVecAlmostEqual
(
self
,
p1
,
p2
,
tol
=
1e-7
):
unit
=
p1
.
unit
p1
=
p1
.
value_in_unit
(
unit
)
...
...
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