Skip to content

Commit

Permalink
fix: use correct distances.dat when starting from existing traj (#485)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbuhr authored Sep 13, 2024
1 parent b73104a commit d0c9859
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
29 changes: 23 additions & 6 deletions src/kimmdy/runmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ class State(Enum):
DONE = auto()


def get_existing_files(config: Config) -> dict:
def get_existing_files(config: Config, section: str = "config") -> dict:
"""Initialize latest_files with every existing file defined in config"""
file_d = {}
files = {}
attr_names = config.get_attributes()
for attr_name in attr_names:
attr = getattr(config, attr_name)
Expand All @@ -108,12 +108,28 @@ def get_existing_files(config: Config) -> dict:

if attr_name == "plumed":
key = "plumed"
file_d["plumed_out"] = attr.parent / get_plumed_out(attr)

file_d[key] = attr
files[key] = attr
elif isinstance(attr, Config):
file_d.update(get_existing_files(attr))
return file_d
files.update(get_existing_files(attr, section=attr_name))

# for starting reactions from existing trajectories,
# we need to read the name of the plumed output file
# from the plumed input file and interpret it
# relative to the parent directory of the trajectory
# or coordinate files (xtc, trr, tpr, gro).
if section == "config" and hasattr(config, "plumed"):
for f in ["xtc", "tpr", "trr", "gro"]:
if hasattr(config, f):
plumed_out = get_plumed_out(files["plumed"])
trajectory_dir = files[f].parent
files["plumed_out"] = trajectory_dir / plumed_out
logger.debug(
f"Setting up plumed_out from {f} file. Plumed out: {plumed_out} in {trajectory_dir}"
)
break

return files


class RunManager:
Expand Down Expand Up @@ -430,6 +446,7 @@ def _setup(self, files: TaskFiles) -> TaskFiles:
for f in ["xtc", "tpr", "trr", "plumed"]:
if hasattr(self.config, f):
if path := self.latest_files.get(f):
logger.debug(f"Copying {path} to {files.outputdir}")
shutil.copy(path, files.outputdir / path.name)
files.output[f] = files.outputdir / path.name

Expand Down
2 changes: 1 addition & 1 deletion src/kimmdy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def truncate_sim_files(
"Last traj contains single frame, will not truncate anything."
)
return
if last_time * 1.01 >= time:
if last_time * 1.01 <= time:
m = f"Requested to truncate trajectory at time {time} but last frame according to gmx check is at {last_time:.4} ps. This might led to unexpected results."
logger.warning(m)
else:
Expand Down

0 comments on commit d0c9859

Please sign in to comment.