@@ -94,9 +94,15 @@ def __init__(
9494 def execute (self ) -> None :
9595 """Run the full entropy workflow and emit results.
9696
97- This method orchestrates the complete pipeline, populates shared data,
98- and triggers the DAG/graph executions. Final results are logged and saved
99- via `ResultsReporter`.
97+ This orchestrates the complete entropy pipeline:
98+ 1. Build trajectory slice.
99+ 2. Apply atom selection to create a reduced universe.
100+ 3. Detect hierarchy levels.
101+ 4. Group molecules.
102+ 5. Split groups into water and non-water.
103+ 6. Optionally compute water entropy (only if solute exists).
104+ 7. Run level DAG and entropy graph.
105+ 8. Finalize and persist results.
100106 """
101107 traj = self ._build_trajectory_slice ()
102108 console .print (
@@ -110,9 +116,11 @@ def execute(self) -> None:
110116 reduced_universe , self ._args .grouping
111117 )
112118
113- nonwater_groups , water_groups = self ._split_water_groups (groups )
119+ nonwater_groups , water_groups = self ._split_water_groups (
120+ reduced_universe , groups
121+ )
114122
115- if self ._args .water_entropy and water_groups :
123+ if self ._args .water_entropy and water_groups and nonwater_groups :
116124 self ._compute_water_entropy (traj , water_groups )
117125 else :
118126 nonwater_groups .update (water_groups )
@@ -255,25 +263,40 @@ def _detect_levels(self, reduced_universe: Any) -> Any:
255263 return levels
256264
257265 def _split_water_groups (
258- self , groups : Mapping [int , Any ]
266+ self ,
267+ universe : Any ,
268+ groups : Mapping [int , Any ],
259269 ) -> tuple [dict [int , Any ], dict [int , Any ]]:
260270 """Partition molecule groups into water and non-water groups.
261271
272+ This method identifies which molecule groups correspond to water
273+ molecules based on residue membership.
274+
262275 Args:
263- groups: Mapping of group id -> molecule ids.
276+ universe (Any):
277+ The MDAnalysis Universe used to build the molecule groups
278+ (typically the reduced_universe).
279+ groups (Mapping[int, Any]):
280+ Mapping of group_id -> list of molecule fragment indices.
264281
265282 Returns:
266- Tuple of (nonwater_groups, water_groups).
283+ Tuple[Dict[int, Any], Dict[int, Any]]:
284+ A tuple containing:
285+
286+ - nonwater_groups:
287+ Mapping of group_id -> molecule ids that are NOT water.
288+ - water_groups:
289+ Mapping of group_id -> molecule ids that contain water.
267290 """
268- water_atoms = self . _universe .select_atoms ("water" )
291+ water_atoms = universe .select_atoms ("water" )
269292 water_resids = {res .resid for res in water_atoms .residues }
270293
271294 water_groups = {
272295 gid : mol_ids
273296 for gid , mol_ids in groups .items ()
274297 if any (
275298 res .resid in water_resids
276- for mol in [self . _universe .atoms .fragments [i ] for i in mol_ids ]
299+ for mol in [universe .atoms .fragments [i ] for i in mol_ids ]
277300 for res in mol .residues
278301 )
279302 }
@@ -294,10 +317,10 @@ def _compute_water_entropy(
294317 if not water_groups or not self ._args .water_entropy :
295318 return
296319
297- water_entropy = WaterEntropy (self ._args )
320+ water_entropy = WaterEntropy (self ._args , self . _reporter )
298321
299322 for group_id in water_groups .keys ():
300- water_entropy ._calculate_water_entropy (
323+ water_entropy .calculate_and_log (
301324 universe = self ._universe ,
302325 start = traj .start ,
303326 end = traj .end ,
0 commit comments