Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tbgl
tools
mrdna
Commits
6457307f
Commit
6457307f
authored
Mar 20, 2018
by
cmaffeo2
Browse files
arbdmodel now preserves particle order
parent
47414bcf
Changes
1
Hide whitespace changes
Inline
Side-by-side
arbdmodel.py
View file @
6457307f
...
...
@@ -491,8 +491,8 @@ class ArbdModel(PdbModel):
def
_updateParticleOrder
(
self
):
## Create ordered list
particles
=
[
p
for
p
in
self
]
self
.
particles
=
sorted
(
particles
,
key
=
lambda
p
:
(
p
.
type_
,
p
.
idx
))
self
.
particles
=
[
p
for
p
in
self
]
#
self.particles = sorted(particles, key=lambda p: (p.type_, p.idx))
## Update particle indices
for
p
,
i
in
zip
(
self
.
particles
,
range
(
len
(
self
.
particles
))):
...
...
@@ -509,7 +509,7 @@ class ArbdModel(PdbModel):
assert
(
type
(
gpu
)
is
int
)
numSteps
=
int
(
numSteps
)
if
self
.
cacheUpToDate
==
False
:
if
self
.
cacheUpToDate
==
False
:
# TODO: remove cache?
self
.
_countParticleTypes
()
self
.
_updateParticleOrder
()
...
...
@@ -566,7 +566,8 @@ class ArbdModel(PdbModel):
self
.
_dihedral_filename
=
"%s/%s.dihedrals.txt"
%
(
d
,
prefix
)
self
.
_exclusion_filename
=
"%s/%s.exculsions.txt"
%
(
d
,
prefix
)
self
.
_writeArbdCoordFile
(
prefix
+
".coord.txt"
)
# self._writeArbdCoordFile( prefix + ".coord.txt" )
self
.
_writeArbdParticleFile
(
prefix
+
".particles.txt"
)
self
.
_writeArbdBondFile
()
self
.
_writeArbdAngleFile
()
self
.
_writeArbdDihedralFile
()
...
...
@@ -574,10 +575,17 @@ class ArbdModel(PdbModel):
self
.
_writeArbdPotentialFiles
(
prefix
,
directory
=
d
)
self
.
_writeArbdConf
(
prefix
,
numSteps
=
numSteps
,
outputPeriod
=
outputPeriod
)
def
_writeArbdCoordFile
(
self
,
filename
):
# def _writeArbdCoordFile(self, filename):
# with open(filename,'w') as fh:
# for p in self.particles:
# fh.write("%f %f %f\n" % tuple(x for x in p.collapsedPosition()))
def
_writeArbdParticleFile
(
self
,
filename
):
with
open
(
filename
,
'w'
)
as
fh
:
for
p
in
self
.
particles
:
fh
.
write
(
"%f %f %f
\n
"
%
tuple
(
x
for
x
in
p
.
collapsedPosition
()))
data
=
tuple
([
p
.
idx
,
p
.
name
]
+
[
x
for
x
in
p
.
collapsedPosition
()])
fh
.
write
(
"ATOM %d %s %f %f %f
\n
"
%
data
)
def
_writeArbdConf
(
self
,
prefix
,
randomSeed
=
None
,
numSteps
=
100000000
,
outputPeriod
=
10000
,
restartCoordinateFile
=
None
):
## TODO: raise exception if _writeArbdPotentialFiles has not been called
...
...
@@ -592,7 +600,8 @@ class ArbdModel(PdbModel):
params
[
'randomSeed'
]
=
"seed %s"
%
randomSeed
params
[
'numSteps'
]
=
int
(
numSteps
)
params
[
'coordinateFile'
]
=
"%s.coord.txt"
%
prefix
# params['coordinateFile'] = "%s.coord.txt" % prefix
params
[
'particleFile'
]
=
"%s.particles.txt"
%
prefix
if
restartCoordinateFile
is
None
:
params
[
'restartCoordinates'
]
=
""
else
:
...
...
@@ -646,7 +655,7 @@ diffusion {diffusivity}
## Write coordinates and interactions
fh
.
write
(
"""
## Input coordinates
input
Coordinates {coordinat
eFile}
input
Particles {particl
eFile}
{restartCoordinates}
## Interaction potentials
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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