Skip to content

Commit

Permalink
Check new releases against archive structures
Browse files Browse the repository at this point in the history
Using a representative subset of the PDB-IHM archive,
test reading in each structure and writing it out again.
Run this as part of the "new release" workflow. Closes #155.
  • Loading branch information
benmwebb committed Dec 7, 2024
1 parent 7e87f5d commit cc4aade
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
4 changes: 3 additions & 1 deletion make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
# codespell . --skip '*.cif' -L assertIn
# - Update AuditConformDumper to match latest IHM dictionary if necessary
# - Run util/validate-outputs.py to make sure all example outputs validate
# (cd util; PYTHONPATH=.. python3 ./validate-outputs.py)
# (cd util; PYTHONPATH=.. python3 validate-outputs.py)
# - Run util/check-db-entries.py to check against some real archive structures
# (cd util; PYTHONPATH=.. python3 check-db-entries.py)
# - Make sure all python-modelcif tests work using new IHM version
# - Update ChangeLog.rst, util/debian/changelog, and util/python-ihm.spec
# with the release number and date
Expand Down
50 changes: 50 additions & 0 deletions util/check-db-entries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import unittest
import ihm.reader
import ihm.dumper
import urllib.request
import os


class Tests(unittest.TestCase):
def _read_cif(self, pdb_id):
url = 'https://pdb-ihm.org/cif/%s.cif' % pdb_id
with urllib.request.urlopen(url) as fh:
s, = ihm.reader.read(fh)
return s

def _write_cif(self, s, check=True):
with open('test.cif', 'w') as fh:
ihm.dumper.write(fh, [s], check=check)
os.unlink('test.cif')

def test_9a0e(self):
"""Test IMP structure with incorrect reference sequence (9a0e)"""
s = self._read_cif('9a0e')
self.assertRaises(ValueError, self._write_cif, s)
self._write_cif(s, check=False)

def test_8zzd(self):
"""Test docking structure with incorrect assembly (8zzd)"""
s = self._read_cif('8zzd')
self.assertRaises(ValueError, self._write_cif, s)
self._write_cif(s, check=False)

def test_9a82(self):
"""Test HADDOCK structure without errors (9a82)"""
s = self._read_cif('9a82')
self._write_cif(s)

def test_9a13(self):
"""Test HADDOCK structure with incorrect null feature (9a13)"""
s = self._read_cif('9a13')
self.assertRaises(ValueError, self._write_cif, s)
self._write_cif(s, check=False)

def test_9a0t(self):
"""Test IMP structure without errors (9a0t)"""
s = self._read_cif('9a0t')
self._write_cif(s)


if __name__ == '__main__':
unittest.main()

0 comments on commit cc4aade

Please sign in to comment.