-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyses.py
More file actions
79 lines (66 loc) · 2.27 KB
/
Copy pathanalyses.py
File metadata and controls
79 lines (66 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from __future__ import annotations
import argparse
import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent
SRC_DIR = REPO_ROOT / "src"
if str(SRC_DIR) not in sys.path:
sys.path.insert(0, str(SRC_DIR))
INSTALL_HINT = (
"Install project dependencies first:\n"
" pip install .\n"
"or\n"
" pip install -r requirements.txt"
)
SUPPORT_HINT = (
"If you hit an error or have questions about this analysis workflow, "
"please contact Hoshin Kim ([email protected])."
)
def build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
description="Run the interactive ABFE/RBFE or trajectory analysis launcher.",
)
parser.add_argument(
"--trajectory",
action="store_true",
help="Open the trajectory analysis wizard directly.",
)
return parser
def main(argv: list[str] | None = None) -> int:
parser = build_parser()
args = parser.parse_args(argv)
try:
from amber_metallo.analysis_cli import run_analysis_wizard
from amber_metallo.ti.abfe import print_analysis_summary
from amber_metallo.trajectory_analysis import TrajectoryAnalysisRunResult
from amber_metallo.trajectory_analysis_cli import (
print_trajectory_analysis_summary,
run_trajectory_analysis_wizard,
)
except ModuleNotFoundError as exc:
missing = exc.name or "a required package"
parser.exit(
1,
f"Missing dependency: {missing}\n{INSTALL_HINT}\n",
)
try:
from amber_metallo.subdirectory_search import (
prompt_for_subdirectory_search,
subdirectory_search_scope,
)
search_subdirectories = prompt_for_subdirectory_search(Path.cwd())
with subdirectory_search_scope(search_subdirectories):
if args.trajectory:
result = run_trajectory_analysis_wizard()
else:
result = run_analysis_wizard()
except Exception:
print(SUPPORT_HINT, file=sys.stderr)
raise
if isinstance(result, TrajectoryAnalysisRunResult):
print_trajectory_analysis_summary(result)
else:
print_analysis_summary(result)
return 0
if __name__ == "__main__":
raise SystemExit(main())