From 4f3320a19e8a1dddad893a7c81490f49e4494f30 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 22 Nov 2024 00:54:52 +0100 Subject: [PATCH 1/2] add build and overwrite to showCumulativeInteractionTypes energy --- prody/proteins/interactions.py | 38 ++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/prody/proteins/interactions.py b/prody/proteins/interactions.py index 3e3081354..effa7052e 100644 --- a/prody/proteins/interactions.py +++ b/prody/proteins/interactions.py @@ -3036,6 +3036,7 @@ def __init__(self, title='Unknown'): self._interactions = None self._interactions_matrix = None self._interactions_matrix_en = None + self._energy_type = None self._hbs = None self._sbs = None self._rib = None @@ -3408,7 +3409,7 @@ def buildInteractionMatrix(self, **kwargs): atoms = self._atoms interactions = self._interactions - LOGGER.info('Calculating interactions') + LOGGER.info('Calculating interaction matrix') InteractionsMap = np.zeros([atoms.select('name CA').numAtoms(),atoms.select('name CA').numAtoms()]) resIDs = list(atoms.select('name CA').getResnums()) resChIDs = list(atoms.select('name CA').getChids()) @@ -3456,10 +3457,11 @@ def buildInteractionMatrix(self, **kwargs): def buildInteractionMatrixEnergy(self, **kwargs): """Build matrix with interaction energy comming from energy of pairs of specific residues. - + :arg energy_list_type: name of the list with energies default is 'IB_solv' - :type energy_list_type: 'IB_nosolv', 'IB_solv', 'CS' + acceptable values are 'IB_nosolv', 'IB_solv', 'CS' + :type energy_list_type: str 'IB_solv' and 'IB_nosolv' are derived from empirical potentials from O Keskin, I Bahar and colleagues from [OK98]_. @@ -3482,7 +3484,7 @@ def buildInteractionMatrixEnergy(self, **kwargs): interactions = self._interactions energy_list_type = kwargs.pop('energy_list_type', 'IB_solv') - LOGGER.info('Calculating interactions') + LOGGER.info('Calculating interaction energies matrix with type {0}'.format(energy_list_type)) InteractionsMap = np.zeros([atoms.select('name CA').numAtoms(),atoms.select('name CA').numAtoms()]) resIDs = list(atoms.select('name CA').getResnums()) resChIDs = list(atoms.select('name CA').getChids()) @@ -3498,6 +3500,7 @@ def buildInteractionMatrixEnergy(self, **kwargs): InteractionsMap[m1][m2] = InteractionsMap[m2][m1] = float(scoring) self._interactions_matrix_en = InteractionsMap + self._energy_type = energy_list_type return InteractionsMap @@ -3792,6 +3795,26 @@ def showCumulativeInteractionTypes(self, **kwargs): :arg energy: sum of the energy between residues default is False :type energy: bool + + :arg energy_list_type: name of the list with energies + default is 'IB_solv' + acceptable values are 'IB_nosolv', 'IB_solv', 'CS' + :type energy_list_type: str + + :arg overwrite_energies: whether to overwrite energies + default is False + :type overwrite_energies: bool + + 'IB_solv' and 'IB_nosolv' are derived from empirical potentials from + O Keskin, I Bahar and colleagues from [OK98]_. + + 'CS' is from MD simulations of amino acid pairs from Carlos Simmerling + and Gary Wu. + + .. [OK98] Keskin O, Bahar I, Badretdinov AY, Ptitsyn OB, Jernigan RL, + Empirical solvent-mediated potentials hold for both intra-molecular + and inter-molecular inter-residue interactions + *Protein Sci* **1998** 7(12):2578-2586. """ import numpy as np @@ -3817,6 +3840,13 @@ def showCumulativeInteractionTypes(self, **kwargs): if energy == True: matrix_en = self._interactions_matrix_en + energy_list_type = kwargs.pop('energy_list_type', 'IB_solv') + overwrite = kwargs.pop('overwrite_energies', False) + if matrix_en is None or overwrite: + LOGGER.warn('The energy matrix is recalculated with type {0}'.format(energy_list_type)) + self.buildInteractionMatrixEnergy(energy_list_type=energy_list_type) + matrix_en = self._interactions_matrix_en + matrix_en_sum = np.sum(matrix_en, axis=0) width = 0.8 From 375d5ff7f3ded078569528a625e68ecbb58fc35d Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 22 Nov 2024 00:57:05 +0100 Subject: [PATCH 2/2] warn wrong energy type --- prody/proteins/interactions.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/prody/proteins/interactions.py b/prody/proteins/interactions.py index effa7052e..1e05157ec 100644 --- a/prody/proteins/interactions.py +++ b/prody/proteins/interactions.py @@ -3847,6 +3847,9 @@ def showCumulativeInteractionTypes(self, **kwargs): self.buildInteractionMatrixEnergy(energy_list_type=energy_list_type) matrix_en = self._interactions_matrix_en + elif self._energy_type != energy_list_type: + LOGGER.warn('The energy type is {0}, not {1}'.format(self._energy_type, energy_list_type)) + matrix_en_sum = np.sum(matrix_en, axis=0) width = 0.8