-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'installation' of github.com:haddocking/haddock3 into in…
…stallation
- Loading branch information
Showing
20 changed files
with
612 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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,37 @@ | ||
# HADDOCK3 DISCLAIMER | ||
|
||
The HADDOCK3 software is provided "as is" and without warranties. | ||
The authors of the software will not be held liable for any use of the HADDOCK3 package and derivatives/results. | ||
|
||
Some of HADDOCK3 modules use the CNS software (<http://cns-online.org/v1.3/>) (Crystallography and NMR System) | ||
as computational engine. | ||
|
||
While CNS is free of use for non-profit users, a proper license is required for commercial applications. | ||
Biovia is handling those licenses (<https://www.3ds.com/how-to-buy/contact-sales>). | ||
While they officially do not distribute CNS (CNX) anymore, they usually allow the use of the non-profit version | ||
provided a proper license is purchased for some of their modelling software. | ||
|
||
The HADDOCK3 modules using CNS are: | ||
|
||
- topology modules: | ||
- topoaa | ||
- topocg | ||
|
||
- sampling modules: | ||
- rigidbody | ||
|
||
- refinement modules: | ||
- flexref | ||
- emref | ||
- mdref | ||
|
||
- scoring modules: | ||
- emscoring | ||
- mdscoring | ||
|
||
- analysis modules: | ||
- alascan | ||
|
||
Commercial use of any of the above-mentioned modules in a HADDOCK3 workflow will thus require a proper CNS license. | ||
It is your responsibility as a user to make sure you have such a license. | ||
|
This file contains 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
This file contains 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,125 @@ | ||
"""Integration tests related to haddock.gear.known_cns_errors.py.""" | ||
|
||
import gzip | ||
import pytest | ||
import tempfile | ||
import random | ||
|
||
from os import linesep | ||
from pathlib import Path | ||
from string import ascii_letters | ||
|
||
from haddock.gear.known_cns_errors import KNOWN_ERRORS | ||
from haddock.libs.libontology import PDBFile | ||
from haddock.modules.sampling.rigidbody import ( | ||
DEFAULT_CONFIG as DEFAULT_RIGIDBODY_CONFIG, | ||
HaddockModule as RigidbodyModule | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def gen_random_text(): | ||
"""Generate some random text.""" | ||
textline = "".join([random.choice(ascii_letters) for _ in range(80)]) | ||
text = "" | ||
for _ in range(500): | ||
text += f"{textline}{linesep}" | ||
yield text | ||
|
||
|
||
@pytest.fixture | ||
def gen_fake_cns_errors(gen_random_text): | ||
"""Generate directory full of CNS.cnserr file with errors.""" | ||
with tempfile.TemporaryDirectory("moduleoutputs") as tmp: | ||
for i, error in enumerate(KNOWN_ERRORS.keys()): | ||
# Generate an error string in the middle of the file | ||
error_text = gen_random_text + error + gen_random_text | ||
# Create two files with same error | ||
for j in range(1, 3): | ||
errored_filepath = Path(tmp, f"with_error_cns_{i}_{j}.cnserr") | ||
# Write error in a file | ||
errored_filepath.write_text(error_text) | ||
# Create two compressed files with same error | ||
for j in range(1, 3): | ||
errored_gz_file = Path(tmp, f"with_error_cns_{i}_{j}.cnserr.gz") | ||
# Write error in a file | ||
with gzip.open(errored_gz_file, mode="wb") as gout: | ||
gout.write(bytes(error_text, encoding="utf-8")) | ||
yield tmp | ||
|
||
|
||
@pytest.fixture | ||
def rigidbody_module_with_cns_errors(gen_fake_cns_errors): | ||
"""Generate a failed rigidbody module with CNS errors.""" | ||
rigidbody = RigidbodyModule( | ||
order=1, | ||
path=Path(gen_fake_cns_errors), | ||
initial_params=DEFAULT_RIGIDBODY_CONFIG, | ||
) | ||
# Generate 9 filepath that were not created | ||
rigidbody.output_models = [ | ||
PDBFile(Path(gen_fake_cns_errors, f"not_generated_output_{i}.pdb")) | ||
for i in range(1, 10) | ||
] | ||
yield rigidbody | ||
|
||
|
||
@pytest.fixture | ||
def rigidbody_module_without_cns_errors(): | ||
"""Generate a failed rigidbody module without CNS errors.""" | ||
with tempfile.TemporaryDirectory("moduleoutputs") as tmp: | ||
rigidbody = RigidbodyModule( | ||
order=1, | ||
path=Path(tmp), | ||
initial_params=DEFAULT_RIGIDBODY_CONFIG, | ||
) | ||
# Generate 9 filepath that were not created | ||
rigidbody.output_models = [ | ||
PDBFile(Path(tmp, f"not_generated_output_{i}.pdb")) | ||
for i in range(1, 10) | ||
] | ||
yield rigidbody | ||
|
||
|
||
class MockPreviousIO: | ||
"""Mock proviousIO function.""" | ||
|
||
def __init__(self, path): | ||
self.path = path | ||
self.output = [] | ||
|
||
|
||
def test_detection_when_faulty(rigidbody_module_with_cns_errors): | ||
"""Test failure of run and detection of CNS errors.""" | ||
rigidbody_module_with_cns_errors.previous_io = MockPreviousIO( | ||
rigidbody_module_with_cns_errors.path | ||
) | ||
# Check that the run will fail | ||
with pytest.raises(RuntimeError) as error_info: | ||
rigidbody_module_with_cns_errors.export_io_models() | ||
# Get final error string | ||
string_error = str(error_info.value) | ||
# Loop over known errors | ||
for cns_error_string, user_hint in KNOWN_ERRORS.items(): | ||
# Check it was detected | ||
assert cns_error_string in string_error | ||
# Check user hint is present in error message | ||
assert user_hint in string_error | ||
|
||
|
||
def test_undetected_when_faulty(rigidbody_module_without_cns_errors): | ||
"""Test failure of run and undetection of CNS errors.""" | ||
rigidbody_module_without_cns_errors.previous_io = MockPreviousIO( | ||
rigidbody_module_without_cns_errors.path | ||
) | ||
# Check that the run will fail | ||
with pytest.raises(RuntimeError) as error_info: | ||
rigidbody_module_without_cns_errors.export_io_models() | ||
# Get final error string | ||
string_error = str(error_info.value) | ||
# Loop over known errors | ||
for cns_error_string, user_hint in KNOWN_ERRORS.items(): | ||
# Check it was NOT detected | ||
assert cns_error_string not in string_error | ||
# Check user hint NOT is present in error message | ||
assert user_hint not in string_error |
This file contains 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.