Skip to content

Commit

Permalink
Merge pull request #1554 from jamesmkrieger/pca_app_nmodes_fix
Browse files Browse the repository at this point in the history
Restore SVD in some cases
  • Loading branch information
jamesmkrieger authored May 17, 2022
2 parents 45cd0d8 + 00d0fd9 commit 0e63ad4
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions prody/apps/prody_apps/prody_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,15 @@ def prody_pca(coords, **kwargs):
pca.calcModes(nmodes)
ensemble = dcd
else:
pca.buildCovariance(dcd, aligned=kwargs.get('aligned'))
pca.calcModes(nmodes)
ensemble = dcd
if len(dcd) > 1000:
pca.buildCovariance(dcd, aligned=kwargs.get('aligned'))
pca.calcModes(nmodes)
ensemble = dcd
else:
ensemble = dcd[:]
if not kwargs.get('aligned'):
ensemble.iterpose(quiet=True)
pca.performSVD(ensemble)

else:
pdb = prody.parsePDB(coords)
Expand Down Expand Up @@ -135,8 +141,7 @@ def prody_pca(coords, **kwargs):
pca.buildCovariance(ensemble, aligned=kwargs.get('aligned'))
pca.calcModes(nmodes)
else:
pca.buildCovariance(ensemble, aligned=kwargs.get('aligned'))
pca.calcModes(nmodes)
pca.performSVD(ensemble)

LOGGER.info('Writing numerical output.')
if kwargs.get('outnpz'):
Expand All @@ -145,15 +150,15 @@ def prody_pca(coords, **kwargs):
if kwargs.get('outscipion'):
prody.writeScipionModes(outdir, pca)

prody.writeNMD(join(outdir, prefix + '.nmd'), pca, select)
prody.writeNMD(join(outdir, prefix + '.nmd'), pca[:nmodes], select)

extend = kwargs.get('extend')
if extend:
if pdb:
if extend == 'all':
extended = prody.extendModel(pca, select, pdb)
extended = prody.extendModel(pca[:nmodes], select, pdb)
else:
extended = prody.extendModel(pca, select,
extended = prody.extendModel(pca[:nmodes], select,
select | pdb.bb)
prody.writeNMD(join(outdir, prefix + '_extended_' +
extend + '.nmd'), *extended)
Expand Down

0 comments on commit 0e63ad4

Please sign in to comment.