Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os
from pathlib import Path

import pytest
import torch

TEST_DIR = Path(__file__).parent
ENV_PDB_DIR = os.environ.get("ENV_PDB_DIR")
PDB_BASE_DIR = Path(ENV_PDB_DIR) if ENV_PDB_DIR else TEST_DIR / "test_files"


@pytest.fixture
def device():
return torch.device("cuda" if torch.cuda.is_available() else "cpu")

@pytest.fixture(scope="session")
def pdb_base_dir():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be a fixture? It will certainly work, but it will call os.environ.get every time you want to get what is essentially a constant.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. a new commit will make a constant first, and just wrap it in a fixture to not affect the existing test functions.

"""Wrapper of constant PDB_BASE_DIR.
"""
return PDB_BASE_DIR


def _resolve_pdb_path(pdb_id):
"""Resolves a PDB path, skipping if missing."""
path = PDB_BASE_DIR / pdb_id / f"{pdb_id}_final.pdb"
if not path.exists():
pytest.skip(f"PDB file not found: {path}")
return str(path)


@pytest.fixture
def pdb_6eey():
"""6eey - standard PDB that passes all quality checks."""
return _resolve_pdb_path("6eey")


@pytest.fixture
def pdb_2b5w():
"""2b5w - fails COM distance check."""
return _resolve_pdb_path("2b5w")


@pytest.fixture
def pdb_8dzt():
"""8dzt - fails water clash check at 2% threshold with 2A distance."""
return _resolve_pdb_path("8dzt")


@pytest.fixture
def pdb_1deu():
"""1deu - has insertion codes (52 residues with ins_code='P')."""
return _resolve_pdb_path("1deu")
35 changes: 0 additions & 35 deletions tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
All test cases created with assistance from Claude Code.
"""

from pathlib import Path

import numpy as np
import pytest
import torch
Expand All @@ -44,39 +42,6 @@
)


@pytest.fixture
def pdb_base_dir():
"""Base directory for PDB files."""
return Path("/sb/wankowicz_lab/data/srivasv/pdb_redo_data")


@pytest.fixture
def pdb_6eey(pdb_base_dir):
"""Path to 6eey PDB file - should pass all quality checks."""
path = pdb_base_dir / "6eey" / "6eey_final.pdb"
if not path.exists():
pytest.skip(f"PDB file not found: {path}")
return str(path)


@pytest.fixture
def pdb_2b5w(pdb_base_dir):
"""Path to 2b5w PDB file - should fail COM distance check."""
path = pdb_base_dir / "2b5w" / "2b5w_final.pdb"
if not path.exists():
pytest.skip(f"PDB file not found: {path}")
return str(path)


@pytest.fixture
def pdb_8dzt(pdb_base_dir):
"""Path to 8dzt PDB file - should fail water clash check at 2% threshold."""
path = pdb_base_dir / "8dzt" / "8dzt_final.pdb"
if not path.exists():
pytest.skip(f"PDB file not found: {path}")
return str(path)


@pytest.fixture
def tmp_processed_dir(tmp_path):
"""Temporary directory for processed files."""
Expand Down
5 changes: 0 additions & 5 deletions tests/test_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@

# ============== Fixtures ==============

@pytest.fixture
def device():
return torch.device("cuda" if torch.cuda.is_available() else "cpu")


@pytest.fixture
def sample_homogeneous_data():
"""Sample Data for testing ProteinGVPEncoder directly."""
Expand Down
File renamed without changes.
5 changes: 0 additions & 5 deletions tests/test_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
from src.gvp_encoder import GVPEncoder, ProteinGVPEncoder, make_encoder_data


@pytest.fixture
def device():
return torch.device("cuda" if torch.cuda.is_available() else "cpu")


@pytest.fixture
def simple_hetero_data(device):
"""Minimal HeteroData with protein and water nodes."""
Expand Down
5 changes: 0 additions & 5 deletions tests/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ def __exit__(self, exc_type, exc, tb):
return False # don't suppress exceptions


@pytest.fixture
def device():
return torch.device("cuda" if torch.cuda.is_available() else "cpu")


def make_batched_hetero(
device,
n_graphs=2,
Expand Down