Skip to content
GitLab
Menu
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
967b04d8
Commit
967b04d8
authored
Sep 10, 2018
by
cmaffeo2
Browse files
Added 'directory' option to arbdmodel.simulate
parent
f1c64034
Changes
1
Hide whitespace changes
Inline
Side-by-side
mrdna/model/arbdmodel.py
View file @
967b04d8
...
...
@@ -676,56 +676,68 @@ class ArbdModel(PdbModel):
if
typeA
!=
typeB
:
self
.
nbSchemes
.
append
(
(
nbScheme
,
typeB
,
typeA
)
)
def
simulate
(
self
,
outputPrefix
,
outputDirectory
=
'output'
,
numSteps
=
100000000
,
timestep
=
None
,
gpu
=
0
,
outputPeriod
=
1e4
,
arbd
=
None
):
def
simulate
(
self
,
outputPrefix
,
outputDirectory
=
'output'
,
numSteps
=
100000000
,
timestep
=
None
,
gpu
=
0
,
outputPeriod
=
1e4
,
arbd
=
None
,
directory
=
'.'
):
assert
(
type
(
gpu
)
is
int
)
numSteps
=
int
(
numSteps
)
if
timestep
is
not
None
:
self
.
timestep
=
timestep
d_orig
=
os
.
getcwd
()
try
:
if
not
os
.
path
.
exists
(
directory
):
os
.
makedirs
(
directory
)
os
.
chdir
(
directory
)
if
self
.
cacheUpToDate
==
False
:
# TODO: remove cache?
self
.
_countParticleTypes
()
self
.
_updateParticleOrder
()
if
timestep
is
not
None
:
self
.
timestep
=
timestep
if
outputDirectory
==
''
:
outputDirectory
=
'.'
if
arbd
is
None
:
for
path
in
os
.
environ
[
"PATH"
].
split
(
os
.
pathsep
):
path
=
path
.
strip
(
'"'
)
fname
=
os
.
path
.
join
(
path
,
"arbd"
)
if
os
.
path
.
isfile
(
fname
)
and
os
.
access
(
fname
,
os
.
X_OK
):
arbd
=
fname
break
if
arbd
is
None
:
raise
Exception
(
"ARBD was not found"
)
if
not
os
.
path
.
exists
(
arbd
):
raise
Exception
(
"ARBD was not found"
)
if
not
os
.
path
.
isfile
(
arbd
):
raise
Exception
(
"ARBD was not found"
)
if
not
os
.
access
(
arbd
,
os
.
X_OK
):
raise
Exception
(
"ARBD is not executable"
)
if
not
os
.
path
.
exists
(
outputDirectory
):
os
.
makedirs
(
outputDirectory
)
elif
not
os
.
path
.
isdir
(
outputDirectory
):
raise
Exception
(
"outputDirectory '%s' is not a directory!"
%
outputDirectory
)
if
self
.
cacheUpToDate
==
False
:
# TODO: remove cache?
self
.
_countParticleTypes
()
self
.
_updateParticleOrder
()
self
.
writePdb
(
outputPrefix
+
".pdb"
)
self
.
writePsf
(
outputPrefix
+
".psf"
)
self
.
writeArbdFiles
(
outputPrefix
,
numSteps
=
numSteps
,
outputPeriod
=
outputPeriod
)
os
.
sync
()
if
outputDirectory
==
''
:
outputDirectory
=
'.'
## http://stackoverflow.com/questions/18421757/live-output-from-subprocess-command
cmd
=
(
arbd
,
'-g'
,
"%d"
%
gpu
,
"%s.bd"
%
outputPrefix
,
"%s/%s"
%
(
outputDirectory
,
outputPrefix
))
cmd
=
tuple
(
str
(
x
)
for
x
in
cmd
)
if
arbd
is
None
:
for
path
in
os
.
environ
[
"PATH"
].
split
(
os
.
pathsep
):
path
=
path
.
strip
(
'"'
)
fname
=
os
.
path
.
join
(
path
,
"arbd"
)
if
os
.
path
.
isfile
(
fname
)
and
os
.
access
(
fname
,
os
.
X_OK
):
arbd
=
fname
break
if
arbd
is
None
:
raise
Exception
(
"ARBD was not found"
)
if
not
os
.
path
.
exists
(
arbd
):
raise
Exception
(
"ARBD was not found"
)
if
not
os
.
path
.
isfile
(
arbd
):
raise
Exception
(
"ARBD was not found"
)
if
not
os
.
access
(
arbd
,
os
.
X_OK
):
raise
Exception
(
"ARBD is not executable"
)
if
not
os
.
path
.
exists
(
outputDirectory
):
os
.
makedirs
(
outputDirectory
)
elif
not
os
.
path
.
isdir
(
outputDirectory
):
raise
Exception
(
"outputDirectory '%s' is not a directory!"
%
outputDirectory
)
self
.
writePdb
(
outputPrefix
+
".pdb"
)
self
.
writePsf
(
outputPrefix
+
".psf"
)
self
.
writeArbdFiles
(
outputPrefix
,
numSteps
=
numSteps
,
outputPeriod
=
outputPeriod
)
os
.
sync
()
## http://stackoverflow.com/questions/18421757/live-output-from-subprocess-command
cmd
=
(
arbd
,
'-g'
,
"%d"
%
gpu
,
"%s.bd"
%
outputPrefix
,
"%s/%s"
%
(
outputDirectory
,
outputPrefix
))
cmd
=
tuple
(
str
(
x
)
for
x
in
cmd
)
print
(
"Running ARBD with: %s"
%
" "
.
join
(
cmd
))
process
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
universal_newlines
=
True
)
for
line
in
process
.
stdout
:
sys
.
stdout
.
write
(
line
)
sys
.
stdout
.
flush
()
except
:
raise
finally
:
os
.
chdir
(
d_orig
)
print
(
"Running ARBD with: %s"
%
" "
.
join
(
cmd
))
process
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
universal_newlines
=
True
)
for
line
in
process
.
stdout
:
sys
.
stdout
.
write
(
line
)
sys
.
stdout
.
flush
()
# -------------------------- #
# Methods for printing model #
...
...
Write
Preview
Supports
Markdown
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