From cc4aaded6f705cd3e22de48c0ca9865b05f955da Mon Sep 17 00:00:00 2001 From: Ben Webb Date: Fri, 6 Dec 2024 17:11:09 -0800 Subject: [PATCH] Check new releases against archive structures 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. --- make-release.sh | 4 +++- util/check-db-entries.py | 50 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 util/check-db-entries.py diff --git a/make-release.sh b/make-release.sh index 5dd40c1..2f0f678 100755 --- a/make-release.sh +++ b/make-release.sh @@ -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 diff --git a/util/check-db-entries.py b/util/check-db-entries.py new file mode 100644 index 0000000..6515afc --- /dev/null +++ b/util/check-db-entries.py @@ -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()