-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathtest_topoaa.py
More file actions
90 lines (71 loc) · 3.18 KB
/
test_topoaa.py
File metadata and controls
90 lines (71 loc) · 3.18 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
80
81
82
83
84
85
86
87
88
89
90
import tempfile
import pytest
from pathlib import Path
from shutil import copyfile
from haddock.core.defaults import DATA_DIRNAME
from haddock.libs.libio import working_directory
from haddock.modules.topology.topoaa import (
DEFAULT_CONFIG as DEFAULT_TOPOAA_CONFIG,
HaddockModule as TopoaaModule,
)
from . import CNS_EXEC, DATA_DIR, has_cns
@pytest.fixture
def molecules():
return [
Path(DATA_DIR, "docking-protein-protein/data/e2aP_1F3G.pdb"),
Path(DATA_DIR, "docking-protein-protein/data/hpr_ensemble.pdb"),
]
@pytest.fixture
def prepare_topoaa_run(molecules):
with tempfile.TemporaryDirectory() as tmpdir:
with working_directory(tmpdir):
modulename_path = Path("0_topoaa")
modulename_path.mkdir(parents=True)
input_dir_path = Path(DATA_DIRNAME, modulename_path)
input_dir_path.mkdir(parents=True)
mol_copies = [
copyfile(mol, Path(input_dir_path, mol.name))
for mol in molecules
]
yield modulename_path, mol_copies
@pytest.fixture
def topoaa_module(prepare_topoaa_run):
modulename_path = prepare_topoaa_run[0]
mol_copies = prepare_topoaa_run[1]
topoaa = TopoaaModule(
order=0,
path=modulename_path,
initial_params=DEFAULT_TOPOAA_CONFIG,
)
#topoaa.__init__(path=modulename_path, order=0)
topoaa.params["molecules"] = mol_copies
topoaa.params["mol1"] = {"prot_segid": "A"}
topoaa.params["mol2"] = {"prot_segid": "B"}
topoaa.params["cns_exec"] = CNS_EXEC
yield topoaa
@has_cns
def test_topoaa_default(topoaa_module):
"""Test the topoaa module."""
topoaa_module.run()
expected_inp = Path(topoaa_module.path, "e2aP_1F3G.inp")
expected_psf = Path(topoaa_module.path, "e2aP_1F3G_haddock.psf")
expected_pdb = Path(topoaa_module.path, "e2aP_1F3G_haddock.pdb")
expected_gz = Path(topoaa_module.path, "e2aP_1F3G.out.gz")
assert expected_inp.exists(), f"{expected_inp} does not exist"
assert expected_psf.exists(), f"{expected_psf} does not exist"
assert expected_gz.exists(), f"{expected_gz} does not exist"
assert expected_pdb.exists(), f"{expected_pdb} does not exist"
assert expected_inp.stat().st_size > 0, f"{expected_inp} is empty"
for i in range(1, 10 + 1):
expected_inp = Path(topoaa_module.path, f"hpr_ensemble_{i}.inp")
expected_psf = Path(topoaa_module.path, f"hpr_ensemble_{i}_haddock.psf")
expected_pdb = Path(topoaa_module.path, f"hpr_ensemble_{i}_haddock.pdb")
expected_gz = Path(topoaa_module.path, f"hpr_ensemble_{i}.out.gz")
assert expected_inp.exists(), f"{expected_inp} does not exist"
assert expected_psf.exists(), f"{expected_psf} does not exist"
assert expected_pdb.exists(), f"{expected_pdb} does not exist"
assert expected_gz.exists(), f"{expected_gz} does not exist"
assert expected_inp.stat().st_size > 0, f"{expected_inp} is empty"
assert expected_psf.stat().st_size > 0, f"{expected_psf} is empty"
assert expected_pdb.stat().st_size > 0, f"{expected_pdb} is empty"
assert expected_gz.stat().st_size > 0, f"{expected_gz} is empty"