Skip to content

Commit

Permalink
better fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmkrieger committed Nov 6, 2023
1 parent 1ac6aa0 commit 574177f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions prody/proteins/pdbfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1242,12 +1242,7 @@ def writePDBStream(stream, atoms, csets=None, **kwargs):
Default is **False**, which means using hexadecimal instead.
NB: ChimeraX seems to prefer hybrid36 and may have problems with hexadecimal.
:type hybrid36: bool
"""
keepACSI = False
if hasattr(atoms, 'getACSIndex'):
initialACSI = atoms.getACSIndex()
keepACSI = True

"""
renumber = kwargs.get('renumber', True)

remark = str(atoms)
Expand All @@ -1266,8 +1261,10 @@ def writePDBStream(stream, atoms, csets=None, **kwargs):
if coordsets is None:
raise ValueError('atoms does not have any coordinate sets')

had_atoms = False
try:
acsi = atoms.getACSIndex()
had_atoms = True
except AttributeError:
try:
atoms = atoms.getAtoms()
Expand Down Expand Up @@ -1442,7 +1439,8 @@ def writePDBStream(stream, atoms, csets=None, **kwargs):
num_ter_lines = 0
for m, coords in enumerate(coordsets):

atoms.setACSIndex(m)
if had_atoms:
atoms.setACSIndex(m)
anisous = atoms._getAnisous()
if anisous is not None:
anisous = np.array(anisous * 10000, dtype=int)
Expand Down Expand Up @@ -1618,8 +1616,8 @@ def writePDBStream(stream, atoms, csets=None, **kwargs):

write('END ' + " "*74 + '\n')

if keepACSI:
atoms.setACSIndex(initialACSI)
if had_atoms:
atoms.setACSIndex(acsi)

writePDBStream.__doc__ += _writePDBdoc

Expand Down

0 comments on commit 574177f

Please sign in to comment.