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
418987b4
Commit
418987b4
authored
Apr 19, 2014
by
Jason Swails
Browse files
Coordinates and velocities have to be natom-length iterators of Vec3's
parent
539c1f1d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
12 deletions
+11
-12
wrappers/python/simtk/openmm/app/charmmcrdfiles.py
wrappers/python/simtk/openmm/app/charmmcrdfiles.py
+11
-12
No files found.
wrappers/python/simtk/openmm/app/charmmcrdfiles.py
View file @
418987b4
...
@@ -36,8 +36,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
...
@@ -36,8 +36,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
from
simtk.openmm.app.internal.charmm.exceptions
import
CharmmFileError
from
simtk.openmm.app.internal.charmm.exceptions
import
CharmmFileError
import
simtk.unit
as
u
import
simtk.unit
as
u
from
simtk.openmm.vec3
import
Vec3
charmlen
=
22
CHARMMLEN
=
22
TIMESCALE
=
4.888821E-14
*
1e12
# AKMA time units to picoseconds
TIMESCALE
=
4.888821E-14
*
1e12
# AKMA time units to picoseconds
ONE_TIMESCALE
=
1
/
TIMESCALE
ONE_TIMESCALE
=
1
/
TIMESCALE
...
@@ -103,23 +104,21 @@ class CharmmCrdFile(object):
...
@@ -103,23 +104,21 @@ class CharmmCrdFile(object):
self
.
resno
.
append
(
int
(
line
[
1
]))
self
.
resno
.
append
(
int
(
line
[
1
]))
self
.
resname
.
append
(
line
[
2
])
self
.
resname
.
append
(
line
[
2
])
self
.
attype
.
append
(
line
[
3
])
self
.
attype
.
append
(
line
[
3
])
self
.
positions
.
append
(
float
(
line
[
4
]))
pos
=
Vec3
(
float
(
line
[
4
]),
float
(
line
[
5
]),
float
(
line
[
6
]))
self
.
positions
.
append
(
float
(
line
[
5
]))
self
.
positions
.
append
(
pos
*
u
.
angstroms
)
self
.
positions
.
append
(
float
(
line
[
6
]))
self
.
segid
.
append
(
line
[
7
])
self
.
segid
.
append
(
line
[
7
])
self
.
resid
.
append
(
int
(
line
[
8
]))
self
.
resid
.
append
(
int
(
line
[
8
]))
self
.
weighting
.
append
(
float
(
line
[
9
]))
self
.
weighting
.
append
(
float
(
line
[
9
]))
if
3
*
self
.
natom
!=
len
(
self
.
positions
):
if
self
.
natom
!=
len
(
self
.
positions
):
raise
CharmmFileError
(
"Error parsing CHARMM .crd file: %d "
raise
CharmmFileError
(
"Error parsing CHARMM .crd file: %d "
"atoms requires %d positions (not %d)"
%
"atoms requires %d positions (not %d)"
%
(
self
.
natom
,
3
*
self
.
natom
,
(
self
.
natom
,
self
.
natom
,
len
(
self
.
positions
))
len
(
self
.
positions
))
)
)
except
(
ValueError
,
IndexError
),
e
:
except
(
ValueError
,
IndexError
),
e
:
raise
CharmmFileError
(
'Error parsing CHARMM coordinate file'
)
raise
CharmmFileError
(
'Error parsing CHARMM coordinate file'
)
self
.
positions
*=
u
.
angstrom
class
CharmmRstFile
(
object
):
class
CharmmRstFile
(
object
):
"""
"""
...
@@ -235,18 +234,18 @@ class CharmmRstFile(object):
...
@@ -235,18 +234,18 @@ class CharmmRstFile(object):
if
not
line
:
if
not
line
:
raise
CharmmFileError
(
'Premature end of file'
)
raise
CharmmFileError
(
'Premature end of file'
)
if
len
(
line
)
<
3
*
charmlen
:
if
len
(
line
)
<
3
*
CHARMMLEN
:
raise
CharmmFileError
(
"Less than 3 coordinates present in "
raise
CharmmFileError
(
"Less than 3 coordinates present in "
"coordinate row or positions may be "
"coordinate row or positions may be "
"truncated."
)
"truncated."
)
line
=
line
.
replace
(
'D'
,
'E'
)
# CHARMM uses 'D' for exponentials
line
=
line
.
replace
(
'D'
,
'E'
)
# CHARMM uses 'D' for exponentials
# CHARMM uses fixed format (len =
charmlen
= 22) for crds in .rst's
# CHARMM uses fixed format (len =
CHARMMLEN
= 22) for crds in .rst's
c
rds
.
append
(
float
(
line
[
0
:
charmlen
]))
c
=
Vec3
(
float
(
line
[
0
:
CHARMMLEN
]),
float
(
line
[
CHARMMLEN
:
2
*
CHARMMLEN
]),
crds
.
append
(
float
(
line
[
charmlen
:
2
*
charmlen
]))
float
(
line
[
2
*
CHARMMLEN
:
3
*
CHARMMLEN
]))
crds
.
append
(
float
(
line
[
2
*
charmlen
:
3
*
charmlen
])
)
crds
.
append
(
c
)
def
printcoords
(
self
,
crds
):
def
printcoords
(
self
,
crds
):
...
...
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