Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frustratometer/classes/AWSEM.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(self,
pdb_structure: object,
sequence: str =None,
expose_indicator_functions: bool=False,
sparse: bool=False,
**parameters)->object:
"""
Generate AWSEM object
Expand Down
1 change: 0 additions & 1 deletion frustratometer/classes/Gamma.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def __init__(self, data, segment_definition=None, description=None, alphabet=Non
self._init_from_file(data)
else:
raise TypeError("Unsupported type for initializing Gamma.")
print(self.gamma_array)

self.alphabet = alphabet if alphabet is not None else self.default_alphabet.copy()
self.segment_definition = segment_definition if segment_definition is not None else self.default_segment_definition.copy()
Expand Down
4 changes: 2 additions & 2 deletions frustratometer/frustration/frustration.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ def compute_auc(roc_score):
auc : float
AUC value
"""
fpr, tpr = roc
fpr, tpr = roc_score
auc = np.sum(tpr[:-1] * (fpr[1:] - fpr[:-1]))
return auc

Expand All @@ -811,7 +811,7 @@ def plot_roc(roc_score):
Array containing lists of false and true positive rates
"""
import matplotlib.pyplot as plt
plt.plot(roc[0], roc[1])
plt.plot(roc_score[0], roc_score[1])
plt.xlabel('False positive rate (1-specificity)')
plt.ylabel('True positive rate (sensiticity)')
plt.suptitle('Receiver operating characteristic')
Expand Down
80 changes: 50 additions & 30 deletions frustratometer/optimization/EnergyTerm.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,45 +80,65 @@ def dummy_decorator(func, *args, **kwargs):
return func

@property
#@lru_cache(maxsize=None)
def energies_function(self):
""" Returns the energy function as a numba dispatcher. """
energy_function = self.energy_function
def compute_energies(seq_indices:np.ndarray):
"""Compute the energies of multiple sequences."""
energies = np.zeros(len(seq_indices))
for i in numba.prange(len(seq_indices)):
energies[i] = energy_function(seq_indices[i])
return energies

if self.use_numba:
return numba.njit(types.Array(types.float64, 1, 'C')(types.Array(types.int64, 2, 'A', readonly=True)), parallel=True)(compute_energies)
else:
return compute_energies
if not hasattr(self, '_energies_function_cache'):
energy_function = self.energy_function

def compute_energies(seq_indices: np.ndarray):
energies = np.zeros(len(seq_indices))
for i in numba.prange(len(seq_indices)):
energies[i] = energy_function(seq_indices[i])
return energies

if self.use_numba:
self._energies_function_cache = numba.njit(
types.Array(types.float64, 1, 'C')(types.Array(types.int64, 2, 'A', readonly=True)),
parallel=True
)(compute_energies)
else:
self._energies_function_cache = compute_energies
return self._energies_function_cache

@property
#@lru_cache(maxsize=None)
def energy_function(self):
""" Returns the energy function as a numba dispatcher. """
if self.use_numba:
return numba.njit(types.float64(types.Array(types.int64, 1, 'A', readonly=True)))(self.compute_energy)
return self.compute_energy

if not hasattr(self, '_energy_function_cache'):
if self.use_numba:
self._energy_function_cache = numba.njit(
types.float64(types.Array(types.int64, 1, 'A', readonly=True))
)(self.compute_energy)
else:
self._energy_function_cache = self.compute_energy
return self._energy_function_cache

@property
#@lru_cache(maxsize=None)
def denergy_mutation_function(self):
""" Returns the mutation energy change function as a numba dispatcher. """
if self.use_numba:
return numba.njit(types.float64(types.Array(types.int64, 1, 'A', readonly=True),types.int64,types.int64))(self.compute_denergy_mutation)
return self.compute_denergy_mutation
if not hasattr(self, '_denergy_mutation_function_cache'):
if self.use_numba:
self._denergy_mutation_function_cache = numba.njit(
types.float64(
types.Array(types.int64, 1, 'A', readonly=True),
types.int64,
types.int64
)
)(self.compute_denergy_mutation)
else:
self._denergy_mutation_function_cache = self.compute_denergy_mutation
return self._denergy_mutation_function_cache

@property
#@lru_cache(maxsize=None)
def denergy_swap_function(self):
""" Returns the swap energy change function as a numba dispatcher. """
if self.use_numba:
return numba.njit(types.float64(types.Array(types.int64, 1, 'A', readonly=True),types.int64,types.int64))(self.compute_denergy_swap)
return self.compute_denergy_swap
if not hasattr(self, '_denergy_swap_function_cache'):
if self.use_numba:
self._denergy_swap_function_cache = numba.njit(
types.float64(
types.Array(types.int64, 1, 'A', readonly=True),
types.int64,
types.int64
)
)(self.compute_denergy_swap)
else:
self._denergy_swap_function_cache = self.compute_denergy_swap
return self._denergy_swap_function_cache

@staticmethod
#@abc.abstractmethod #TODO: Add abstract method decorator. Currently not working due to the late initialization of the methods.
Expand Down
Loading