From 6713df27e14af8b47508810d986c293ae19ad048 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 12 Oct 2023 22:44:13 +0200 Subject: [PATCH] unobs header tests --- prody/tests/datafiles/__init__.py | 2 ++ prody/tests/proteins/test_ciffile.py | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/prody/tests/datafiles/__init__.py b/prody/tests/datafiles/__init__.py index 8f5a0ed6a..070a76f09 100644 --- a/prody/tests/datafiles/__init__.py +++ b/prody/tests/datafiles/__init__.py @@ -229,6 +229,7 @@ 'file': 'mmcif_3o21.cif', 'atoms': 12793, 'bm0_atoms': 6281, + 'num_chains_united': 4, 'bm_chains_united': [2, 2], 'bm_chains_alone': [9, 10], 'chainA_atoms_united': 3170, @@ -236,6 +237,7 @@ 'ca_atoms': 1489, 'bb_atoms': 5956, 'models': 1, + 'unobs_B_start': 'G-------------------------------NQNTTEK-' }, 'long_chid_cif': { 'pdb': '6zu5', diff --git a/prody/tests/proteins/test_ciffile.py b/prody/tests/proteins/test_ciffile.py index f24580e2b..b302f3c7e 100644 --- a/prody/tests/proteins/test_ciffile.py +++ b/prody/tests/proteins/test_ciffile.py @@ -1,5 +1,6 @@ """This module contains unit tests for :mod:`~prody.proteins`.""" +from collections import OrderedDict import os import numpy as np @@ -203,6 +204,29 @@ def testAgArgMultiModel(self): ag = parseMMCIF(path, ag=ag) self.assertEqual(ag.numCoordsets(), ncsets*2, 'parseMMCIF failed to append coordinate sets to given ag') - assert_equal(coords, ag.getCoordsets(np.arange(ncsets, ncsets*2))) + self.assertEqual(coords, ag.getCoordsets(np.arange(ncsets, ncsets*2)), + 'parseMMCIF failed to have the right coordinates') + def testUnobsHeaderArgument(self): + """Test outcome of valid and invalid *subset* arguments.""" + path = pathDatafile(self.biomols['file']) + header = parseCIFHeader(path) + self.assertIsInstance(header, dict, + 'parseCIFHeader failed to return an dict instance') + self.assertTrue('unobserved' in header, + 'parseCIFHeader failed to return a header containing ' + 'unobserved') + + unobs_header = parseCIFHeader(path, 'unobserved') + self.assertIsInstance(unobs_header, OrderedDict, + 'parseCIFHeader failed to return an OrderedDict instance when ' + 'providing a key') + self.assertEqual(len(unobs_header), + self.biomols['num_chains_united'], + 'failed to parse unobserved for correct number of chains') + self.assertEqual(unobs_header['B'][0][:39], + self.biomols['unobs_B_start'], + 'failed to parse unobserved alignment correctly') + + unobs_header_B = unobs_header[1]