Skip to content

Commit

Permalink
tests: add docstrings to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aalexmmaldonado committed May 20, 2024
1 parent aa7f08d commit 6e8c83d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 4 deletions.
22 changes: 22 additions & 0 deletions tests/test_fop.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@


def test_fop_gen():
"""
Test the generation of a field of points (FOP) centered around a specified point.
This function tests the `gen_fop` function's ability to generate a field of points with a
given resolution and radius, centered at a specified point. The number of generated points,
the coordinates of a specific point, and the center of the field are verified against expected
values.
Steps:
1. Generate a field of points (FOP) using `gen_fop` with specified parameters:
- center: [0.0, 0.0, 0.0]
- resolution: 0.5
- radius: 10.0
- round_decimals: 3
2. Verify the number of generated points.
3. Verify the coordinates of a specific point in the field.
4. Verify the center of the generated field.
Raises:
AssertionError: If the number of generated points, the coordinates of the specific point,
or the center of the field do not match the expected values.
"""
fop, fop_center = gen_fop(
center=[0.0, 0.0, 0.0],
resolution=0.5,
Expand Down
48 changes: 44 additions & 4 deletions tests/test_pocket_detect.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,62 @@
from typing import MutableMapping

import MDAnalysis as mda

from subpex.configs import SubpexConfig
from subpex.pocket.detect import get_fop_pocket_convenience, get_pocket_selection


def test_pocket_selection_m7g(path_m7g_paths, m7g_config):
def test_pocket_selection_m7g(
path_m7g_paths: MutableMapping[str, str], m7g_config: SubpexConfig
) -> None:
"""
Test the selection of atoms for the binding pocket in a molecular dynamics simulation.
This function tests the framework's ability to correctly select atoms that define the
binding pocket based on a specified center, radius, and distance constraint. The selection
is compared against a known selection string from the configuration.
Args:
path_m7g_paths (dict): Dictionary containing paths to the input files required for the test:
- "ref_pdb": Path to the reference PDB file.
m7g_config (object): Configuration object for the simulation which includes the parameters
for defining the pocket (center, radius, and selection distance).
Raises:
AssertionError: If the computed pocket selection string does not match the expected value.
"""
# Load structure
u = mda.Universe(path_m7g_paths["ref_pdb"])

pocket_selection = get_pocket_selection(
u,
center=m7g_config.pocket.center,
center=m7g_config.pocket.center, # type: ignore
radius=m7g_config.pocket.radius,
distance_constraint=m7g_config.pocket.selection_dist,
distance_constraint=m7g_config.pocket.selection_dist, # type: ignore
)
assert pocket_selection == m7g_config.pocket.selection_str


def test_pocket_fop_gen_m7g(path_m7g_paths, m7g_config):
def test_pocket_fop_gen_m7g(
path_m7g_paths: MutableMapping[str, str], m7g_config: SubpexConfig
) -> None:
"""
Test the generation of the Frame of Pocket (FOP) for the binding pocket in a molecular dynamics simulation.
This function tests the framework's ability to generate a Frame of Pocket (FOP) for the binding
pocket by detecting the pocket atoms based on the provided configuration. The number of atoms
and specific coordinates of a known atom are verified against expected values.
Args:
path_m7g_paths (dict): Dictionary containing paths to the input files required for the test:
- "ref_pdb": Path to the reference PDB file.
m7g_config (object): Configuration object for the simulation which includes settings for
detecting the pocket.
Raises:
AssertionError: If the number of detected pocket atoms or the coordinates of a specific
atom do not match the expected values.
"""
u = mda.Universe(path_m7g_paths["ref_pdb"])
fop_frame = get_fop_pocket_convenience(u.atoms, m7g_config)

Expand Down

0 comments on commit 6e8c83d

Please sign in to comment.