summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/check-db-entries.py43
-rw-r--r--util/python-modelcif.spec78
-rwxr-xr-xutil/validate-outputs.py28
3 files changed, 149 insertions, 0 deletions
diff --git a/util/check-db-entries.py b/util/check-db-entries.py
new file mode 100644
index 0000000..7b53e19
--- /dev/null
+++ b/util/check-db-entries.py
@@ -0,0 +1,43 @@
+import unittest
+import modelcif.reader
+import modelcif.dumper
+import urllib.request
+import os
+
+
+class Tests(unittest.TestCase):
+ def _read_cif(self, url):
+ with urllib.request.urlopen(url) as fh:
+ s, = modelcif.reader.read(fh)
+ return s
+
+ def _write_cif(self, s, check=True):
+ with open('test.cif', 'w') as fh:
+ modelcif.dumper.write(fh, [s], check=check)
+ os.unlink('test.cif')
+
+ def test_modbase(self):
+ """Test ModBase structure without errors"""
+ model_id = '3c79945a94ec00cac8a03104e853ca50'
+ modbase_top = 'https://salilab.org/modbase/retrieve/modbase'
+ url = '%s/?modelID=%s&format=mmcif' % (modbase_top, model_id)
+ s = self._read_cif(url)
+ self._write_cif(s)
+
+ def test_swiss_model(self):
+ """Test SWISS-MODEL structure without errors"""
+ model_id = '680335e5cca47f7d2b00afc1'
+ url = 'https://swissmodel.expasy.org/repository/%s.cif' % model_id
+ s = self._read_cif(url)
+ self._write_cif(s)
+
+ def test_alpha_fold(self):
+ """Test AlphaFold structure without errors"""
+ model_id = 'AF-B4GKE9-F1-model_v4'
+ url = 'https://alphafold.ebi.ac.uk/files/%s.cif' % model_id
+ s = self._read_cif(url)
+ self._write_cif(s)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/util/python-modelcif.spec b/util/python-modelcif.spec
new file mode 100644
index 0000000..037d238
--- /dev/null
+++ b/util/python-modelcif.spec
@@ -0,0 +1,78 @@
+Name: python3-modelcif
+License: MIT
+Group: Applications/Engineering
+Version: 1.5
+Release: 1%{?dist}
+Summary: Package for handling ModelCIF mmCIF and BinaryCIF files
+Packager: Ben Webb <ben@salilab.org>
+URL: https://pypi.python.org/pypi/modelcif
+Source: modelcif-%{version}.tar.gz
+BuildRequires: python3-devel, python3-setuptools, python3-ihm >= 2.6
+Requires: python3-ihm >= 2.6
+BuildArch: noarch
+%if 0%{?fedora} >= 42
+BuildRequires: python3-pytest
+%endif
+
+%description
+This is a Python package to assist in handling mmCIF and BinaryCIF files
+compliant with the ModelCIF extension. It works with Python 3.6 or later.
+
+%prep
+%setup -n modelcif-%{version}
+
+%build
+%{__python3} setup.py install --root=${RPM_BUILD_ROOT} --record=INSTALLED_FILES
+
+%check
+%if 0%{?fedora} >= 42
+%pytest modelcif/test.py
+%else
+%{__python3} setup.py test
+%endif
+
+%files -f INSTALLED_FILES
+%defattr(-,root,root)
+
+%changelog
+* Wed Sep 17 2025 Ben Webb <ben@salilab.org> 1.5-1
+- Update to latest upstream.
+
+* Wed Jun 11 2025 Ben Webb <ben@salilab.org> 1.4-1
+- Update to latest upstream.
+
+* Tue Jan 14 2025 Ben Webb <ben@salilab.org> 1.3-1
+- Update to latest upstream.
+
+* Wed Oct 23 2024 Ben Webb <ben@salilab.org> 1.2-1
+- Update to latest upstream.
+
+* Fri Sep 27 2024 Ben Webb <ben@salilab.org> 1.1-1
+- Update to latest upstream.
+
+* Thu Jun 20 2024 Ben Webb <ben@salilab.org> 1.0-1
+- Update to latest upstream.
+
+* Mon Oct 02 2023 Ben Webb <ben@salilab.org> 0.9-1
+- Update to latest upstream.
+
+* Fri Aug 04 2023 Ben Webb <ben@salilab.org> 0.8-1
+- Update to latest upstream.
+
+* Mon Jul 31 2023 Ben Webb <ben@salilab.org> 0.7-1
+- Update to latest upstream.
+
+* Tue May 10 2022 Ben Webb <ben@salilab.org> 0.5-1
+- Update to latest upstream.
+
+* Thu Apr 14 2022 Ben Webb <ben@salilab.org> 0.4-1
+- Update to latest upstream.
+
+* Mon Mar 21 2022 Ben Webb <ben@salilab.org> 0.3-1
+- Update to latest upstream.
+
+* Thu Jan 27 2022 Ben Webb <ben@salilab.org> 0.2-1
+- Update to latest upstream.
+
+* Thu Jan 27 2022 Ben Webb <ben@salilab.org> 0.1-1
+- Initial package.
diff --git a/util/validate-outputs.py b/util/validate-outputs.py
new file mode 100755
index 0000000..14e1ad1
--- /dev/null
+++ b/util/validate-outputs.py
@@ -0,0 +1,28 @@
+#!/usr/bin/python3
+
+"""Check the output of each example for validity against the PDBx
+ and ModelCIF dictionaries.
+
+ This should be periodically rechecked in case the PDBx and ModelCIF
+ dictionaries are updated.
+"""
+
+import sys
+import os
+import subprocess
+import ihm.dictionary
+import urllib.request
+
+with urllib.request.urlopen(
+ 'https://mmcif.wwpdb.org/dictionaries/ascii/mmcif_ma.dic') as fh:
+ pdbx_mcif = ihm.dictionary.read(fh)
+
+for script in ('mkmodbase.py', 'ligands.py'):
+ print(script)
+ subprocess.check_call([sys.executable, '../examples/' + script])
+ with open('output.cif') as fh:
+ try:
+ pdbx_mcif.validate(fh)
+ except ihm.dictionary.ValidatorError as exc:
+ print(exc)
+os.unlink('output.cif')