forked from haddocking/haddock3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_module_flexref.py
More file actions
67 lines (55 loc) · 2.35 KB
/
Copy pathtest_module_flexref.py
File metadata and controls
67 lines (55 loc) · 2.35 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
"""Test the flexref module."""
import tempfile
import shutil
from pathlib import Path
import pytest
from haddock.libs.libio import extract_files_flat
from haddock.modules.refinement.flexref import \
DEFAULT_CONFIG as DEFAULT_FLEXREF_PARAMS
from haddock.modules.refinement.flexref import HaddockModule as Flexref
from . import golden_data
@pytest.fixture(name="flexref")
def fixture_fixture_flexref(monkeypatch):
"""???"""
with tempfile.TemporaryDirectory() as tempdir:
monkeypatch.chdir(tempdir)
yield Flexref(
order=1,
path=Path("."),
initial_params=DEFAULT_FLEXREF_PARAMS,
)
def test_prev_fnames(flexref, protdna_input_list):
"""Tests the correct retrieval of ambiguous restraints information."""
protdna_input_list[0].restr_fname = Path(golden_data, "example_ambig_1.tbl")
protdna_input_list[1].restr_fname = Path(golden_data, "example_ambig_2.tbl")
prev_ambig_fnames = [model.restr_fname for model in protdna_input_list]
obs_ambig_fnames = flexref.get_ambig_fnames(prev_ambig_fnames)
assert obs_ambig_fnames is None
# now setting previous to true
flexref.params["previous_ambig"] = True
obs_ambig_fnames = flexref.get_ambig_fnames(prev_ambig_fnames)
assert obs_ambig_fnames == prev_ambig_fnames
# removing restraints information from a model while previous is true
# should cause an exception
protdna_input_list[0].restr_fname = None
prev_ambig_fnames = [model.restr_fname for model in protdna_input_list]
# FIXME: this should be a more specific exception
with pytest.raises(Exception): # noqa: B017
obs_ambig_fnames = flexref.get_ambig_fnames(prev_ambig_fnames)
def test_multiple_ambigs(flexref):
"""Test usage of multiple ambigs."""
# Copy ambig.tbl.tgz
reference_archive = Path(golden_data, "ambig.tbl.tgz")
shutil.copy(reference_archive, flexref.path)
archive = Path(flexref.path, reference_archive.name)
# First extract the file
extract_files_flat(archive, flexref.path)
# Set the parameter
flexref.params["ambig_fname"] = archive
ambig_fnames = flexref.get_ambig_fnames([])
assert len(ambig_fnames) == 1
# Remove file from path
Path('ambig_1.tbl').unlink()
with pytest.raises(Exception) as _e:
ambig_fnames = flexref.get_ambig_fnames([])
assert ambig_fnames is None