@@ -64,7 +64,6 @@ def execute(self):
6464 # Get reduced universe and initialize values
6565 reduced_atom = self ._get_reduced_universe ()
6666 number_molecules , levels = self ._level_manager .select_levels (reduced_atom )
67- # number_residues = len(reduced_atom.residues)
6867
6968 ve = VibrationalEntropy (
7069 self ._run_manager ,
@@ -169,6 +168,7 @@ def execute(self):
169168 highest_level = level == levels [molecule_id ][- 1 ]
170169
171170 if level == "united_atom" :
171+ # get the conformational states
172172 for res_id , residue in enumerate (mol_container .residues ):
173173 key = (molecule_id , res_id )
174174
@@ -183,9 +183,15 @@ def execute(self):
183183 res_container , "not name H*"
184184 )
185185
186+ # get dihedrals
186187 dihedrals = self ._level_manager .get_dihedrals (heavy_res , level )
188+ num_dihedrals = len (dihedrals )
189+
190+ # assign conformation for each dihedral
191+ conformation = np .zeros ((num_dihedrals , number_frames ))
192+ dihedral_index = 0
187193 for dihedral in dihedrals :
188- states_ua [ key ] = ce .assign_conformation (
194+ conformation [ dihedral_index ] = ce .assign_conformation (
189195 heavy_res ,
190196 dihedral ,
191197 number_frames ,
@@ -194,7 +200,17 @@ def execute(self):
194200 end ,
195201 step ,
196202 )
203+ dihedral_index += 1
204+
205+ # concatenate conformations into state string
206+ states_ua [key ] = ["" for x in range (number_frames )]
207+ for frame_index in range (number_frames ):
208+ for dihedral_index in range (num_dihedrals ):
209+ states_ua [key ][frame_index ] += str (conformation [dihedral_index ][frame_index ])
210+ logger .debug (f"States UA { states_ua [key ]} " )
211+
197212
213+ # Calculate the united atom entropy
198214 self ._process_united_atom_entropy (
199215 molecule_id ,
200216 mol_container ,
@@ -211,9 +227,15 @@ def execute(self):
211227
212228 elif level == "residue" :
213229
230+ # get dihedrals
214231 dihedrals = self ._level_manager .get_dihedrals (mol_container , level )
232+ num_dihedrals = len (dihedrals )
233+
234+ # for each dihedral assign conformation
235+ conformation = np .zeros ((num_dihedrals , number_frames ))
236+ dihedral_index = 0
215237 for dihedral in dihedrals :
216- states_res [ molecule_id ] = ce .assign_conformation (
238+ conformation [ dihedral_index ] = ce .assign_conformation (
217239 mol_container ,
218240 dihedral ,
219241 number_frames ,
@@ -222,6 +244,15 @@ def execute(self):
222244 end ,
223245 step ,
224246 )
247+ dihedral_index += 1
248+
249+ # concatenate conformations into state string
250+ states_res = ["" for x in range (number_frames )]
251+ for frame_index in range (number_frames ):
252+ for dihedral_index in range (num_dihedrals ):
253+ states_res [frame_index ] += str (conformation [dihedral_index ][frame_index ])
254+ logger .debug (f"States UA { states_res } " )
255+
225256
226257 self ._process_vibrational_entropy (
227258 molecule_id ,
@@ -237,7 +268,7 @@ def execute(self):
237268 mol_container ,
238269 ce ,
239270 level ,
240- states_res [ molecule_id ] ,
271+ states_res ,
241272 number_frames ,
242273 )
243274
@@ -423,10 +454,13 @@ def _process_vibrational_entropy(
423454 level.
424455 """
425456 number_frames = len (mol_container .trajectory )
457+
426458 force_matrix = self ._level_manager .filter_zero_rows_columns (force_matrix )
427459 force_matrix = force_matrix / number_frames
460+
428461 torque_matrix = self ._level_manager .filter_zero_rows_columns (torque_matrix )
429462 torque_matrix = torque_matrix / number_frames
463+
430464 S_trans = ve .vibrational_entropy_calculation (
431465 force_matrix , "force" , self ._args .temperature , highest
432466 )
0 commit comments