Skip to content

Commit

Permalink
Merge pull request prody#1811 from jamesmkrieger/parseMMCIF_altloc
Browse files Browse the repository at this point in the history
fix default altloc mask size for parseMMCIF
  • Loading branch information
jamesmkrieger authored Jan 10, 2024
2 parents 9c3b8cf + e1c41e3 commit d3bdff2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 4 additions & 3 deletions prody/proteins/ciffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def parseMMCIFStream(stream, **kwargs):
unite_chains = kwargs.get('unite_chains', False)
altloc = kwargs.get('altloc', 'A')
header = kwargs.get('header', False)
report = kwargs.get('report', False)
assert isinstance(header, bool), 'header must be a boolean'

if model is not None:
Expand Down Expand Up @@ -235,7 +236,7 @@ def parseMMCIFStream(stream, **kwargs):
hd = getCIFHeaderDict(lines)

_parseMMCIFLines(ag, lines, model, chain, subset, altloc,
segment, unite_chains)
segment, unite_chains, report)

if ag.numAtoms() > 0:
LOGGER.report('{0} atoms and {1} coordinate set(s) were '
Expand Down Expand Up @@ -281,7 +282,7 @@ def parseMMCIFStream(stream, **kwargs):

def _parseMMCIFLines(atomgroup, lines, model, chain, subset,
altloc_torf, segment, unite_chains,
report=False):
report):
"""Returns an AtomGroup. See also :func:`.parsePDBStream()`.
:arg lines: mmCIF lines
Expand Down Expand Up @@ -487,7 +488,7 @@ def _parseMMCIFLines(atomgroup, lines, model, chain, subset,
else:
modelSize = acount

mask = np.full(modelSize, True, dtype=bool)
mask = np.full(acount, True, dtype=bool)
if which_altlocs != 'all':
#mask out any unwanted alternative locations
mask = (altlocs == ' ') | np.logical_or(*[(altlocs == altloc)
Expand Down
11 changes: 11 additions & 0 deletions prody/tests/proteins/test_ciffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,14 @@ def testAltlocNoneToLessAtoms(self):

assert_allclose(hisB234.getAnisous(), self.altlocs['anisousA'],
err_msg='parsePDB failed to have right His B234 CA atoms getAnisous A with altloc "all"')

def testAltlocAllMultiModels(self):
"""Test number of coordinate sets and atoms for multi-model case with altloc='all'."""

path = pathDatafile(self.multi['file'])

ag = parsePDB(path, altloc="all")
self.assertEqual(ag.numAtoms(), self.multi['atoms'],
'parsePDB failed to parse correct number of atoms for multi-model with altloc "all"')
self.assertEqual(ag.numCoordsets(), self.multi['models'],
'parsePDB failed to parse correct number of coordsets ({0}) with altloc "all"'.format(self.multi['models']))

0 comments on commit d3bdff2

Please sign in to comment.