diff --git a/prody/tests/datafiles/__init__.py b/prody/tests/datafiles/__init__.py index c49bb210e..8f5a0ed6a 100644 --- a/prody/tests/datafiles/__init__.py +++ b/prody/tests/datafiles/__init__.py @@ -228,6 +228,9 @@ 'pdb': '3o21', 'file': 'mmcif_3o21.cif', 'atoms': 12793, + 'bm0_atoms': 6281, + 'bm_chains_united': [2, 2], + 'bm_chains_alone': [9, 10], 'chainA_atoms_united': 3170, 'chainA_atoms_alone': 3025, 'ca_atoms': 1489, diff --git a/prody/tests/proteins/test_ciffile.py b/prody/tests/proteins/test_ciffile.py index 9d53c5513..f24580e2b 100644 --- a/prody/tests/proteins/test_ciffile.py +++ b/prody/tests/proteins/test_ciffile.py @@ -114,6 +114,59 @@ def testLongChainArgument(self): self.no_pdb['segment_SX0_atoms'], 'parseMMCIF failed to parse correct number of atoms ' 'when segment SX0 is specified') + + def testUniteChainsArgument(self): + """Test outcome of valid and invalid *segment* arguments.""" + + path = pathDatafile(self.biomols['file']) + self.assertEqual(parseMMCIF(path, chain='A').numAtoms(), + self.biomols['chainA_atoms_united'], + 'parseMMCIF failed to parse correct number of atoms ' + 'when chain A is specified with unite_chain default (True)') + self.assertEqual(parseMMCIF(path, chain='A', unite_chains=False).numAtoms(), + self.biomols['chainA_atoms_alone'], + 'parseMMCIF failed to parse correct number of atoms ' + 'when chain A is specified with unite_chain False') + self.assertEqual(parseMMCIF(path, chain='A', header=True)[0].numAtoms(), + self.biomols['chainA_atoms_united'], + 'parseMMCIF failed to parse correct number of atoms ' + 'when chain A is specified with unite_chain default (True) ' + 'with header True') + + def testUniteChainsAndBiomolArguments(self): + """Test outcome of valid and invalid *segment* arguments.""" + + path = pathDatafile(self.biomols['file']) + + bm_united = parseMMCIF(path, biomol=True) + self.assertEqual(bm_united[0].numAtoms(), + self.biomols['bm0_atoms'], + 'parseMMCIF failed to parse correct number of atoms ' + 'with biomol True and unite_chain default (True)') + self.assertEqual([b.numChains() for b in bm_united], + self.biomols['bm_chains_united'], + 'parseMMCIF failed to parse correct numbers of chains ' + 'with biomol True and unite_chain default (True)') + + bm_non_united = parseMMCIF(path, biomol=True, unite_chains=False) + self.assertEqual(bm_non_united[0].numAtoms(), + self.biomols['bm0_atoms'], + 'parseMMCIF failed to parse correct number of atoms ' + 'when chain A is specified with unite_chain False') + self.assertEqual([b.numChains() for b in bm_non_united], + self.biomols['bm_chains_alone'], + 'parseMMCIF failed to parse correct numbers of chains ' + 'with biomol True and unite_chain False') + + bm_header = parseMMCIF(path, biomol=True)[0] + self.assertEqual(bm_header[0].numAtoms(), + self.biomols['bm0_atoms'], + 'parseMMCIF failed to parse correct number of atoms ' + 'with biomol True and unite_chain default (True)') + self.assertEqual([b.numChains() for b in bm_header], + self.biomols['bm_chains_united'], + 'parseMMCIF failed to parse correct numbers of chains ' + 'with biomol True and unite_chain default (True)') def testSubsetArgument(self): """Test outcome of valid and invalid *subset* arguments."""