-
Notifications
You must be signed in to change notification settings - Fork 58
refactor clustfcc and it's tests to use the proper path
#1016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b24ecd4
re-organize clustfcc tests
rvhonorato 20b261c
Use module paths instead of relative one
rvhonorato 146eb8e
Merge branch 'main' into fcc-test
rvhonorato 0190bab
revert explicit path definition
rvhonorato cda7d57
address review
rvhonorato c58ba6d
tweak test_clustfcc.py
rvhonorato 5cf8d7f
Merge branch 'main' into fcc-test
rvhonorato File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2,192 changes: 2,192 additions & 0 deletions
2,192
integration_tests/golden_data/protprot_complex_1.pdb
Large diffs are not rendered by default.
Oops, something went wrong.
2,192 changes: 2,192 additions & 0 deletions
2,192
integration_tests/golden_data/protprot_complex_2.pdb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| import os | ||
| import shutil | ||
| import tempfile | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| from haddock.libs.libontology import ModuleIO, PDBFile | ||
| from haddock.modules.analysis.clustfcc import DEFAULT_CONFIG as clustfcc_pars | ||
| from haddock.modules.analysis.clustfcc import HaddockModule as ClustFCCModule | ||
|
|
||
| from . import golden_data | ||
|
|
||
|
|
||
| class MockPreviousIO: | ||
| def __init__(self, path): | ||
| self.path = path | ||
|
|
||
| def retrieve_models(self, individualize: bool = False): | ||
| shutil.copy( | ||
| Path(golden_data, "protprot_complex_1.pdb"), | ||
| Path(self.path, "protprot_complex_1.pdb"), | ||
| ) | ||
|
|
||
| shutil.copy( | ||
| Path(golden_data, "protprot_complex_2.pdb"), | ||
| Path(self.path, "protprot_complex_2.pdb"), | ||
| ) | ||
|
|
||
| # add the topology to the models | ||
| model_list = [ | ||
| PDBFile( | ||
| file_name="protprot_complex_1.pdb", | ||
| path=self.path, | ||
| ), | ||
| PDBFile( | ||
| file_name="protprot_complex_2.pdb", | ||
| path=self.path, | ||
| ), | ||
| ] | ||
| return model_list | ||
|
|
||
| def output(self) -> None: | ||
| return None | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def output_list(): | ||
| """Clustfcc output list.""" | ||
| return [ | ||
| "fcc.matrix", | ||
| "cluster.out", | ||
| "protprot_complex_1.con", | ||
| "protprot_complex_2.con", | ||
| "clustfcc.txt", | ||
| "io.json", | ||
| "clustfcc.tsv", | ||
| ] | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def fcc_module(): | ||
| """Clustfcc module.""" | ||
| with tempfile.TemporaryDirectory() as tempdir: | ||
| yield ClustFCCModule(order=1, path=Path(tempdir), initial_params=clustfcc_pars) | ||
|
|
||
|
|
||
| def test_clustfcc_output_existence(fcc_module, output_list): | ||
| """Test clustfcc output.""" | ||
| fcc_module.previous_io = MockPreviousIO(path=fcc_module.path) | ||
|
|
||
| fcc_module.run() | ||
|
|
||
| for _f in output_list: | ||
| expected_file = Path(fcc_module.path, _f) | ||
| assert expected_file.exists() | ||
|
|
||
| # Test the fcc matrix contents | ||
| with open(Path(fcc_module.path, "fcc.matrix"), encoding="utf-8", mode="r") as f: | ||
| observed_fcc_matrix = f.read() | ||
| expected_fcc_output = "1 2 0.05 0.062" + os.linesep | ||
|
|
||
| assert observed_fcc_matrix == expected_fcc_output | ||
|
rvhonorato marked this conversation as resolved.
|
||
|
|
||
| # Check .con files. | ||
| expected_output_length = [100, 119] | ||
|
|
||
| observed_contact_files = [ | ||
| Path(fcc_module.path, "protprot_complex_1.con"), | ||
| Path(fcc_module.path, "protprot_complex_2.con"), | ||
| ] | ||
|
|
||
| for exp_output_len, observed_con_file in zip( | ||
| expected_output_length, observed_contact_files | ||
| ): | ||
| with open(observed_con_file, encoding="utf-8", mode="r") as f: | ||
| observed_output_len = len(f.read().splitlines()) | ||
|
|
||
| assert observed_output_len == exp_output_len | ||
|
rvhonorato marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Check cluster.out file. | ||
| expected_cluster_output = [ | ||
| "Cluster 1 -> 2 " + os.linesep, | ||
| "Cluster 2 -> 1 " + os.linesep, | ||
| ] | ||
| with open(Path(fcc_module.path, "cluster.out"), encoding="utf-8", mode="r") as f: | ||
| for expected, line in zip(expected_cluster_output, f.readlines()): | ||
| assert line == expected | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.