Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
mgiulini committed Dec 10, 2024
1 parent 01ad5f4 commit 3a68823
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/test_libpdb.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
"""Test lib PDB."""
from pathlib import Path
import pytest


from haddock.libs import libpdb
from haddock.libs.libio import PDBFile

from . import golden_data

chainC = [
'ATOM 3 CA ARG C 4 37.080 43.455 -3.421 1.00 0.00 C C ', # noqa: E501
Expand Down Expand Up @@ -31,3 +35,28 @@ def test_read_chain_ids(lines, expected):
def test_read_seg_ids(lines, expected):
result = libpdb.read_segids(lines)
assert result == expected


@pytest.fixture(name="wrong_rigid_molecules")
def fixture_wrong_rigidbody_molecules():
"""fixture for wrong rigidbody input molecules."""
receptor = PDBFile(Path(golden_data, "protprot_complex_1.pdb"))
ligand = PDBFile(Path(golden_data, "protprot_complex_2.pdb"))
return [receptor, ligand]

@pytest.fixture(name="good_rigid_molecules")
def fixture_good_rigidbody_molecules():
"""fixture for good rigidbody input molecules."""
receptor = PDBFile(Path(golden_data, "e2aP_1F3G_haddock.pdb"))
ligand = PDBFile(Path(golden_data, "hpr_ensemble_1_haddock.pdb"))
return [receptor, ligand]

def test_check_combination_chains(good_rigid_molecules, wrong_rigid_molecules):
"""Test check_combination_chains."""
exp_chains = ["A", "B"]
obs_chains = libpdb.check_combination_chains(good_rigid_molecules)
assert obs_chains == exp_chains
# when input molecules share chains there should be a ValueError
with pytest.raises(ValueError):
libpdb.check_combination_chains(wrong_rigid_molecules)

0 comments on commit 3a68823

Please sign in to comment.