Skip to content

Commit

Permalink
tests: setup start of westpa init test
Browse files Browse the repository at this point in the history
  • Loading branch information
aalexmmaldonado committed May 21, 2024
1 parent 6ba9891 commit 4b49e8b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
26 changes: 21 additions & 5 deletions subpex/setup/westpa/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
from ...configs import SubpexConfig, WestpaConfig


def link_initial_sims(
subpex_config: SubpexConfig,
westpa_config: WestpaConfig,
write_dir: str = "",
overwrite: bool = False,
) -> None:
"""WESTPA starts from a relaxed molecular simulation using the same MD engine.
Instead of copying the preliminary simulation files, we create a soft link to
the relevant files.
"""


def run_westpa_setup(
subpex_config: SubpexConfig,
westpa_config: WestpaConfig,
Expand All @@ -27,12 +39,16 @@ def run_westpa_setup(
logger.error("Aborting")
sys.exit(1)

logger.info(f"Creating directory at {write_dir}")
os.makedirs(write_dir, exist_ok=True)
logger.info(f"Creating directory at {write_dir} if absent")
os.makedirs(write_dir, exist_ok=overwrite)

logger.info("Creating all necessary directories")
logger.info("Creating all necessary WESTPA directories")
logger.debug(" - Creating common_files")
os.makedirs(os.path.join(write_dir, "common_files"), exist_ok=overwrite)
logger.debug(" - Creating westpa_scripts")
os.makedirs(os.path.join(write_dir, "westpa_scripts"), exist_ok=overwrite)
logger.debug(" - Creating bstates")
os.makedirs(os.path.join(write_dir, "bstates"))
os.makedirs(os.path.join(write_dir, "bstates"), exist_ok=overwrite)


def cli_run_westpa_setup():
Expand Down Expand Up @@ -61,7 +77,7 @@ def cli_run_westpa_setup():
parser.add_argument(
"--overwrite",
action="store_true",
help="Remove and overwrite directory",
help="Overwrite files in write_dir",
)
args = parser.parse_args()

Expand Down
15 changes: 15 additions & 0 deletions tests/test_westpa_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os

from subpex.configs import WestpaConfig
from subpex.setup.westpa.main import run_westpa_setup


def test_westpa_init_m7g(path_m7g_paths, m7g_config, tmp_dir):
westpa_config = WestpaConfig()
write_dir = os.path.join(tmp_dir, "westpa_init_m7g")
run_westpa_setup(
subpex_config=m7g_config,
westpa_config=westpa_config,
write_dir=write_dir,
overwrite=True,
)

0 comments on commit 4b49e8b

Please sign in to comment.