Skip to content

Commit

Permalink
Set up basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoshanuikabundi committed Jan 9, 2025
1 parent c921ffc commit 66a4110
Show file tree
Hide file tree
Showing 12 changed files with 53,628 additions and 98 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/gh-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.11", "3.13"]
include:
- os: macos-latest
python-version: "3.11"
os: [ubuntu-latest, macos-latest]
python-version: ["3.11"]

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ repos:
hooks:
- id: basedpyright
files: "openff"
exclude: "_tests"
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.8.6
Expand Down
9 changes: 3 additions & 6 deletions openff/pablo/_pdb.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import itertools
from collections.abc import Mapping
from collections.abc import Iterable, Mapping
from os import PathLike
from pathlib import Path
from collections.abc import Iterable
from typing import assert_never

import numpy as np
from openff.toolkit import Molecule, Topology
from openff.units import elements, unit
from typing import assert_never

from ._pdb_data import PdbData, ResidueMatch
from ._utils import (
Expand Down Expand Up @@ -205,8 +203,7 @@ def topology_from_pdb(
"""
# TODO: support streams and gzipped files
path = Path(path)
data = PdbData.parse_pdb(path.read_text().splitlines())
data = PdbData.from_file(path)

molecules: list[Molecule] = []
this_molecule = Molecule()
Expand Down
8 changes: 7 additions & 1 deletion openff/pablo/_pdb_data.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import dataclasses
from collections.abc import Iterable, Iterator, Mapping, Sequence
from dataclasses import dataclass, field
from functools import cached_property
from os import PathLike
from pathlib import Path
from typing import Any, Self
from collections.abc import Iterable, Iterator, Mapping, Sequence

from ._utils import __UNSET__, dec_hex, with_neighbours
from .residue import AtomDefinition, ResidueDefinition
Expand Down Expand Up @@ -140,6 +142,10 @@ class PdbData:
cryst1_beta: float | None = None
cryst1_gamma: float | None = None

@classmethod
def from_file(cls, path: str | PathLike[str]) -> Self:
return cls.parse_pdb(Path(path).read_text().splitlines())

def _append_coord_line(self, line: str):
for field_ in dataclasses.fields(self):
value = getattr(self, field_.name)
Expand Down
21 changes: 0 additions & 21 deletions openff/pablo/_tests/conftest.py

This file was deleted.

53,601 changes: 53,601 additions & 0 deletions openff/pablo/_tests/data/5ap1_prepared.pdb

Large diffs are not rendered by default.

27 changes: 0 additions & 27 deletions openff/pablo/_tests/data/C1CC1.sdf

This file was deleted.

17 changes: 0 additions & 17 deletions openff/pablo/_tests/data/README.md

This file was deleted.

Empty file.
20 changes: 0 additions & 20 deletions openff/pablo/_tests/data/files.py

This file was deleted.

9 changes: 9 additions & 0 deletions openff/pablo/_tests/test_pdb_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest
from pkg_resources import resource_filename

from openff.pablo._pdb_data import PdbData


@pytest.mark.parametrize("pdbfile", ["data/5ap1_prepared.pdb"])
def test_can_load_pdb_file_as_data(pdbfile: str):
PdbData.from_file(resource_filename(__name__, pdbfile))
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ include = ["openff.*"]

[tool.pyright]
include = ["openff"]
exclude = [".soap", "openff/pablo/_version.py", "docs", "examples"]
exclude = [
".soap",
"docs",
"examples",
]
typeCheckingMode = "strict"

reportUnsupportedDunderAll = "error"
Expand Down

0 comments on commit 66a4110

Please sign in to comment.