44TODO: remove code duplication and commented code
55"""
66
7- import decimal as dc
87import re
98import warnings
109
@@ -84,7 +83,7 @@ def prob_op_within_trustinterval(
8483
8584
8685# quality of molecule fragments
87- def get_fragments (mapping_dict : dict ):
86+ def get_fragments (mapping_dict : dict ) -> dict :
8887 fragments = {}
8988
9089 for key_m , value in mapping_dict .items ():
@@ -124,7 +123,7 @@ def evaluated_percentage(fragments, exp_op_data):
124123 for key , value in exp_op_data .items ():
125124 if key .split (" " )[0 ] in fragments [fragment_key ]: # check if atom belongs to the fragment
126125 fragment_size += 1
127- if not np .isnan (value [0 ][ 0 ] ):
126+ if not np .isnan (value [0 ]):
128127 count_value += 1
129128 if fragment_size != 0 :
130129 frag_percentage [fragment_key ] = count_value / fragment_size
@@ -137,7 +136,7 @@ def evaluated_percentage(fragments, exp_op_data):
137136 return frag_percentage
138137
139138
140- def fragmentQuality (fragments , exp_op_data , sim_op_data ):
139+ def fragmentQuality (fragments : dict , exp_op_data : dict , sim_op_data : dict ):
141140 # depends on the experiment file what fragments are in this dictionary
142141 p_F = evaluated_percentage (fragments , exp_op_data )
143142 exp_error = 0.02
@@ -156,8 +155,8 @@ def fragmentQuality(fragments, exp_op_data, sim_op_data):
156155 else :
157156 if p_F [fragment_key ] != 0 :
158157 for key_exp , value_exp in exp_op_data .items ():
159- if key_exp .split ()[0 ] in fragments [fragment_key ] and not np .isnan (value_exp [0 ][ 0 ] ):
160- OP_exp = value_exp [0 ][ 0 ]
158+ if key_exp .split ()[0 ] in fragments [fragment_key ] and not np .isnan (value_exp [0 ]):
159+ OP_exp = value_exp [0 ]
161160 try :
162161 OP_sim = sim_op_data [key_exp ][0 ]
163162 except (KeyError , TypeError ):
@@ -242,7 +241,7 @@ def fragmentQualityAvg(
242241
243242
244243# fragments is different for each lipid ---> need to make individual dictionaries
245- def systemQuality (system_fragment_qualities , simulation ):
244+ def systemQuality (system_fragment_qualities , simulation : QualSimulation ):
246245 system_dict = {}
247246 lipid_dict = {}
248247 w_nan = []
@@ -251,7 +250,7 @@ def systemQuality(system_fragment_qualities, simulation):
251250 # copy keys to new dictionary
252251 lipid_dict = dict .fromkeys (system_fragment_qualities [lipid ].keys (), 0 )
253252
254- w = simulation .molar_fraction ( lipid )
253+ w = simulation .membrane_composition ( basis = "molar" )[ lipid ]
255254
256255 for key , value in system_fragment_qualities [lipid ].items ():
257256 if not np .isnan (value ):
0 commit comments