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
d8545b79
"openmmapi/src/GayBerneForceImpl.cpp" did not exist on "27a2456b0fa62eb3df0c3dedbcd3af9ff86a1ec8"
Commit
d8545b79
authored
Sep 20, 2012
by
Peter Eastman
Browse files
PDBFile loads all frames in the file. Also fixed a bug.
parent
04fe2449
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
11 deletions
+22
-11
wrappers/python/simtk/openmm/app/gromacsgrofile.py
wrappers/python/simtk/openmm/app/gromacsgrofile.py
+1
-1
wrappers/python/simtk/openmm/app/pdbfile.py
wrappers/python/simtk/openmm/app/pdbfile.py
+21
-10
No files found.
wrappers/python/simtk/openmm/app/gromacsgrofile.py
View file @
d8545b79
...
@@ -176,7 +176,7 @@ class GromacsGroFile(object):
...
@@ -176,7 +176,7 @@ class GromacsGroFile(object):
if
self
.
_numpyPositions
is
None
:
if
self
.
_numpyPositions
is
None
:
self
.
_numpyPositions
=
[
None
]
*
len
(
self
.
_positions
)
self
.
_numpyPositions
=
[
None
]
*
len
(
self
.
_positions
)
if
self
.
_numpyPositions
[
frame
]
is
None
:
if
self
.
_numpyPositions
[
frame
]
is
None
:
self
.
_numpyPositions
[
frame
]
=
numpy
.
array
(
self
.
_positions
[
frame
].
value_in_unit
(
nanometers
))
*
nanometers
self
.
_numpyPositions
[
frame
]
=
Quantity
(
numpy
.
array
(
self
.
_positions
[
frame
].
value_in_unit
(
nanometers
))
,
nanometers
)
return
self
.
_numpyPositions
[
frame
]
return
self
.
_numpyPositions
[
frame
]
return
self
.
_positions
[
frame
]
return
self
.
_positions
[
frame
]
...
...
wrappers/python/simtk/openmm/app/pdbfile.py
View file @
d8545b79
...
@@ -65,13 +65,12 @@ class PDBFile(object):
...
@@ -65,13 +65,12 @@ class PDBFile(object):
- file (string) the name of the file to load
- file (string) the name of the file to load
"""
"""
top
=
Topology
()
top
=
Topology
()
coords
=
[];
## The Topology read from the PDB file
## The Topology read from the PDB file
self
.
topology
=
top
self
.
topology
=
top
# Load the PDB file
# Load the PDB file
pdb
=
PdbStructure
(
open
(
file
))
pdb
=
PdbStructure
(
open
(
file
)
,
load_all_models
=
True
)
PDBFile
.
_loadNameReplacementTables
()
PDBFile
.
_loadNameReplacementTables
()
# Build the topology
# Build the topology
...
@@ -119,10 +118,15 @@ class PDBFile(object):
...
@@ -119,10 +118,15 @@ class PDBFile(object):
pass
pass
newAtom
=
top
.
addAtom
(
atomName
,
element
,
r
)
newAtom
=
top
.
addAtom
(
atomName
,
element
,
r
)
atomByNumber
[
atom
.
serial_number
]
=
newAtom
atomByNumber
[
atom
.
serial_number
]
=
newAtom
self
.
_positions
=
[]
for
model
in
pdb
.
iter_models
(
True
):
coords
=
[]
for
atom
in
model
.
iter_atoms
():
pos
=
atom
.
get_position
().
value_in_unit
(
nanometers
)
pos
=
atom
.
get_position
().
value_in_unit
(
nanometers
)
coords
.
append
(
Vec3
(
pos
[
0
],
pos
[
1
],
pos
[
2
]))
coords
.
append
(
Vec3
(
pos
[
0
],
pos
[
1
],
pos
[
2
]))
## The atom positions read from the PDB file
self
.
_positions
.
append
(
coords
*
nanometers
)
self
.
positions
=
coords
*
nanometers
## The atom positions read from the PDB file. If the file contains multiple frames, these are the positions in the first frame.
self
.
positions
=
self
.
_positions
[
0
]
self
.
topology
.
setUnitCellDimensions
(
pdb
.
get_unit_cell_dimensions
())
self
.
topology
.
setUnitCellDimensions
(
pdb
.
get_unit_cell_dimensions
())
self
.
topology
.
createStandardBonds
()
self
.
topology
.
createStandardBonds
()
self
.
topology
.
createDisulfideBonds
(
self
.
positions
)
self
.
topology
.
createDisulfideBonds
(
self
.
positions
)
...
@@ -147,17 +151,24 @@ class PDBFile(object):
...
@@ -147,17 +151,24 @@ class PDBFile(object):
"""Get the Topology of the model."""
"""Get the Topology of the model."""
return
self
.
topology
return
self
.
topology
def
getPositions
(
self
,
asNumpy
=
False
):
def
getNumFrames
(
self
):
"""Get the number of frames stored in the file."""
return
len
(
self
.
_positions
)
def
getPositions
(
self
,
asNumpy
=
False
,
frame
=
0
):
"""Get the atomic positions.
"""Get the atomic positions.
Parameters:
Parameters:
- asNumpy (boolean=False) if true, the values are returned as a numpy array instead of a list of Vec3s
- asNumpy (boolean=False) if true, the values are returned as a numpy array instead of a list of Vec3s
- frame (int=0) the index of the frame for which to get positions
"""
"""
if
asNumpy
:
if
asNumpy
:
if
self
.
_numpyPositions
is
None
:
if
self
.
_numpyPositions
is
None
:
self
.
_numpyPositions
=
numpy
.
array
(
self
.
positions
.
value_in_unit
(
nanometers
))
*
nanometers
self
.
_numpyPositions
=
[
None
]
*
len
(
self
.
_positions
)
return
self
.
_numpyPositions
if
self
.
_numpyPositions
[
frame
]
is
None
:
return
self
.
positions
self
.
_numpyPositions
[
frame
]
=
Quantity
(
numpy
.
array
(
self
.
_positions
[
frame
].
value_in_unit
(
nanometers
)),
nanometers
)
return
self
.
_numpyPositions
[
frame
]
return
self
.
_positions
[
frame
]
@
staticmethod
@
staticmethod
def
_loadNameReplacementTables
():
def
_loadNameReplacementTables
():
...
...
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