corems.encapsulation.factory.parameters
1import dataclasses 2 3from corems.encapsulation.factory.processingSetting import ( 4 LiquidChromatographSetting, 5 MolecularFormulaSearchSettings, 6 TransientSetting, 7 MassSpecPeakSetting, 8 MassSpectrumSetting, 9) 10from corems.encapsulation.factory.processingSetting import ( 11 CompoundSearchSettings, 12 GasChromatographSetting, 13) 14from corems.encapsulation.factory.processingSetting import DataInputSetting 15 16def hush_output(): 17 """Toggle all the verbose_processing flags to False on the MSParameters, GCMSParameters and LCMSParameters classes""" 18 MSParameters.molecular_search.verbose_processing = False 19 MSParameters.mass_spectrum.verbose_processing = False 20 GCMSParameters.gc_ms.verbose_processing = False 21 LCMSParameters.lc_ms.verbose_processing = False 22 23def reset_ms_parameters(): 24 """Reset the MSParameter class to the default values""" 25 MSParameters.molecular_search = MolecularFormulaSearchSettings() 26 MSParameters.transient = TransientSetting() 27 MSParameters.mass_spectrum = MassSpectrumSetting() 28 MSParameters.ms_peak = MassSpecPeakSetting() 29 MSParameters.data_input = DataInputSetting() 30 31 32def reset_gcms_parameters(): 33 """Reset the GCMSParameters class to the default values""" 34 GCMSParameters.molecular_search = CompoundSearchSettings() 35 GCMSParameters.gc_ms = GasChromatographSetting() 36 37 38def reset_lcms_parameters(): 39 """Reset the LCMSParameters class to the default values""" 40 reset_ms_parameters() 41 LCMSParameters.lc_ms = LiquidChromatographSetting() 42 43 44class MSParameters: 45 """MSParameters class is used to store the parameters used for the processing of the mass spectrum 46 47 Each attibute is a class that contains the parameters for the processing of the mass spectrum, see the corems.encapsulation.factory.processingSetting module for more details. 48 49 Parameters 50 ---------- 51 use_defaults: bool, optional 52 if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False. 53 54 Attributes 55 ----------- 56 molecular_search: MolecularFormulaSearchSettings 57 MolecularFormulaSearchSettings object 58 transient: TransientSetting 59 TransientSetting object 60 mass_spectrum: MassSpectrumSetting 61 MassSpectrumSetting object 62 ms_peak: MassSpecPeakSetting 63 MassSpecPeakSetting object 64 data_input: DataInputSetting 65 DataInputSetting object 66 67 Notes 68 ----- 69 One can use the use_defaults parameter to reset the parameters to the default values. 70 Alternatively, to use the current values - modify the class's contents before instantiating the class. 71 """ 72 73 molecular_search = MolecularFormulaSearchSettings() 74 transient = TransientSetting() 75 mass_spectrum = MassSpectrumSetting() 76 ms_peak = MassSpecPeakSetting() 77 data_input = DataInputSetting() 78 79 def __init__(self, use_defaults=False) -> None: 80 if not use_defaults: 81 self.molecular_search = dataclasses.replace(MSParameters.molecular_search) 82 self.transient = dataclasses.replace(MSParameters.transient) 83 self.mass_spectrum = dataclasses.replace(MSParameters.mass_spectrum) 84 self.ms_peak = dataclasses.replace(MSParameters.ms_peak) 85 self.data_input = dataclasses.replace(MSParameters.data_input) 86 else: 87 self.molecular_search = MolecularFormulaSearchSettings() 88 self.transient = TransientSetting() 89 self.mass_spectrum = MassSpectrumSetting() 90 self.ms_peak = MassSpecPeakSetting() 91 self.data_input = DataInputSetting() 92 93 def copy(self): 94 """Create a copy of the MSParameters object""" 95 new_ms_parameters = MSParameters() 96 new_ms_parameters.molecular_search = dataclasses.replace(self.molecular_search) 97 new_ms_parameters.transient = dataclasses.replace(self.transient) 98 new_ms_parameters.mass_spectrum = dataclasses.replace(self.mass_spectrum) 99 new_ms_parameters.ms_peak = dataclasses.replace(self.ms_peak) 100 new_ms_parameters.data_input = dataclasses.replace(self.data_input) 101 102 return new_ms_parameters 103 104 def print(self): 105 """Print the MSParameters object""" 106 for k, v in self.__dict__.items(): 107 print(k, type(v).__name__) 108 109 for k2, v2 in v.__dict__.items(): 110 print(" {}: {}".format(k2, v2)) 111 112 def __eq__(self, value: object) -> bool: 113 # Check that the object is of the same type 114 if not isinstance(value, MSParameters): 115 return False 116 equality_check = [] 117 equality_check.append(self.molecular_search == value.molecular_search) 118 equality_check.append(self.transient == value.transient) 119 equality_check.append(self.mass_spectrum == value.mass_spectrum) 120 equality_check.append(self.ms_peak == value.ms_peak) 121 equality_check.append(self.data_input == value.data_input) 122 123 return all(equality_check) 124 125 126class GCMSParameters: 127 """GCMSParameters class is used to store the parameters used for the processing of the gas chromatograph mass spectrum 128 129 Each attibute is a class that contains the parameters for the processing of the data, see the corems.encapsulation.factory.processingSetting module for more details. 130 131 Parameters 132 ---------- 133 use_defaults: bool, optional 134 if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False. 135 136 Attributes 137 ----------- 138 molecular_search: MolecularFormulaSearchSettings 139 MolecularFormulaSearchSettings object 140 gc_ms: GasChromatographSetting 141 GasChromatographSetting object 142 143 Notes 144 ----- 145 One can use the use_defaults parameter to reset the parameters to the default values. 146 Alternatively, to use the current values - modify the class's contents before instantiating the class. 147 """ 148 149 molecular_search = CompoundSearchSettings() 150 gc_ms = GasChromatographSetting() 151 152 def __init__(self, use_defaults=False) -> None: 153 if not use_defaults: 154 self.molecular_search = dataclasses.replace(GCMSParameters.molecular_search) 155 self.gc_ms = dataclasses.replace(GCMSParameters.gc_ms) 156 else: 157 self.molecular_search = CompoundSearchSettings() 158 self.gc_ms = GasChromatographSetting() 159 160 def copy(self): 161 """Create a copy of the GCMSParameters object""" 162 new_gcms_parameters = GCMSParameters() 163 new_gcms_parameters.molecular_search = dataclasses.replace( 164 self.molecular_search 165 ) 166 new_gcms_parameters.gc_ms = dataclasses.replace(self.gc_ms) 167 168 return new_gcms_parameters 169 170 def __eq__(self, value: object) -> bool: 171 # Check that the object is of the same type 172 if not isinstance(value, GCMSParameters): 173 return False 174 equality_check = [] 175 equality_check.append(self.molecular_search == value.molecular_search) 176 equality_check.append(self.gc_ms == value.gc_ms) 177 178 return all(equality_check) 179 180 def print(self): 181 """Print the GCMSParameters object""" 182 for k, v in self.__dict__.items(): 183 print(k, type(v).__name__) 184 185 for k2, v2 in v.__dict__.items(): 186 print(" {}: {}".format(k2, v2)) 187 188 189class LCMSParameters: 190 """LCMSParameters class is used to store the parameters used for the processing of the liquid chromatograph mass spectrum 191 192 Each attibute is a class that contains the parameters for the processing of the data, see the corems.encapsulation.factory.processingSetting module for more details. 193 194 Parameters 195 ---------- 196 use_defaults: bool, optional 197 if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False. 198 199 Attributes 200 ----------- 201 lc_ms: LiquidChromatographSetting 202 LiquidChromatographSetting object 203 mass_spectrum: dict 204 dictionary with the mass spectrum parameters for ms1 and ms2, each value is a MSParameters object 205 206 Notes 207 ----- 208 One can use the use_defaults parameter to reset the parameters to the default values. 209 Alternatively, to use the current values - modify the class's contents before instantiating the class. 210 """ 211 212 lc_ms = LiquidChromatographSetting() 213 mass_spectrum = {"ms1": MSParameters(), "ms2": MSParameters()} 214 215 def __init__(self, use_defaults=False) -> None: 216 if not use_defaults: 217 self.lc_ms = dataclasses.replace(LCMSParameters.lc_ms) 218 self.mass_spectrum = { 219 "ms1": MSParameters(use_defaults=False), 220 "ms2": MSParameters(use_defaults=False), 221 } 222 else: 223 self.lc_ms = LiquidChromatographSetting() 224 self.mass_spectrum = { 225 "ms1": MSParameters(use_defaults=True), 226 "ms2": MSParameters(use_defaults=True), 227 } 228 229 def copy(self): 230 """Create a copy of the LCMSParameters object""" 231 new_lcms_parameters = LCMSParameters() 232 new_lcms_parameters.lc_ms = dataclasses.replace(self.lc_ms) 233 for key in self.mass_spectrum: 234 new_lcms_parameters.mass_spectrum[key] = self.mass_spectrum[key].copy() 235 236 return new_lcms_parameters 237 238 def __eq__(self, value: object) -> bool: 239 # Check that the object is of the same type 240 if not isinstance(value, LCMSParameters): 241 return False 242 equality_check = [] 243 equality_check.append(self.lc_ms == value.lc_ms) 244 245 # Check that the mass_spectrum dictionary has the same keys 246 equality_check.append(self.mass_spectrum.keys() == value.mass_spectrum.keys()) 247 248 # Check that the values of the mass_spectrum dictionary are equal 249 for key in self.mass_spectrum.keys(): 250 equality_check.append( 251 self.mass_spectrum[key].mass_spectrum 252 == value.mass_spectrum[key].mass_spectrum 253 ) 254 equality_check.append( 255 self.mass_spectrum[key].ms_peak == value.mass_spectrum[key].ms_peak 256 ) 257 equality_check.append( 258 self.mass_spectrum[key].molecular_search 259 == value.mass_spectrum[key].molecular_search 260 ) 261 equality_check.append( 262 self.mass_spectrum[key].transient == value.mass_spectrum[key].transient 263 ) 264 equality_check.append( 265 self.mass_spectrum[key].data_input 266 == value.mass_spectrum[key].data_input 267 ) 268 269 return all(equality_check) 270 271 def print(self): 272 """Print the LCMSParameters object""" 273 # Print the lcms paramters 274 for k, v in self.__dict__.items(): 275 if k == "lc_ms": 276 print(k, type(v).__name__) 277 278 for k2, v2 in self.mass_spectrum.items(): 279 """Print the MSParameters object""" 280 for k3, v3 in v2.__dict__.items(): 281 print("{} - {}: {}".format(k2, k3, type(v3).__name__)) 282 283 for k4, v4 in v3.__dict__.items(): 284 print(" {}: {}".format(k4, v4)) 285 286 287def default_parameters(file_location): # pragma: no cover 288 """Generate parameters dictionary with the default parameters for data processing 289 To gather parameters from instrument data during the data parsing step, a parameters dictionary with the default parameters needs to be generated. 290 This dictionary acts as a placeholder and is later used as an argument for all the class constructor methods during instantiation. 291 The data gathered from the instrument is added to the class properties. 292 293 Parameters 294 ---------- 295 file_location: str 296 path to the file 297 298 Returns 299 ------- 300 parameters: dict 301 dictionary with the default parameters for data processing 302 """ 303 304 parameters = dict() 305 306 parameters["Aterm"] = 0 307 308 parameters["Bterm"] = 0 309 310 parameters["Cterm"] = 0 311 312 parameters["exc_high_freq"] = 0 313 314 parameters["exc_low_freq"] = 0 315 316 parameters["mw_low"] = 0 317 318 parameters["mw_high"] = 0 319 320 parameters["qpd_enabled"] = 0 321 322 parameters["bandwidth"] = 0 323 324 parameters["analyzer"] = "Unknown" 325 326 parameters["acquisition_time"] = None 327 328 parameters["instrument_label"] = "Unknown" 329 330 parameters["sample_name"] = "Unknown" 331 332 parameters["number_data_points"] = 0 333 334 parameters["polarity"] = "Unknown" 335 336 parameters["filename_path"] = str(file_location) 337 338 """scan_number and rt will be need to lc ms""" 339 340 parameters["mobility_scan"] = 0 341 342 parameters["mobility_rt"] = 0 343 344 parameters["scan_number"] = 0 345 346 parameters["rt"] = 0 347 348 return parameters
17def hush_output(): 18 """Toggle all the verbose_processing flags to False on the MSParameters, GCMSParameters and LCMSParameters classes""" 19 MSParameters.molecular_search.verbose_processing = False 20 MSParameters.mass_spectrum.verbose_processing = False 21 GCMSParameters.gc_ms.verbose_processing = False 22 LCMSParameters.lc_ms.verbose_processing = False
Toggle all the verbose_processing flags to False on the MSParameters, GCMSParameters and LCMSParameters classes
24def reset_ms_parameters(): 25 """Reset the MSParameter class to the default values""" 26 MSParameters.molecular_search = MolecularFormulaSearchSettings() 27 MSParameters.transient = TransientSetting() 28 MSParameters.mass_spectrum = MassSpectrumSetting() 29 MSParameters.ms_peak = MassSpecPeakSetting() 30 MSParameters.data_input = DataInputSetting()
Reset the MSParameter class to the default values
33def reset_gcms_parameters(): 34 """Reset the GCMSParameters class to the default values""" 35 GCMSParameters.molecular_search = CompoundSearchSettings() 36 GCMSParameters.gc_ms = GasChromatographSetting()
Reset the GCMSParameters class to the default values
39def reset_lcms_parameters(): 40 """Reset the LCMSParameters class to the default values""" 41 reset_ms_parameters() 42 LCMSParameters.lc_ms = LiquidChromatographSetting()
Reset the LCMSParameters class to the default values
45class MSParameters: 46 """MSParameters class is used to store the parameters used for the processing of the mass spectrum 47 48 Each attibute is a class that contains the parameters for the processing of the mass spectrum, see the corems.encapsulation.factory.processingSetting module for more details. 49 50 Parameters 51 ---------- 52 use_defaults: bool, optional 53 if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False. 54 55 Attributes 56 ----------- 57 molecular_search: MolecularFormulaSearchSettings 58 MolecularFormulaSearchSettings object 59 transient: TransientSetting 60 TransientSetting object 61 mass_spectrum: MassSpectrumSetting 62 MassSpectrumSetting object 63 ms_peak: MassSpecPeakSetting 64 MassSpecPeakSetting object 65 data_input: DataInputSetting 66 DataInputSetting object 67 68 Notes 69 ----- 70 One can use the use_defaults parameter to reset the parameters to the default values. 71 Alternatively, to use the current values - modify the class's contents before instantiating the class. 72 """ 73 74 molecular_search = MolecularFormulaSearchSettings() 75 transient = TransientSetting() 76 mass_spectrum = MassSpectrumSetting() 77 ms_peak = MassSpecPeakSetting() 78 data_input = DataInputSetting() 79 80 def __init__(self, use_defaults=False) -> None: 81 if not use_defaults: 82 self.molecular_search = dataclasses.replace(MSParameters.molecular_search) 83 self.transient = dataclasses.replace(MSParameters.transient) 84 self.mass_spectrum = dataclasses.replace(MSParameters.mass_spectrum) 85 self.ms_peak = dataclasses.replace(MSParameters.ms_peak) 86 self.data_input = dataclasses.replace(MSParameters.data_input) 87 else: 88 self.molecular_search = MolecularFormulaSearchSettings() 89 self.transient = TransientSetting() 90 self.mass_spectrum = MassSpectrumSetting() 91 self.ms_peak = MassSpecPeakSetting() 92 self.data_input = DataInputSetting() 93 94 def copy(self): 95 """Create a copy of the MSParameters object""" 96 new_ms_parameters = MSParameters() 97 new_ms_parameters.molecular_search = dataclasses.replace(self.molecular_search) 98 new_ms_parameters.transient = dataclasses.replace(self.transient) 99 new_ms_parameters.mass_spectrum = dataclasses.replace(self.mass_spectrum) 100 new_ms_parameters.ms_peak = dataclasses.replace(self.ms_peak) 101 new_ms_parameters.data_input = dataclasses.replace(self.data_input) 102 103 return new_ms_parameters 104 105 def print(self): 106 """Print the MSParameters object""" 107 for k, v in self.__dict__.items(): 108 print(k, type(v).__name__) 109 110 for k2, v2 in v.__dict__.items(): 111 print(" {}: {}".format(k2, v2)) 112 113 def __eq__(self, value: object) -> bool: 114 # Check that the object is of the same type 115 if not isinstance(value, MSParameters): 116 return False 117 equality_check = [] 118 equality_check.append(self.molecular_search == value.molecular_search) 119 equality_check.append(self.transient == value.transient) 120 equality_check.append(self.mass_spectrum == value.mass_spectrum) 121 equality_check.append(self.ms_peak == value.ms_peak) 122 equality_check.append(self.data_input == value.data_input) 123 124 return all(equality_check)
MSParameters class is used to store the parameters used for the processing of the mass spectrum
Each attibute is a class that contains the parameters for the processing of the mass spectrum, see the corems.encapsulation.factory.processingSetting module for more details.
Parameters
- use_defaults (bool, optional): if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False.
Attributes
- molecular_search (MolecularFormulaSearchSettings): MolecularFormulaSearchSettings object
- transient (TransientSetting): TransientSetting object
- mass_spectrum (MassSpectrumSetting): MassSpectrumSetting object
- ms_peak (MassSpecPeakSetting): MassSpecPeakSetting object
- data_input (DataInputSetting): DataInputSetting object
Notes
One can use the use_defaults parameter to reset the parameters to the default values. Alternatively, to use the current values - modify the class's contents before instantiating the class.
80 def __init__(self, use_defaults=False) -> None: 81 if not use_defaults: 82 self.molecular_search = dataclasses.replace(MSParameters.molecular_search) 83 self.transient = dataclasses.replace(MSParameters.transient) 84 self.mass_spectrum = dataclasses.replace(MSParameters.mass_spectrum) 85 self.ms_peak = dataclasses.replace(MSParameters.ms_peak) 86 self.data_input = dataclasses.replace(MSParameters.data_input) 87 else: 88 self.molecular_search = MolecularFormulaSearchSettings() 89 self.transient = TransientSetting() 90 self.mass_spectrum = MassSpectrumSetting() 91 self.ms_peak = MassSpecPeakSetting() 92 self.data_input = DataInputSetting()
94 def copy(self): 95 """Create a copy of the MSParameters object""" 96 new_ms_parameters = MSParameters() 97 new_ms_parameters.molecular_search = dataclasses.replace(self.molecular_search) 98 new_ms_parameters.transient = dataclasses.replace(self.transient) 99 new_ms_parameters.mass_spectrum = dataclasses.replace(self.mass_spectrum) 100 new_ms_parameters.ms_peak = dataclasses.replace(self.ms_peak) 101 new_ms_parameters.data_input = dataclasses.replace(self.data_input) 102 103 return new_ms_parameters
Create a copy of the MSParameters object
127class GCMSParameters: 128 """GCMSParameters class is used to store the parameters used for the processing of the gas chromatograph mass spectrum 129 130 Each attibute is a class that contains the parameters for the processing of the data, see the corems.encapsulation.factory.processingSetting module for more details. 131 132 Parameters 133 ---------- 134 use_defaults: bool, optional 135 if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False. 136 137 Attributes 138 ----------- 139 molecular_search: MolecularFormulaSearchSettings 140 MolecularFormulaSearchSettings object 141 gc_ms: GasChromatographSetting 142 GasChromatographSetting object 143 144 Notes 145 ----- 146 One can use the use_defaults parameter to reset the parameters to the default values. 147 Alternatively, to use the current values - modify the class's contents before instantiating the class. 148 """ 149 150 molecular_search = CompoundSearchSettings() 151 gc_ms = GasChromatographSetting() 152 153 def __init__(self, use_defaults=False) -> None: 154 if not use_defaults: 155 self.molecular_search = dataclasses.replace(GCMSParameters.molecular_search) 156 self.gc_ms = dataclasses.replace(GCMSParameters.gc_ms) 157 else: 158 self.molecular_search = CompoundSearchSettings() 159 self.gc_ms = GasChromatographSetting() 160 161 def copy(self): 162 """Create a copy of the GCMSParameters object""" 163 new_gcms_parameters = GCMSParameters() 164 new_gcms_parameters.molecular_search = dataclasses.replace( 165 self.molecular_search 166 ) 167 new_gcms_parameters.gc_ms = dataclasses.replace(self.gc_ms) 168 169 return new_gcms_parameters 170 171 def __eq__(self, value: object) -> bool: 172 # Check that the object is of the same type 173 if not isinstance(value, GCMSParameters): 174 return False 175 equality_check = [] 176 equality_check.append(self.molecular_search == value.molecular_search) 177 equality_check.append(self.gc_ms == value.gc_ms) 178 179 return all(equality_check) 180 181 def print(self): 182 """Print the GCMSParameters object""" 183 for k, v in self.__dict__.items(): 184 print(k, type(v).__name__) 185 186 for k2, v2 in v.__dict__.items(): 187 print(" {}: {}".format(k2, v2))
GCMSParameters class is used to store the parameters used for the processing of the gas chromatograph mass spectrum
Each attibute is a class that contains the parameters for the processing of the data, see the corems.encapsulation.factory.processingSetting module for more details.
Parameters
- use_defaults (bool, optional): if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False.
Attributes
- molecular_search (MolecularFormulaSearchSettings): MolecularFormulaSearchSettings object
- gc_ms (GasChromatographSetting): GasChromatographSetting object
Notes
One can use the use_defaults parameter to reset the parameters to the default values. Alternatively, to use the current values - modify the class's contents before instantiating the class.
153 def __init__(self, use_defaults=False) -> None: 154 if not use_defaults: 155 self.molecular_search = dataclasses.replace(GCMSParameters.molecular_search) 156 self.gc_ms = dataclasses.replace(GCMSParameters.gc_ms) 157 else: 158 self.molecular_search = CompoundSearchSettings() 159 self.gc_ms = GasChromatographSetting()
161 def copy(self): 162 """Create a copy of the GCMSParameters object""" 163 new_gcms_parameters = GCMSParameters() 164 new_gcms_parameters.molecular_search = dataclasses.replace( 165 self.molecular_search 166 ) 167 new_gcms_parameters.gc_ms = dataclasses.replace(self.gc_ms) 168 169 return new_gcms_parameters
Create a copy of the GCMSParameters object
190class LCMSParameters: 191 """LCMSParameters class is used to store the parameters used for the processing of the liquid chromatograph mass spectrum 192 193 Each attibute is a class that contains the parameters for the processing of the data, see the corems.encapsulation.factory.processingSetting module for more details. 194 195 Parameters 196 ---------- 197 use_defaults: bool, optional 198 if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False. 199 200 Attributes 201 ----------- 202 lc_ms: LiquidChromatographSetting 203 LiquidChromatographSetting object 204 mass_spectrum: dict 205 dictionary with the mass spectrum parameters for ms1 and ms2, each value is a MSParameters object 206 207 Notes 208 ----- 209 One can use the use_defaults parameter to reset the parameters to the default values. 210 Alternatively, to use the current values - modify the class's contents before instantiating the class. 211 """ 212 213 lc_ms = LiquidChromatographSetting() 214 mass_spectrum = {"ms1": MSParameters(), "ms2": MSParameters()} 215 216 def __init__(self, use_defaults=False) -> None: 217 if not use_defaults: 218 self.lc_ms = dataclasses.replace(LCMSParameters.lc_ms) 219 self.mass_spectrum = { 220 "ms1": MSParameters(use_defaults=False), 221 "ms2": MSParameters(use_defaults=False), 222 } 223 else: 224 self.lc_ms = LiquidChromatographSetting() 225 self.mass_spectrum = { 226 "ms1": MSParameters(use_defaults=True), 227 "ms2": MSParameters(use_defaults=True), 228 } 229 230 def copy(self): 231 """Create a copy of the LCMSParameters object""" 232 new_lcms_parameters = LCMSParameters() 233 new_lcms_parameters.lc_ms = dataclasses.replace(self.lc_ms) 234 for key in self.mass_spectrum: 235 new_lcms_parameters.mass_spectrum[key] = self.mass_spectrum[key].copy() 236 237 return new_lcms_parameters 238 239 def __eq__(self, value: object) -> bool: 240 # Check that the object is of the same type 241 if not isinstance(value, LCMSParameters): 242 return False 243 equality_check = [] 244 equality_check.append(self.lc_ms == value.lc_ms) 245 246 # Check that the mass_spectrum dictionary has the same keys 247 equality_check.append(self.mass_spectrum.keys() == value.mass_spectrum.keys()) 248 249 # Check that the values of the mass_spectrum dictionary are equal 250 for key in self.mass_spectrum.keys(): 251 equality_check.append( 252 self.mass_spectrum[key].mass_spectrum 253 == value.mass_spectrum[key].mass_spectrum 254 ) 255 equality_check.append( 256 self.mass_spectrum[key].ms_peak == value.mass_spectrum[key].ms_peak 257 ) 258 equality_check.append( 259 self.mass_spectrum[key].molecular_search 260 == value.mass_spectrum[key].molecular_search 261 ) 262 equality_check.append( 263 self.mass_spectrum[key].transient == value.mass_spectrum[key].transient 264 ) 265 equality_check.append( 266 self.mass_spectrum[key].data_input 267 == value.mass_spectrum[key].data_input 268 ) 269 270 return all(equality_check) 271 272 def print(self): 273 """Print the LCMSParameters object""" 274 # Print the lcms paramters 275 for k, v in self.__dict__.items(): 276 if k == "lc_ms": 277 print(k, type(v).__name__) 278 279 for k2, v2 in self.mass_spectrum.items(): 280 """Print the MSParameters object""" 281 for k3, v3 in v2.__dict__.items(): 282 print("{} - {}: {}".format(k2, k3, type(v3).__name__)) 283 284 for k4, v4 in v3.__dict__.items(): 285 print(" {}: {}".format(k4, v4))
LCMSParameters class is used to store the parameters used for the processing of the liquid chromatograph mass spectrum
Each attibute is a class that contains the parameters for the processing of the data, see the corems.encapsulation.factory.processingSetting module for more details.
Parameters
- use_defaults (bool, optional): if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False.
Attributes
- lc_ms (LiquidChromatographSetting): LiquidChromatographSetting object
- mass_spectrum (dict): dictionary with the mass spectrum parameters for ms1 and ms2, each value is a MSParameters object
Notes
One can use the use_defaults parameter to reset the parameters to the default values. Alternatively, to use the current values - modify the class's contents before instantiating the class.
216 def __init__(self, use_defaults=False) -> None: 217 if not use_defaults: 218 self.lc_ms = dataclasses.replace(LCMSParameters.lc_ms) 219 self.mass_spectrum = { 220 "ms1": MSParameters(use_defaults=False), 221 "ms2": MSParameters(use_defaults=False), 222 } 223 else: 224 self.lc_ms = LiquidChromatographSetting() 225 self.mass_spectrum = { 226 "ms1": MSParameters(use_defaults=True), 227 "ms2": MSParameters(use_defaults=True), 228 }
230 def copy(self): 231 """Create a copy of the LCMSParameters object""" 232 new_lcms_parameters = LCMSParameters() 233 new_lcms_parameters.lc_ms = dataclasses.replace(self.lc_ms) 234 for key in self.mass_spectrum: 235 new_lcms_parameters.mass_spectrum[key] = self.mass_spectrum[key].copy() 236 237 return new_lcms_parameters
Create a copy of the LCMSParameters object
272 def print(self): 273 """Print the LCMSParameters object""" 274 # Print the lcms paramters 275 for k, v in self.__dict__.items(): 276 if k == "lc_ms": 277 print(k, type(v).__name__) 278 279 for k2, v2 in self.mass_spectrum.items(): 280 """Print the MSParameters object""" 281 for k3, v3 in v2.__dict__.items(): 282 print("{} - {}: {}".format(k2, k3, type(v3).__name__)) 283 284 for k4, v4 in v3.__dict__.items(): 285 print(" {}: {}".format(k4, v4))
Print the LCMSParameters object
288def default_parameters(file_location): # pragma: no cover 289 """Generate parameters dictionary with the default parameters for data processing 290 To gather parameters from instrument data during the data parsing step, a parameters dictionary with the default parameters needs to be generated. 291 This dictionary acts as a placeholder and is later used as an argument for all the class constructor methods during instantiation. 292 The data gathered from the instrument is added to the class properties. 293 294 Parameters 295 ---------- 296 file_location: str 297 path to the file 298 299 Returns 300 ------- 301 parameters: dict 302 dictionary with the default parameters for data processing 303 """ 304 305 parameters = dict() 306 307 parameters["Aterm"] = 0 308 309 parameters["Bterm"] = 0 310 311 parameters["Cterm"] = 0 312 313 parameters["exc_high_freq"] = 0 314 315 parameters["exc_low_freq"] = 0 316 317 parameters["mw_low"] = 0 318 319 parameters["mw_high"] = 0 320 321 parameters["qpd_enabled"] = 0 322 323 parameters["bandwidth"] = 0 324 325 parameters["analyzer"] = "Unknown" 326 327 parameters["acquisition_time"] = None 328 329 parameters["instrument_label"] = "Unknown" 330 331 parameters["sample_name"] = "Unknown" 332 333 parameters["number_data_points"] = 0 334 335 parameters["polarity"] = "Unknown" 336 337 parameters["filename_path"] = str(file_location) 338 339 """scan_number and rt will be need to lc ms""" 340 341 parameters["mobility_scan"] = 0 342 343 parameters["mobility_rt"] = 0 344 345 parameters["scan_number"] = 0 346 347 parameters["rt"] = 0 348 349 return parameters
Generate parameters dictionary with the default parameters for data processing To gather parameters from instrument data during the data parsing step, a parameters dictionary with the default parameters needs to be generated. This dictionary acts as a placeholder and is later used as an argument for all the class constructor methods during instantiation. The data gathered from the instrument is added to the class properties.
Parameters
- file_location (str): path to the file
Returns
- parameters (dict): dictionary with the default parameters for data processing