Commit f5e11b30 by Jason Swails Committed by GitHub

Revamp PDBFixer testing (#225)

* Revamp PDBFixer testing

* Use GitHub Actions to run a suite of tests
* Switch from nose to pytest (nose has not been supported in years)
* Download a PDB file and track it instead of fetching it during CI
  (RCSB has blocked testing frameworks in the past).

* Add missing environment.yaml file

* Try the workflow on my branch

* Try to fix the pipeline

* Stop building on jms-updates
parent 951102cd
name: PDBFixer Continuous Integration Workflow
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build_test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
name: "Checkout the source code"
- uses: conda-incubator/setup-miniconda@v2
name: "Prepare base dependencies"
with:
python-version: ${{ matrix.python-version }}
activate-environment: pdbfixer-dev
environment-file: devtools/environment-dev.yaml
- name: "Install PDBFixer"
shell: bash -l {0}
run: |
which python
python -V
pip install -e .
pytest -vs pdbfixer
name: pdbfixer-dev
channels:
- conda-forge
dependencies:
- pytest
- openmm
- numpy
- pip
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
from __future__ import print_function from __future__ import print_function
import pdbfixer import pdbfixer
import simtk.openmm import openmm
import os import os
import os.path import os.path
...@@ -29,9 +29,9 @@ class Watchdog(BaseException): ...@@ -29,9 +29,9 @@ class Watchdog(BaseException):
raise self raise self
def simulate(pdbcode, pdb_filename): def simulate(pdbcode, pdb_filename):
from simtk.openmm import app from openmm import app
import simtk.openmm as mm import openmm.openmm as mm
from simtk import unit from openmm import unit
from sys import stdout from sys import stdout
# Load the PDB file. # Load the PDB file.
......
...@@ -13,10 +13,11 @@ Test command-line interface. ...@@ -13,10 +13,11 @@ Test command-line interface.
# GLOBAL IMPORTS # GLOBAL IMPORTS
#============================================================================================= #=============================================================================================
import os
import subprocess import subprocess
from subprocess import CalledProcessError from subprocess import CalledProcessError
from nose.plugins.skip import Skip, SkipTest import pytest
#============================================================================================= #=============================================================================================
# UNIT TESTS # UNIT TESTS
...@@ -50,5 +51,6 @@ def test_help(): ...@@ -50,5 +51,6 @@ def test_help():
def test_pdbid(): def test_pdbid():
run_cli('--pdbid 1LE1') run_cli('--pdbid 1LE1')
@pytest.mark.skipif(os.getenv("GITHUB_ACTION") is not None, reason="Cannot download during CI")
def test_url(): def test_url():
run_cli('--url "http://www.rcsb.org/pdb/download/downloadFile.do?fileFormat=pdb&compression=NO&structureId=1LE1"') run_cli('--url "http://www.rcsb.org/pdb/download/downloadFile.do?fileFormat=pdb&compression=NO&structureId=1LE1"')
from nose.tools import ok_, eq_, raises import openmm.app as app
import simtk.openmm.app as app
import pdbfixer import pdbfixer
import tempfile import tempfile
from pytest import raises
def test_mutate_1(): def test_mutate_1():
fixer = pdbfixer.PDBFixer(pdbid='1VII') fixer = pdbfixer.PDBFixer(pdbid='1VII')
...@@ -48,21 +48,21 @@ def test_mutate_2(): ...@@ -48,21 +48,21 @@ def test_mutate_2():
desired_atom_names = set(["C", "N", "CA", "CB", "CG", "CD1", "CD2", "O", "H", "HA", "HB2", "HB3", "HD11", "HD12", "HD13", "HD21", "HD22", "HD23", "HG"]) desired_atom_names = set(["C", "N", "CA", "CB", "CG", "CD1", "CD2", "O", "H", "HA", "HB2", "HB3", "HD11", "HD12", "HD13", "HD21", "HD22", "HD23", "HG"])
assert atom_names == desired_atom_names, "Atom Names did not match for LEU 57" assert atom_names == desired_atom_names, "Atom Names did not match for LEU 57"
@raises(ValueError)
def test_mutate_3_fails(): def test_mutate_3_fails():
fixer = pdbfixer.PDBFixer(pdbid='1VII') with raises(ValueError):
fixer.applyMutations(["ALA-57-GLY", "SER-57-ALA"], "A") fixer = pdbfixer.PDBFixer(pdbid='1VII')
fixer.applyMutations(["ALA-57-GLY", "SER-57-ALA"], "A")
@raises(KeyError)
def test_mutate_4_fails(): def test_mutate_4_fails():
fixer = pdbfixer.PDBFixer(pdbid='1VII') with raises(KeyError):
fixer.applyMutations(["ALA-57-WTF", "SER-56-ALA"], "A") fixer = pdbfixer.PDBFixer(pdbid='1VII')
fixer.applyMutations(["ALA-57-WTF", "SER-56-ALA"], "A")
@raises(KeyError)
def test_mutate_5_fails(): def test_mutate_5_fails():
fixer = pdbfixer.PDBFixer(pdbid='1VII') with raises(KeyError):
fixer.applyMutations(["ALA-1000-GLY", "SER-56-ALA"], "A") fixer = pdbfixer.PDBFixer(pdbid='1VII')
fixer.applyMutations(["ALA-1000-GLY", "SER-56-ALA"], "A")
def test_mutate_multiple_copies_of_chain_A(): def test_mutate_multiple_copies_of_chain_A():
fixer = pdbfixer.PDBFixer(pdbid='1OL5') fixer = pdbfixer.PDBFixer(pdbid='1OL5')
......
from nose.tools import ok_, eq_, raises, assert_list_equal import openmm.app as app
import simtk.openmm.app as app
import pdbfixer import pdbfixer
import tempfile import tempfile
import time import time
from pathlib import Path
try: from urllib.request import urlopen
from urllib.request import urlopen from io import StringIO
from io import StringIO
except:
from urllib2 import urlopen
from cStringIO import StringIO
# Download the file once to avoid repeated requests to the PDB. import pytest
file_content = urlopen('http://www.rcsb.org/pdb/files/4JSV.pdb').read().decode('utf-8') @pytest.fixture(scope="module")
def file_content():
return (Path(__file__).parent / "data" / "4JSV.pdb").read_text()
def remove_chain_ids_and_verify(chain_ids_to_remove, expected_chain_ids_remaining): def remove_chains_and_verify(file_content, expected_chain_ids_remaining, **kws):
# Create a PDBFixer instance for the given pdbid # Create a PDBFixer instance for the given pdbid
fixer = pdbfixer.PDBFixer(pdbfile=StringIO(file_content)) fixer = pdbfixer.PDBFixer(pdbfile=StringIO(file_content))
# Remove specified chains. # Remove specified chains.
fixer.removeChains(chainIds=chain_ids_to_remove) fixer.removeChains(**kws)
# Check to make sure asserted chains remain. # Check to make sure asserted chains remain.
chain_ids_remaining = [c.id for c in fixer.topology.chains()] chain_ids_remaining = [c.id for c in fixer.topology.chains()]
assert_list_equal(chain_ids_remaining, expected_chain_ids_remaining) assert expected_chain_ids_remaining == chain_ids_remaining
def test_removechain_ids(): def test_removechain_ids(file_content):
remove_chain_ids_and_verify([], ['B', 'D', 'A', 'C', 'B', 'A']) remove_chains_and_verify(file_content, ['B', 'D', 'A', 'C', 'B', 'A'], chainIds=[])
remove_chain_ids_and_verify(['B', 'D'], ['A', 'C', 'A']) remove_chains_and_verify(file_content, ['A', 'C', 'A'], chainIds=['B', 'D'])
remove_chain_ids_and_verify(['A', 'C'], ['B', 'D', 'B']) remove_chains_and_verify(file_content, ['B', 'D', 'B'], chainIds=['A', 'C'])
remove_chain_ids_and_verify(['B', 'A'], ['D', 'C']) remove_chains_and_verify(file_content, ['D', 'C'], chainIds=['B', 'A'])
remove_chain_ids_and_verify(['B', 'D', 'A', 'C'], []) remove_chains_and_verify(file_content, [], chainIds=['B', 'D', 'A', 'C'])
def remove_chain_indices_and_verify(chain_indices_to_remove, expected_chain_ids_remaining): def test_removechain_indices(file_content):
# Create a PDBFixer instance for the given pdbid remove_chains_and_verify(file_content, ['B', 'D', 'A', 'C', 'B', 'A'], chainIndices=[])
fixer = pdbfixer.PDBFixer(pdbfile=StringIO(file_content)) remove_chains_and_verify(file_content, ['A', 'C', 'B', 'A'], chainIndices=[0, 1])
# Remove specified chains. remove_chains_and_verify(file_content, ['B', 'D', 'B', 'A'], chainIndices=[2, 3])
fixer.removeChains(chainIndices=chain_indices_to_remove) remove_chains_and_verify(file_content, ['D', 'C', 'B', 'A'], chainIndices=[0, 2])
# Check to make sure asserted chains remain. remove_chains_and_verify(file_content, [], chainIndices=[0, 1, 2, 3, 4, 5])
chain_ids_remaining = [c.id for c in fixer.topology.chains()]
assert_list_equal(chain_ids_remaining, expected_chain_ids_remaining)
def test_removechain_indices():
remove_chain_indices_and_verify([], ['B', 'D', 'A', 'C', 'B', 'A'])
remove_chain_indices_and_verify([0, 1], ['A', 'C', 'B', 'A'])
remove_chain_indices_and_verify([2, 3], ['B', 'D', 'B', 'A'])
remove_chain_indices_and_verify([0, 2], ['D', 'C', 'B', 'A'])
remove_chain_indices_and_verify([0, 1, 2, 3, 4, 5], [])
...@@ -68,7 +68,7 @@ setup( ...@@ -68,7 +68,7 @@ setup(
long_description="\n".join(DOCLINES[2:]), long_description="\n".join(DOCLINES[2:]),
version=__version__, version=__version__,
license='MIT', license='MIT',
url='https://github.com/SimTk/pdbfixer', url='https://github.com/openmm/pdbfixer',
platforms=['Linux', 'Mac OS-X', 'Unix', 'Windows'], platforms=['Linux', 'Mac OS-X', 'Unix', 'Windows'],
classifiers=CLASSIFIERS.splitlines(), classifiers=CLASSIFIERS.splitlines(),
packages=find_packages(), packages=find_packages(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment