Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for disulfides #15

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion devtools/conda-envs/docs_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dependencies:
# Base depends
- python>=3.11
- pip
- pyxdg

# Documentation
- myst-parser
Expand All @@ -25,6 +24,7 @@ dependencies:
- typer>=0.14
- mdanalysis
- rdkit
- pyxdg

# Pip-only installs
- pip:
Expand Down
25 changes: 12 additions & 13 deletions devtools/conda-envs/test_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@ name: pablo-test
channels:
- conda-forge
dependencies:
# Base depends
# Base depends (runtime and imports)
- pip
- python>=3.11
- openff-toolkit-base>=0.14.7
- rdkit
- openmm
- pyxdg

# Lints
- basedpyright
- ruff

# Testing
- pytest
- pytest-xdist
- pytest-socket
# - pytest-cov
# - codecov

# Examples
- jupyterlab>=4
- ipywidgets>=8
Expand All @@ -22,24 +32,13 @@ dependencies:
- black
- isort
- snakeviz

# Testing
- pytest
# - pytest-cov
- pytest-xdist
- pytest-socket
# - codecov

# chemistry
- openff-toolkit-base>=0.14.7
- rdkit
- nglview>=3.0.6,<3.1.0
- pdbfixer
- mdanalysis
- openff-interchange
- ambertools
- numpy

- pip:
# - codecov
- git+https://github.com/openforcefield/openff-toolkit.git@better_typing
- git+https://github.com/openforcefield/openff-units.git@better_typing
4 changes: 4 additions & 0 deletions docs/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Pablo has a (developing) PDB test suite.
- ACE/NME caps, `unique_molecules`
* - 193L_prepared.pdb
- disulfides, all 20 canonical amino acids, charged terminii, charged canonical AA side chains
* - 2hi7_prepared.pdb
- disulfide bond between two different protein chains
* - 2zuq_prepared.pdb
- disulfide bond between two different protein chains, with additional chains between and after the crosslinked chains
:::

<script>
Expand Down
13 changes: 8 additions & 5 deletions openff/pablo/_pdb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import itertools
import warnings
from collections.abc import Iterable, Mapping, MutableSequence
from io import TextIOBase
from os import PathLike
Expand Down Expand Up @@ -344,6 +345,8 @@ def topology_from_pdb(
n = len(topology_pdb_indices)
positions = np.stack([data.x[:n], data.y[:n], data.z[:n]], axis=-1) * unit.angstrom
topology.set_positions(positions[topology_pdb_indices])
if topology_pdb_indices != list(range(n)):
warnings.warn("Atoms in topology are not in same order as those in PDB file")

if set_stereochemistry_from_3d:
for molecule in topology.molecules:
Expand All @@ -362,7 +365,7 @@ def topology_from_pdb(

def _check_all_conects(topology: Topology, data: PdbData):
all_bonds: set[tuple[int, int]] = {
sort_tuple((topology.atom_index(bond.atom1), topology.atom_index(bond.atom2)))
sort_tuple((bond.atom1.metadata["pdb_index"], bond.atom2.metadata["pdb_index"])) # type:ignore
for bond in topology.bonds
}

Expand Down Expand Up @@ -501,12 +504,12 @@ def _add_to_molecule(
return this_molecule

for other_molecule in molecules:
other_mol_pdb_idx_to_mol_atom_idx = other_molecule.properties[
"pdb_idx_to_mol_atom_idx"
]
other_mol_pdb_idx_to_mol_atom_idx: dict[int, int] = (
other_molecule.properties["pdb_idx_to_mol_atom_idx"]
)
assert isinstance(
dict,
other_mol_pdb_idx_to_mol_atom_idx,
dict,
), "This property should have already been set by Pablo"

if other_idx in other_mol_pdb_idx_to_mol_atom_idx:
Expand Down
22 changes: 13 additions & 9 deletions openff/pablo/_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
from pathlib import Path

import pytest
from pkg_resources import resource_filename

from openff.pablo._pdb_data import PdbData, ResidueMatch
from openff.pablo._tests.utils import get_test_data_path
from openff.pablo.chem import DISULFIDE_BOND, PEPTIDE_BOND
from openff.pablo.residue import AtomDefinition, BondDefinition, ResidueDefinition


@pytest.fixture(
params=[
"data/5ap1_prepared.pdb",
"data/193l_prepared.pdb",
"data/3cu9_vicinal_disulfide.pdb",
"data/e2_7nel.pdb",
"5ap1_prepared.pdb",
"prepared_pdbs/193l_prepared.pdb",
"prepared_pdbs/2zuq_prepared.pdb",
"prepared_pdbs/2hi7_prepared.pdb",
"3cu9_vicinal_disulfide.pdb",
"e2_7nel.pdb",
],
)
def pdbfn(request: pytest.FixtureRequest) -> Path:
return Path(resource_filename(__name__, request.param))
return get_test_data_path(request.param)


@pytest.fixture
def hewl_data() -> PdbData:
return PdbData.from_file(resource_filename(__name__, "data/193l_prepared.pdb"))
return PdbData.from_file(
get_test_data_path("prepared_pdbs/193l_prepared.pdb"),
)


@pytest.fixture
def vicinal_disulfide_data() -> PdbData:
return PdbData.from_file(
resource_filename(__name__, "data/3cu9_vicinal_disulfide.pdb"),
get_test_data_path("3cu9_vicinal_disulfide.pdb"),
)


Expand Down Expand Up @@ -61,7 +65,7 @@ def cys_data(cys_pdblines: list[str]) -> PdbData:

@pytest.fixture
def e2_data() -> PdbData:
return PdbData.from_file(resource_filename(__name__, "data/e2_7nel.pdb"))
return PdbData.from_file(get_test_data_path("e2_7nel.pdb"))


@pytest.fixture
Expand Down
Loading