Skip to content

Commit

Permalink
Merge pull request #1999 from jamesmkrieger/insty_energy
Browse files Browse the repository at this point in the history
add build and overwrite to showCumulativeInteractionTypes energy
  • Loading branch information
jamesmkrieger authored Nov 22, 2024
2 parents 6862fdc + 375d5ff commit 36222dd
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions prody/proteins/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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]_.
Expand All @@ -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())
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -3817,6 +3840,16 @@ 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

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
Expand Down

0 comments on commit 36222dd

Please sign in to comment.