-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathtest_rmsdmatrix.py
More file actions
49 lines (39 loc) · 1.66 KB
/
test_rmsdmatrix.py
File metadata and controls
49 lines (39 loc) · 1.66 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
import os
import tempfile
from pathlib import Path
import shutil
import pytest
import pytest_mock
from haddock.libs.libontology import PDBFile
from haddock.modules.analysis.rmsdmatrix import DEFAULT_CONFIG as DEFAULT_RMSD_CONFIG
from haddock.modules.analysis.rmsdmatrix import HaddockModule as rmsdmatrixModule
from . import golden_data
@pytest.fixture
def rmsdmatrix_module():
with tempfile.TemporaryDirectory(".") as tmpdir:
ilrmsdmatrix = rmsdmatrixModule(
order=1, path=Path(tmpdir), initial_params=DEFAULT_RMSD_CONFIG
)
yield ilrmsdmatrix
class MockPreviousIO():
def __init__(self, path):
self.path = path
def retrieve_models(self, individualize: bool = False):
shutil.copy(Path(golden_data, "protglyc_complex_1.pdb"), Path(".", "protglyc_complex_1.pdb"))
shutil.copy(Path(golden_data, "protglyc_complex_2.pdb"), Path(".", "protglyc_complex_2.pdb"))
model_list = [
PDBFile(file_name="protglyc_complex_1.pdb", path="."),
PDBFile(file_name="protglyc_complex_2.pdb", path="."),
]
return model_list
def test_rmsdmatrix_default(rmsdmatrix_module, mocker):
"""Test the rmsdmatrix module."""
rmsdmatrix_module.previous_io = MockPreviousIO(path=rmsdmatrix_module.path)
mocker.patch("haddock.modules.BaseHaddockModule.export_io_models", return_value = None)
rmsdmatrix_module.run()
# expected paths
exp_rmsd_matrix = Path(rmsdmatrix_module.path, "rmsd.matrix")
assert exp_rmsd_matrix.exists(), "rmsd.matrix does not exist"
# open files and check content
with open(exp_rmsd_matrix) as f:
assert f.readline() == "1 2 3.326\n"