@@ -93,7 +93,7 @@ def execute(self):
9393 states_res = [None for _ in range (number_molecules )]
9494
9595 for timestep in reduced_atom .trajectory [start :end :step ]:
96- # time_index = timestep.frame - start
96+ time_index = timestep .frame - start
9797
9898 for molecule_id in range (number_molecules ):
9999 mol_container = self ._get_molecule_container (reduced_atom , molecule_id )
@@ -104,6 +104,7 @@ def execute(self):
104104
105105 # Get matrices for vibrational entropy calculations
106106 if level == "united_atom" :
107+ mol_container .trajectory [time_index ]
107108 for res_id , residue in enumerate (mol_container .residues ):
108109 key = (molecule_id , res_id )
109110
@@ -114,6 +115,9 @@ def execute(self):
114115 f"{ residue .atoms .indices [- 1 ]} "
115116 ),
116117 )
118+
119+ res_container .trajectory [time_index ]
120+
117121 force_matrix , torque_matrix = (
118122 self ._level_manager .get_matrices (
119123 res_container ,
@@ -129,6 +133,8 @@ def execute(self):
129133 torque_matrix_ua [key ] = torque_matrix
130134
131135 elif level == "residue" :
136+ mol_container .trajectory [time_index ]
137+
132138 force_matrix , torque_matrix = self ._level_manager .get_matrices (
133139 mol_container ,
134140 level ,
@@ -141,6 +147,8 @@ def execute(self):
141147 torque_matrix_res [molecule_id ] = torque_matrix
142148
143149 elif level == "polymer" :
150+ mol_container .trajectory [time_index ]
151+
144152 force_matrix , torque_matrix = self ._level_manager .get_matrices (
145153 mol_container ,
146154 level ,
@@ -233,6 +241,7 @@ def execute(self):
233241 torque_matrix_ua [key ],
234242 states_ua [key ],
235243 highest_level ,
244+ number_frames ,
236245 )
237246
238247 elif level == "residue" :
@@ -246,7 +255,12 @@ def execute(self):
246255 highest_level ,
247256 )
248257 self ._process_conformational_entropy (
249- molecule_id , mol_container , ce , level , states_res [molecule_id ]
258+ molecule_id ,
259+ mol_container ,
260+ ce ,
261+ level ,
262+ states_res [molecule_id ],
263+ number_frames ,
250264 )
251265
252266 elif level == "polymer" :
@@ -348,6 +362,7 @@ def _process_united_atom_entropy(
348362 torque_matrix ,
349363 states ,
350364 highest ,
365+ number_frames ,
351366 ):
352367 """
353368 Calculates translational, rotational, and conformational entropy at the
@@ -374,7 +389,7 @@ def _process_united_atom_entropy(
374389 torque_matrix , "torque" , self ._args .temperature , highest
375390 )
376391
377- S_conf_res = ce .conformational_entropy_calculation (mol_id , states )
392+ S_conf_res = ce .conformational_entropy_calculation (states , number_frames )
378393
379394 S_trans += S_trans_res
380395 S_rot += S_rot_res
@@ -416,7 +431,6 @@ def _process_vibrational_entropy(
416431 highest (bool): Flag indicating if this is the highest granularity
417432 level.
418433 """
419- force_matrix , torque_matrix = self .force_matrix , self .torque_matrix
420434
421435 S_trans = ve .vibrational_entropy_calculation (
422436 force_matrix , "force" , self ._args .temperature , highest
@@ -432,7 +446,9 @@ def _process_vibrational_entropy(
432446 residue .resname , level , "Rovibrational" , S_rot
433447 )
434448
435- def _process_conformational_entropy (self , mol_id , mol_container , ce , level , states ):
449+ def _process_conformational_entropy (
450+ self , mol_id , mol_container , ce , level , states , number_frames
451+ ):
436452 """
437453 Computes conformational entropy at the residue level (whole-molecule dihedral
438454 analysis).
@@ -445,7 +461,7 @@ def _process_conformational_entropy(self, mol_id, mol_container, ce, level, stat
445461 start, end, step (int): Frame bounds.
446462 n_frames (int): Number of frames used.
447463 """
448- S_conf = ce .conformational_entropy_calculation (states )
464+ S_conf = ce .conformational_entropy_calculation (states , number_frames )
449465 residue = mol_container .residues [mol_id ]
450466 self ._data_logger .add_results_data (
451467 residue .resname , level , "Conformational" , S_conf
@@ -813,9 +829,7 @@ def assign_conformation(
813829
814830 return conformations
815831
816- def conformational_entropy_calculation (
817- self , data_container , dihedrals , bin_width , start , end , step , number_frames
818- ):
832+ def conformational_entropy_calculation (self , states , number_frames ):
819833 """
820834 Function to calculate conformational entropies using eq. (7) in Higham,
821835 S.-Y. Chou, F. Gräter and R. H. Henchman, Molecular Physics, 2018, 116,
@@ -834,27 +848,6 @@ def conformational_entropy_calculation(
834848
835849 S_conf_total = 0
836850
837- # For each dihedral, identify the conformation in each frame
838- num_dihedrals = len (dihedrals )
839- conformation = np .zeros ((num_dihedrals , number_frames ))
840- index = 0
841- for dihedral in dihedrals :
842- conformation [index ] = self .assign_conformation (
843- data_container , dihedral , number_frames , bin_width , start , end , step
844- )
845- index += 1
846-
847- logger .debug (f"Conformation matrix: { conformation } " )
848-
849- # For each frame, convert the conformation of all dihedrals into a
850- # state string
851- states = ["" for x in range (number_frames )]
852- for frame_index in range (number_frames ):
853- for index in range (num_dihedrals ):
854- states [frame_index ] += str (conformation [index ][frame_index ])
855-
856- logger .debug (f"States: { states } " )
857-
858851 # Count how many times each state occurs, then use the probability
859852 # to get the entropy
860853 # entropy = sum over states p*ln(p)
0 commit comments