Skip to content

Commit

Permalink
Merge branch 'acs_fix' of github.com:jamesmkrieger/ProDy into clusten…
Browse files Browse the repository at this point in the history
…m_fit
  • Loading branch information
jamesmkrieger committed Nov 6, 2023
2 parents a53c4bd + 1ac6aa0 commit edaac21
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
9 changes: 7 additions & 2 deletions prody/proteins/pdbfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,11 @@ def writePDBStream(stream, atoms, csets=None, **kwargs):
NB: ChimeraX seems to prefer hybrid36 and may have problems with hexadecimal.
:type hybrid36: bool
"""
initialACSI = atoms.getACSIndex()
keepACSI = False
if hasattr(atoms, 'getACSIndex'):
initialACSI = atoms.getACSIndex()
keepACSI = True

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

remark = str(atoms)
Expand Down Expand Up @@ -1614,7 +1618,8 @@ def writePDBStream(stream, atoms, csets=None, **kwargs):

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

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

writePDBStream.__doc__ += _writePDBdoc

Expand Down
15 changes: 15 additions & 0 deletions prody/tests/proteins/test_pdbfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ def setUp(self):
self.ag = parsePDB(self.pdb['path'])
self.tmp = os.path.join(TEMPDIR, 'test.pdb')

self.ens = PDBEnsemble()
self.ens.setAtoms(self.ag)
self.ens.setCoords(self.ag.getCoords())
self.ens.addCoordset(self.ag.getCoordsets())

self.ubi = parsePDB(DATA_FILES['1ubi']['path'], secondary=True)

self.hex = parsePDB(DATA_FILES['hex']['path'])
Expand Down Expand Up @@ -446,6 +451,16 @@ def testWritingAltlocModels(self):

self.assertEqual(lines1[8], lines2[8],
'writePDB failed to write correct ANISOU line 8 for 6flr selection with altloc None')

def testWriteEnsembleToPDB(self):
"""Test that writePDB can handle ensembles."""

out = writePDB(self.tmp, self.ens)
out = parsePDB(out)
self.assertEqual(out.numCoordsets(), self.ens.numCoordsets(),
'failed to write correct number of models from ensemble')
assert_equal(out.getCoords(), self.ag.getCoordsets(0),
'failed to write ensemble model 1 coordinates correctly')

@dec.slow
def tearDown(self):
Expand Down

0 comments on commit edaac21

Please sign in to comment.