@@ -56,13 +56,17 @@ def dataclass_from_dict(klass, d):
56
56
# from: https://stackoverflow.com/a/54769644/4295016
57
57
try :
58
58
fieldtypes = {f .name : f .type for f in dataclasses .fields (klass )}
59
- return klass (** {f : dataclass_from_dict (fieldtypes [f ], d [f ]) for f in d })
60
59
except TypeError as e :
60
+ ALLOWED_PASSTHROUGH_TYPES = (int , float , str , bool )
61
+ if type (d ) in ALLOWED_PASSTHROUGH_TYPES :
62
+ return d
63
+
61
64
if "must be called with a dataclass type or instance" in str (e ):
62
65
return d
63
66
except Exception as e :
64
67
raise KeyError (f"Could not convert to { klass } because { e } " ) from e
65
68
69
+ return klass (** {f : dataclass_from_dict (fieldtypes [f ], d [f ]) for f in d })
66
70
67
71
def infinite_colour_loop ():
68
72
options = ["#ff0000" , "#00ff00" , "#0000ff" ]
@@ -150,14 +154,12 @@ class MainScoreElements:
150
154
ms2_lazyscore : list [float ]
151
155
ms2_lazyscore_vs_baseline : list [float ]
152
156
ref_time_ms : list [int ]
153
- # ms1_ms2_correlation: list[float]
154
- cocoscore : list [float ]
155
157
ms2_lazyscore_vs_baseline_std : float
156
158
157
159
def plot (self , min_rt_ms , max_rt_ms , vlines_ms : list [int ] | None = None ):
158
160
# Make a plot grid, where each row is a different score element
159
161
# but all share the same retention time axis
160
- fig , ax = plt .subplots (nrows = 3 , ncols = 3 , figsize = (10 , 12 ))
162
+ fig , ax = plt .subplots (nrows = 2 , ncols = 3 , figsize = (10 , 12 ))
161
163
162
164
rt_use = np .array (self .ref_time_ms )
163
165
ranges = np .searchsorted (rt_use , [min_rt_ms , max_rt_ms ])
@@ -177,9 +179,6 @@ def plot(self, min_rt_ms, max_rt_ms, vlines_ms: list[int] | None = None):
177
179
ax [1 , 2 ].plot (rt_plot , self .ms2_lazyscore [ranges [0 ] : ranges [1 ]])
178
180
ax [1 , 2 ].set_title ("MS2 LazyScore" )
179
181
180
- ax [2 , 0 ].plot (rt_plot , self .cocoscore [ranges [0 ] : ranges [1 ]])
181
- ax [2 , 0 ].set_title ("CoCoScore" )
182
-
183
182
# ax[2, 0].plot(rt_plot, self.ms2_lazyscore_vs_baseline_std[ranges[0] : ranges[1]])
184
183
# ax[2, 0].set_title("MS2 LazyScore Baseline STD")
185
184
@@ -204,9 +203,6 @@ def plot(self, min_rt_ms, max_rt_ms, vlines_ms: list[int] | None = None):
204
203
ax [1 , 2 ].axvline (
205
204
x = vlines_minutes [i ], color = "k" , linestyle = "--" , alpha = 0.5
206
205
)
207
- ax [2 , 0 ].axvline (
208
- x = vlines_minutes [i ], color = "k" , linestyle = "--" , alpha = 0.5
209
- )
210
206
211
207
for i in range (2 ):
212
208
for j in range (3 ):
@@ -268,9 +264,6 @@ class SearchResults:
268
264
ms2_inten_ratio_5 : float
269
265
ms2_inten_ratio_6 : float
270
266
271
- # ms1_ms2_correlation: float
272
- cocoscore : float
273
-
274
267
delta_ms1_ms2_mobility : float
275
268
sq_delta_ms1_ms2_mobility : float
276
269
0 commit comments