Skip to content

Commit

Permalink
Merge pull request prody#1792 from jamesmkrieger/6uwi
Browse files Browse the repository at this point in the history
adhoc fix for 6uwi for mmCIF
  • Loading branch information
jamesmkrieger authored Nov 15, 2023
2 parents c55c8a2 + d2cfdfd commit 30052ce
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
6 changes: 4 additions & 2 deletions prody/database/pfam.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,10 @@ def parsePfamPDBs(query, data=[], **kwargs):
continue

right_dbref = header[data_dict['chain']].dbrefs[right_part]
chainStart = ag.select('chain {0}'.format(data_dict['chain'])
).getResnums()[0]
chain = ag.select('chain {0}'.format(data_dict['chain']))
if chain is None:
continue
chainStart = chain.getResnums()[0]
missing = chainStart - right_dbref.first[0]
partStart = ag.getResindices()[np.where(ag.getResnums() ==
right_dbref.first[0] + missing)][0]
Expand Down
53 changes: 28 additions & 25 deletions prody/proteins/ciffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
from .cifheader import getCIFHeaderDict
from .header import buildBiomolecules, assignSecstr, isHelix, isSheet

from string import ascii_uppercase

__all__ = ['parseMMCIFStream', 'parseMMCIF', 'parseCIF']


Expand Down Expand Up @@ -311,7 +309,6 @@ def _parseMMCIFLines(atomgroup, lines, model, chain, subset,
doneAtomBlock = False
start = 0
stop = 0
warnedAltloc = False
while not doneAtomBlock:
line = lines[i]
if line[:11] == '_atom_site.':
Expand Down Expand Up @@ -443,8 +440,6 @@ def _parseMMCIFLines(atomgroup, lines, model, chain, subset,
continue

alt = line.split()[fields['label_alt_id']]
if alt not in which_altlocs and which_altlocs != 'all':
continue

if alt == '.':
alt = ' '
Expand Down Expand Up @@ -492,28 +487,36 @@ def _parseMMCIFLines(atomgroup, lines, model, chain, subset,
else:
modelSize = acount

mask = np.full(modelSize, True, dtype=bool)
if which_altlocs != 'all':
#mask out any unwanted alternative locations
mask = (altlocs == '') | (altlocs == which_altlocs)

if np.all(mask == False):
mask = (altlocs == '') | (altlocs == altlocs[0])

if addcoords:
atomgroup.addCoordset(coordinates[:modelSize])
atomgroup.addCoordset(coordinates[mask][:modelSize])
else:
atomgroup._setCoords(coordinates[:modelSize])

atomgroup.setNames(atomnames[:modelSize])
atomgroup.setResnames(resnames[:modelSize])
atomgroup.setResnums(resnums[:modelSize])
atomgroup.setSegnames(segnames[:modelSize])
atomgroup.setChids(chainids[:modelSize])
atomgroup.setFlags('hetatm', hetero[:modelSize])
atomgroup.setFlags('pdbter', termini[:modelSize])
atomgroup.setFlags('selpdbter', termini[:modelSize])
atomgroup.setAltlocs(altlocs[:modelSize])
atomgroup.setIcodes(icodes[:modelSize])
atomgroup.setSerials(serials[:modelSize])

atomgroup.setElements(elements[:modelSize])
atomgroup._setCoords(coordinates[mask][:modelSize])

atomgroup.setNames(atomnames[mask][:modelSize])
atomgroup.setResnames(resnames[mask][:modelSize])
atomgroup.setResnums(resnums[mask][:modelSize])
atomgroup.setSegnames(segnames[mask][:modelSize])
atomgroup.setChids(chainids[mask][:modelSize])
atomgroup.setFlags('hetatm', hetero[mask][:modelSize])
atomgroup.setFlags('pdbter', termini[mask][:modelSize])
atomgroup.setFlags('selpdbter', termini[mask][:modelSize])
atomgroup.setAltlocs(altlocs[mask][:modelSize])
atomgroup.setIcodes(icodes[mask][:modelSize])
atomgroup.setSerials(serials[mask][:modelSize])

atomgroup.setElements(elements[mask][:modelSize])
from prody.utilities.misctools import getMasses
atomgroup.setMasses(getMasses(elements[:modelSize]))
atomgroup.setBetas(bfactors[:modelSize])
atomgroup.setOccupancies(occupancies[:modelSize])
atomgroup.setMasses(getMasses(elements[mask][:modelSize]))
atomgroup.setBetas(bfactors[mask][:modelSize])
atomgroup.setOccupancies(occupancies[mask][:modelSize])

anisou = None
siguij = None
Expand Down Expand Up @@ -558,6 +561,6 @@ def _parseMMCIFLines(atomgroup, lines, model, chain, subset,

if model is None:
for n in range(1, nModels):
atomgroup.addCoordset(coordinates[n*modelSize:(n+1)*modelSize])
atomgroup.addCoordset(coordinates[mask][n*modelSize:(n+1)*modelSize])

return atomgroup

0 comments on commit 30052ce

Please sign in to comment.