Skip to content

Commit

Permalink
better fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmkrieger committed Nov 8, 2023
1 parent f6baf7c commit 624b889
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions prody/proteins/ciffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,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 @@ -434,8 +433,6 @@ def _parseMMCIFLines(atomgroup, lines, model, chain, subset,
continue

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

if alt == '.':
alt = ' '
Expand Down Expand Up @@ -483,28 +480,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])
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])

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

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

anisou = None
siguij = None
Expand Down

0 comments on commit 624b889

Please sign in to comment.