@@ -74,6 +74,7 @@ def run(self, shared_data: MutableMapping[str, Any], **_: Any) -> Dict[str, Any]
7474 groups = shared_data ["groups" ]
7575 levels = shared_data ["levels" ]
7676 fragments = shared_data ["reduced_universe" ].atoms .fragments
77+ flexible = shared_data ["flexible_dihedrals" ]
7778
7879 gid2i = self ._get_group_id_to_index (shared_data )
7980
@@ -108,6 +109,7 @@ def run(self, shared_data: MutableMapping[str, Any], **_: Any) -> Dict[str, Any]
108109 residues = rep_mol .residues ,
109110 force_ua = force_cov ["ua" ],
110111 torque_ua = torque_cov ["ua" ],
112+ flexible = flexible ["ua" ],
111113 ua_frame_counts = ua_frame_counts ,
112114 reporter = reporter ,
113115 n_frames_default = shared_data .get ("n_frames" , 0 ),
@@ -137,11 +139,17 @@ def run(self, shared_data: MutableMapping[str, Any], **_: Any) -> Dict[str, Any]
137139 fmat = self ._get_indexed_matrix (force_cov .get (cov_key , []), gi )
138140 tmat = self ._get_indexed_matrix (torque_cov .get (cov_key , []), gi )
139141
142+ if level == "residue" :
143+ flexible = flexible ["res" ][group_id ]
144+ else :
145+ flexible = 0 # No polymer level flexible dihedrals
146+
140147 pair = self ._compute_force_torque_entropy (
141148 ve = ve ,
142149 temp = temp ,
143150 fmat = fmat ,
144151 tmat = tmat ,
152+ flexible = flexible ,
145153 highest = highest ,
146154 )
147155 self ._store_results (results , group_id , level , pair )
@@ -216,6 +224,7 @@ def _compute_united_atom_entropy(
216224 residues : Any ,
217225 force_ua : Mapping [CovKey , Any ],
218226 torque_ua : Mapping [CovKey , Any ],
227+ flexible : Any ,
219228 ua_frame_counts : Mapping [CovKey , int ],
220229 reporter : Optional [Any ],
221230 n_frames_default : int ,
@@ -234,6 +243,7 @@ def _compute_united_atom_entropy(
234243 residues: Residue container/sequence for the representative molecule.
235244 force_ua: Mapping from (group_id, residue_id) to force covariance matrix.
236245 torque_ua: Mapping from (group_id, residue_id) to torque covariance matrix.
246+ flexible: Data about number of flexible dihedrals
237247 ua_frame_counts: Mapping from (group_id, residue_id) to frame counts.
238248 reporter: Optional reporter object supporting add_residue_data calls.
239249 n_frames_default: Fallback frame count if per-residue count missing.
@@ -249,12 +259,14 @@ def _compute_united_atom_entropy(
249259 key = (group_id , res_id )
250260 fmat = force_ua .get (key )
251261 tmat = torque_ua .get (key )
262+ flexible = flexible [key ]
252263
253264 pair = self ._compute_force_torque_entropy (
254265 ve = ve ,
255266 temp = temp ,
256267 fmat = fmat ,
257268 tmat = tmat ,
269+ flexible = flexible ,
258270 highest = highest ,
259271 )
260272
@@ -289,6 +301,7 @@ def _compute_force_torque_entropy(
289301 temp : float ,
290302 fmat : Any ,
291303 tmat : Any ,
304+ flexible : int ,
292305 highest : bool ,
293306 ) -> EntropyPair :
294307 """Compute vibrational entropy from separate force and torque covariances.
@@ -321,10 +334,10 @@ def _compute_force_torque_entropy(
321334 return EntropyPair (trans = 0.0 , rot = 0.0 )
322335
323336 s_trans = ve .vibrational_entropy_calculation (
324- f , "force" , temp , highest_level = highest
337+ f , "force" , temp , highest_level = highest , flexible = flexible
325338 )
326339 s_rot = ve .vibrational_entropy_calculation (
327- t , "torque" , temp , highest_level = highest
340+ t , "torque" , temp , highest_level = highest , flexible = flexible
328341 )
329342 return EntropyPair (trans = float (s_trans ), rot = float (s_rot ))
330343
@@ -334,6 +347,7 @@ def _compute_ft_entropy(
334347 ve : VibrationalEntropy ,
335348 temp : float ,
336349 ftmat : Any ,
350+ flexible : int ,
337351 ) -> EntropyPair :
338352 """Compute vibrational entropy from a combined force-torque covariance matrix.
339353
@@ -359,10 +373,10 @@ def _compute_ft_entropy(
359373 return EntropyPair (trans = 0.0 , rot = 0.0 )
360374
361375 s_trans = ve .vibrational_entropy_calculation (
362- ft , "forcetorqueTRANS" , temp , highest_level = True
376+ ft , "forcetorqueTRANS" , temp , highest_level = True , flexible = flexible
363377 )
364378 s_rot = ve .vibrational_entropy_calculation (
365- ft , "forcetorqueROT" , temp , highest_level = True
379+ ft , "forcetorqueROT" , temp , highest_level = True , flexible = flexible
366380 )
367381 return EntropyPair (trans = float (s_trans ), rot = float (s_rot ))
368382
0 commit comments