Skip to content

Commit

Permalink
fixed mdpath testing
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinTaterra authored Jul 30, 2024
1 parent d507916 commit 9861b63
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions mdpath/tests/test_mdpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -1176,34 +1176,50 @@ def test_bootstrap_analysis():


def test_mdpath_output_files():

script_dir = os.path.dirname(os.path.abspath(__file__))
project_root = os.path.dirname(script_dir)
mdpath_dir = os.path.join(project_root, 'mdpath')

topology = os.path.join(script_dir, "test_topology.pdb")
trajectory = os.path.join(script_dir, "test_trajectory.dcd")
numpath = "50"
numpath = "25"

assert os.path.exists(topology), f"Topology file {topology} does not exist."
assert os.path.exists(trajectory), f"Trajectory file {trajectory} does not exist."

expected_files = [
"first_frame.pdb",
"mi_diff_df.csv",
"output.txt",
"path_confidence_intervals.txt",
"residue_coordinates.pkl",
"cluster_pathways_dict.pkl",
"clusters_paths.json",
"precomputed_clusters_paths.json",
"quick_precomputed_clusters_paths.json",
os.path.join(script_dir, "first_frame.pdb"),
os.path.join(script_dir, "mi_diff_df.csv"),
os.path.join(script_dir, "output.txt"),
os.path.join(script_dir, "residue_coordinates.pkl"),
os.path.join(script_dir, "cluster_pathways_dict.pkl"),
os.path.join(script_dir, "clusters_paths.json"),
os.path.join(script_dir, "precomputed_clusters_paths.json"),
os.path.join(script_dir, "quick_precomputed_clusters_paths.json")
]

result = subprocess.run(
["mdpath", "-top", topology, "-traj", trajectory, "-numpath", numpath],
capture_output=True,
text=True,
)
sys.path.insert(0, mdpath_dir)

try:
import mdpath
except ImportError as e:
raise ImportError(f"Error importing mdpath: {e}")

original_cwd = os.getcwd()
os.chdir(script_dir)

sys.argv = [
"mdpath",
"-top", topology,
"-traj", trajectory,
"-numpath", numpath
]

mdpath.mdpath.main()

for file in expected_files:
assert os.path.exists(file), f"Expected output file {file} not found."

for file in expected_files:
os.remove(file)
if os.path.exists(file):
os.remove(file)

0 comments on commit 9861b63

Please sign in to comment.