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
a8df200d
Commit
a8df200d
authored
Nov 14, 2014
by
peastman
Browse files
Merge pull request #722 from swails/fix_dcd
[WIP]Fix byte handling to work for both Py2 and Py3
parents
3a3a2aa1
c6b6b894
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
wrappers/python/simtk/openmm/app/dcdfile.py
wrappers/python/simtk/openmm/app/dcdfile.py
+1
-1
wrappers/python/simtk/openmm/app/pdbfile.py
wrappers/python/simtk/openmm/app/pdbfile.py
+4
-0
wrappers/python/tests/TestDcdFile.py
wrappers/python/tests/TestDcdFile.py
+22
-0
No files found.
wrappers/python/simtk/openmm/app/dcdfile.py
View file @
a8df200d
...
...
@@ -73,7 +73,7 @@ class DCDFile(object):
header
=
struct
.
pack
(
'<i4c9if'
,
84
,
b
'C'
,
b
'O'
,
b
'R'
,
b
'D'
,
0
,
firstStep
,
interval
,
0
,
0
,
0
,
0
,
0
,
0
,
dt
)
header
+=
struct
.
pack
(
'<13i'
,
boxFlag
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
24
,
84
,
164
,
2
)
header
+=
struct
.
pack
(
'<80s'
,
b
'Created by OpenMM'
)
header
+=
struct
.
pack
(
'<80s'
,
b
'Created '
+
bytes
(
time
.
asctime
(
time
.
localtime
(
time
.
time
()))
,
'ascii'
))
header
+=
struct
.
pack
(
'<80s'
,
b
'Created '
+
time
.
asctime
(
time
.
localtime
(
time
.
time
()))
.
encode
(
'ascii'
))
header
+=
struct
.
pack
(
'<4i'
,
164
,
4
,
len
(
list
(
topology
.
atoms
())),
4
)
file
.
write
(
header
)
...
...
wrappers/python/simtk/openmm/app/pdbfile.py
View file @
a8df200d
...
...
@@ -75,9 +75,13 @@ class PDBFile(object):
pdb
=
file
else
:
inputfile
=
file
own_handle
=
False
if
isinstance
(
file
,
str
):
inputfile
=
open
(
file
)
own_handle
=
True
pdb
=
PdbStructure
(
inputfile
,
load_all_models
=
True
)
if
own_handle
:
inputfile
.
close
()
PDBFile
.
_loadNameReplacementTables
()
# Build the topology
...
...
wrappers/python/tests/TestDcdFile.py
0 → 100644
View file @
a8df200d
import
unittest
import
tempfile
from
simtk.openmm
import
app
import
simtk.openmm
as
mm
from
simtk
import
unit
from
random
import
random
import
os
class
TestDCDFile
(
unittest
.
TestCase
):
def
test_dcd
(
self
):
""" Test the DCD file """
fname
=
tempfile
.
mktemp
(
suffix
=
'.dcd'
)
pdbfile
=
app
.
PDBFile
(
'systems/alanine-dipeptide-implicit.pdb'
)
natom
=
len
(
list
(
pdbfile
.
topology
.
atoms
()))
with
open
(
fname
,
'wb'
)
as
f
:
dcd
=
app
.
DCDFile
(
f
,
pdbfile
.
topology
,
0.001
)
for
i
in
range
(
5
):
dcd
.
writeModel
([
mm
.
Vec3
(
random
(),
random
(),
random
())
for
j
in
range
(
natom
)]
*
unit
.
angstroms
)
os
.
remove
(
fname
)
if
__name__
==
'__main__'
:
unittest
.
main
()
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