@@ -292,22 +292,17 @@ def system_quality_gather_lipids(self) -> dict:
292292
293293 :return: dictionary of type {macrofragment: quality} where macrofragmetn is headgroup|tails|total.
294294 """
295- system_fragment_qualities = self .lipid_fragment_qualities
296295 molar_composition = self ._sim .membrane_composition (basis = "molar" )
297296
298297 system_dict = {}
299298 lipid_dict = {}
300- w_nan = []
301299
302- for lname , lqual in system_fragment_qualities .items ():
300+ for lname , lqual in self . lipid_fragment_qualities .items ():
303301 lipid_dict = dict .fromkeys (lqual .keys (), 0 )
304302 w = molar_composition [lname ]
305303 for key , value in lqual .items ():
306304 if not np .isnan (value ):
307305 lipid_dict [key ] += w * value
308- else :
309- # save 1 - w of a lipid into a list if the fragment quality is nan
310- w_nan .append (1 - w )
311306 system_dict [lname ] = lipid_dict
312307
313308 system_quality = {}
@@ -316,22 +311,34 @@ def system_quality_gather_lipids(self) -> dict:
316311 tails = 0
317312 total = 0
318313
319- for ldict in system_dict .values ():
314+ penalty = {"headgroup" : 1.0 , "tails" : 1.0 , "total" : 1.0 }
315+ for lname , ldict in system_dict .items ():
316+ lip_total = 0
317+ lip_head = 0
318+ lip_tails = 0
320319 for key , value in ldict .items ():
321320 if key == "total" :
322- total += value
321+ lip_total += value
323322 elif key == "headgroup" :
324- headgroup += value
323+ lip_head += value
325324 elif key in {"sn-1" , "sn-2" }:
326- tails += value / 2
325+ lip_tails += value / 2
327326 else :
328- tails += value # everything non head is tail??
329-
330- penalty = np .prod (w_nan ) if w_nan else 1
331-
332- system_quality ["headgroup" ] = headgroup * penalty
333- system_quality ["tails" ] = tails * penalty
334- system_quality ["total" ] = total * penalty
327+ lip_tails += value # everything non head is tail??
328+ w = molar_composition [lname ]
329+ if lip_total == 0 :
330+ penalty ["total" ] *= (1 - w )
331+ total += lip_total
332+ if lip_head == 0 :
333+ penalty ["headgroup" ] *= (1 - w )
334+ headgroup += lip_head
335+ if lip_tails == 0 :
336+ penalty ["tails" ] *= (1 - w )
337+ tails += lip_tails
338+
339+ system_quality ["headgroup" ] = headgroup * penalty ["headgroup" ]
340+ system_quality ["tails" ] = tails * penalty ["tails" ]
341+ system_quality ["total" ] = total * penalty ["total" ]
335342
336343 return system_quality
337344
0 commit comments