Skip to content

Commit

Permalink
Fix top file suffix after changing from template
Browse files Browse the repository at this point in the history
  • Loading branch information
a-ws-m committed Aug 30, 2023
1 parent e26d8e5 commit 5140b74
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion mdpow/equil.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import os, errno
import shutil
from pathlib import Path
from string import Template
from typing import Optional

Expand Down Expand Up @@ -371,7 +372,18 @@ def topology(self, itp="drug.itp", prm=None, **kwargs):
template = forcefields.get_top_template(self.solvent_type)

top_template = config.get_template(kwargs.pop("top_template", template))
topol = kwargs.pop("topol", os.path.basename(top_template))

default_top_path = Path(top_template)
if ".top" in default_top_path.suffixes:
# Include all suffixes up to that one
default_top_name = default_top_path.name
default_top_name = (
default_top_name[: default_top_name.index(".top")] + ".top"
)
else:
default_top_name = default_top_path.with_suffix(".top").name

Check warning on line 384 in mdpow/equil.py

View check run for this annotation

Codecov / codecov/patch

mdpow/equil.py#L384

Added line #L384 was not covered by tests

topol = kwargs.pop("topol", default_top_name)
self.top_template = top_template
itp = os.path.realpath(itp)
_itp = os.path.basename(itp)
Expand Down

0 comments on commit 5140b74

Please sign in to comment.