Skip to content

Commit 8171493

Browse files
committed
changing the calculation of conformational state probability to account for groups
1 parent 06b787f commit 8171493

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎CodeEntropy/entropy.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def _process_united_atom_entropy(
475475
# If there are no conformational states (i.e. no dihedrals)
476476
# then the conformational entropy is zero
477477
S_conf_res = (
478-
ce.conformational_entropy_calculation(values, number_frames)
478+
ce.conformational_entropy_calculation(values)
479479
if contains_non_empty_states
480480
else 0
481481
)
@@ -605,7 +605,7 @@ def _process_conformational_entropy(
605605
# If there are no conformational states (i.e. no dihedrals)
606606
# then the conformational entropy is zero
607607
S_conf = (
608-
ce.conformational_entropy_calculation(group_states, number_frames)
608+
ce.conformational_entropy_calculation(group_states)
609609
if contains_state_data
610610
else 0
611611
)
@@ -1037,7 +1037,7 @@ def assign_conformation(
10371037

10381038
return conformations
10391039

1040-
def conformational_entropy_calculation(self, states, number_frames):
1040+
def conformational_entropy_calculation(self, states):
10411041
"""
10421042
Function to calculate conformational entropies using eq. (7) in Higham,
10431043
S.-Y. Chou, F. Gräter and R. H. Henchman, Molecular Physics, 2018, 116,
@@ -1048,7 +1048,6 @@ def conformational_entropy_calculation(self, states, number_frames):
10481048
10491049
Args:
10501050
states (array): Conformational states in the molecule
1051-
number_frames (int): The number of frames analysed
10521051
10531052
Returns:
10541053
S_conf_total (float) : conformational entropy
@@ -1060,11 +1059,12 @@ def conformational_entropy_calculation(self, states, number_frames):
10601059
# to get the entropy
10611060
# entropy = sum over states p*ln(p)
10621061
values, counts = np.unique(states, return_counts=True)
1062+
total_count = len(states)
10631063
for state in range(len(values)):
10641064
logger.debug(f"Unique states: {values}")
10651065
logger.debug(f"Counts: {counts}")
10661066
count = counts[state]
1067-
probability = count / number_frames
1067+
probability = count / total_count
10681068
entropy = probability * np.log(probability)
10691069
S_conf_total += entropy
10701070

0 commit comments

Comments
 (0)