From f02f99dc007f541a1f52bb964fcfe95ec0bbc644 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Tue, 17 May 2022 08:59:53 +0200 Subject: [PATCH 1/4] add missed quiet check --- prody/dynamics/pca.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/prody/dynamics/pca.py b/prody/dynamics/pca.py index 65a936cd9..70ffe0ccc 100644 --- a/prody/dynamics/pca.py +++ b/prody/dynamics/pca.py @@ -158,13 +158,16 @@ def buildCovariance(self, coordsets, **kwargs): cov = np.zeros((dof, dof)) coordsets = coordsets.reshape((n_confs, dof)) mean = coordsets.mean(0) - LOGGER.progress('Building covariance', n_confs, + if not quiet: + LOGGER.progress('Building covariance', n_confs, '_prody_pca') for i, coords in enumerate(coordsets.reshape(s)): deviations = coords - mean cov += np.outer(deviations, deviations) - LOGGER.update(n_confs, label='_prody_pca') - LOGGER.finish() + if not quiet: + LOGGER.update(n_confs, label='_prody_pca') + if not quiet: + LOGGER.finish() cov /= n_confs self._cov = cov else: @@ -255,10 +258,10 @@ def performSVD(self, coordsets): coordsets._getCoords()) n_confs = deviations.shape[0] - if n_confs < 3: + if n_confs <= 3: raise ValueError('coordsets must have more than 3 coordinate sets') n_atoms = deviations.shape[1] - if n_atoms < 3: + if n_atoms <= 3: raise ValueError('coordsets must have more than 3 atoms') dof = n_atoms * 3 From 3fc8ed91df0ca6535d743edd17229a916747e408 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Tue, 17 May 2022 17:24:09 +0200 Subject: [PATCH 2/4] remove pca app quiet kwarg --- prody/apps/prody_apps/prody_pca.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/prody/apps/prody_apps/prody_pca.py b/prody/apps/prody_apps/prody_pca.py index 0e79c91fb..ed14230a7 100644 --- a/prody/apps/prody_apps/prody_pca.py +++ b/prody/apps/prody_apps/prody_pca.py @@ -47,7 +47,6 @@ def prody_pca(coords, **kwargs): prefix = kwargs.get('prefix') nmodes = kwargs.get('nmodes') selstr = kwargs.get('select') - quiet = kwargs.pop('quiet', False) altloc = kwargs.get('altloc') ext = splitext(coords)[1].lower() @@ -96,11 +95,11 @@ def prody_pca(coords, **kwargs): raise ImportError('Please install threadpoolctl to control threads') with threadpool_limits(limits=nproc, user_api="blas"): - pca.buildCovariance(dcd, aligned=kwargs.get('aligned'), quiet=quiet) + pca.buildCovariance(dcd, aligned=kwargs.get('aligned')) pca.calcModes(nmodes) ensemble = dcd else: - pca.buildCovariance(dcd, aligned=kwargs.get('aligned'), quiet=quiet) + pca.buildCovariance(dcd, aligned=kwargs.get('aligned')) pca.calcModes(nmodes) ensemble = dcd @@ -133,10 +132,10 @@ def prody_pca(coords, **kwargs): raise ImportError('Please install threadpoolctl to control threads') with threadpool_limits(limits=nproc, user_api="blas"): - pca.buildCovariance(ensemble, aligned=kwargs.get('aligned'), quiet=quiet) + pca.buildCovariance(ensemble, aligned=kwargs.get('aligned')) pca.calcModes(nmodes) else: - pca.buildCovariance(ensemble, aligned=kwargs.get('aligned'), quiet=quiet) + pca.buildCovariance(ensemble, aligned=kwargs.get('aligned')) pca.calcModes(nmodes) LOGGER.info('Writing numerical output.') @@ -269,7 +268,7 @@ def addCommand(commands): subparser = commands.add_parser('pca', help='perform principal component analysis calculations') - subparser.add_argument('--quiet', help="suppress info messages to stderr", + subparser.add_argument('--quiet', help='suppress info messages to stderr', action=Quiet, nargs=0) subparser.add_argument('--examples', action=UsageExample, nargs=0, From 95d09f8533775c552fd6ecef3c6a3f7214cee073 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Tue, 17 May 2022 17:24:55 +0200 Subject: [PATCH 3/4] another build covariance quiet add --- prody/dynamics/pca.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/prody/dynamics/pca.py b/prody/dynamics/pca.py index 70ffe0ccc..85d171262 100644 --- a/prody/dynamics/pca.py +++ b/prody/dynamics/pca.py @@ -147,8 +147,9 @@ def buildCovariance(self, coordsets, **kwargs): if n_atoms < 3: raise ValueError('coordsets must have more than 3 atoms') dof = n_atoms * 3 - LOGGER.info('Covariance is calculated using {0} coordinate sets.' - .format(len(coordsets))) + if not quiet: + LOGGER.info('Covariance is calculated using {0} coordinate sets.' + .format(len(coordsets))) s = (n_confs, dof) if weights is None: if coordsets.dtype == float: @@ -188,7 +189,8 @@ def buildCovariance(self, coordsets, **kwargs): self._trace = self._cov.trace() self._dof = dof self._n_atoms = n_atoms - LOGGER.report('Covariance matrix calculated in %2fs.', '_prody_pca') + if not quiet: + LOGGER.report('Covariance matrix calculated in %2fs.', '_prody_pca') def calcModes(self, n_modes=20, turbo=True): """Calculate principal (or essential) modes. This method uses From a257f98b5709e5006aad9d89eb414a3ef5da73d8 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Tue, 17 May 2022 17:25:23 +0200 Subject: [PATCH 4/4] logger progress check level fix --- prody/utilities/logger.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/prody/utilities/logger.py b/prody/utilities/logger.py index de6320683..0f18aba87 100644 --- a/prody/utilities/logger.py +++ b/prody/utilities/logger.py @@ -251,7 +251,8 @@ def progress(self, msg, steps, label=None, **kwargs): if not hasattr(self, '_verb'): self._verb = self._getverbosity() - self._setverbosity('progress') + if self._level < logging.WARNING: + self._setverbosity('progress') self._n_progress += 1 def update(self, step, msg=None, label=None):