Skip to content

Commit

Permalink
AMBRose now cleans up leap.log files properly
Browse files Browse the repository at this point in the history
  • Loading branch information
mszegedy committed Jun 18, 2019
1 parent dec323b commit 87e370d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion AmbRose/ambrose/pose_to_traj.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ def pose_to_amber_params(pose, crd_path, top_path, log_path='leap.log', *,
nonzero. True by default.
'''

# .exists() is appropriate here rather than .isfile(), because we don't want
# to remove it even if it's a directory. I don't know what LEaP does with it
# if it already exists as a directory, however...
leap_log_exists_in_current_dir = os.path.exists('leap.log')
if leap_script_dump_path is not None:
leap_in_fd, leap_in_path = leap_script_dump_path, leap_script_dump_path
else:
Expand Down Expand Up @@ -293,7 +297,15 @@ def pose_to_amber_params(pose, crd_path, top_path, log_path='leap.log', *,

finally:
if leap_script_dump_path is None:
os.remove(leap_in_path)
try:
os.remove(leap_in_path)
except FileNotFoundError:
pass
if not leap_log_exists_in_current_dir:
try:
os.remove('leap.log')
except FileNotFoundError:
pass
## the "load" commands for different solvents, used to construct the LEaP
## instructions
pose_to_amber_params.SOLVENTS = \
Expand Down

0 comments on commit 87e370d

Please sign in to comment.