Skip to content

Commit

Permalink
write out the correct gro file after truncation!
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbuhr committed Nov 15, 2024
1 parent abe31f7 commit edaff31
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/kimmdy/runmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ def _run_md(
files.input["mdp"] = md_config.mdp
mdp = files.input["mdp"]
ndx = files.input["ndx"]
logger.info(f"Using the following input files: top: {top}, gro: {gro}")

# to continue MD after timeout
if continue_md:
Expand Down
27 changes: 15 additions & 12 deletions src/kimmdy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,24 +457,14 @@ def truncate_sim_files(
f"Truncating trajectories to {time:.4} ps. Trajectory time was {last_time:.4} ps"
)

# backup the tails of trajectories
for trj in trjs:
tmp = trj.rename(trj.with_name("tmp_backup_" + trj.name))
if keep_tail:
run_gmx(
f"gmx trjconv -f {tmp} -b {time} -o {trj}",
)
trj.rename(str(trj) + ".tail")

run_gmx(f"gmx trjconv -f {tmp} -e {time} -o {trj}")
tmp.unlink()

# backup the gro
bck_gro = paths["gro"].rename(
paths["gro"].with_name("tmp_backup_" + paths["gro"].name)
)
# write out gro at the specified time
sp.run(
f"gmx trjconv -f {trjs[0]} -s {bck_gro} -dump -1 -o {paths['gro']}",
f"gmx trjconv -f {trjs[0]} -s {bck_gro} -dump {time} -o {paths['gro']}",
text=True,
input="0",
shell=True,
Expand All @@ -483,6 +473,19 @@ def truncate_sim_files(
if not keep_tail:
bck_gro.unlink()

# backup the tails of trajectories
for trj in trjs:
tmp = trj.rename(trj.with_name("tmp_backup_" + trj.name))
if keep_tail:
run_gmx(
f"gmx trjconv -f {tmp} -b {time} -o {trj}",
)
trj.rename(str(trj) + ".tail")

run_gmx(f"gmx trjconv -f {tmp} -e {time} -o {trj}")
tmp.unlink()


# backup the edr
if paths["edr"] is not None:
bck_edr = paths["edr"].rename(
Expand Down

0 comments on commit edaff31

Please sign in to comment.