corems.encapsulation.factory.parameters

  1import dataclasses
  2
  3from corems.encapsulation.factory.processingSetting import (
  4    LiquidChromatographSetting,
  5    MolecularFormulaSearchSettings,
  6    TransientSetting,
  7    MassSpecPeakSetting,
  8    MassSpectrumSetting,
  9    LCMSCollectionSettings,
 10)
 11from corems.encapsulation.factory.processingSetting import (
 12    CompoundSearchSettings,
 13    GasChromatographSetting,
 14)
 15from corems.encapsulation.factory.processingSetting import DataInputSetting
 16
 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
 23
 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()
 31
 32
 33def reset_gcms_parameters():
 34    """Reset the GCMSParameters class to the default values"""
 35    GCMSParameters.molecular_search = CompoundSearchSettings()
 36    GCMSParameters.gc_ms = GasChromatographSetting()
 37
 38
 39def reset_lcms_parameters():
 40    """Reset the LCMSParameters class to the default values"""
 41    reset_ms_parameters()
 42    LCMSParameters.lc_ms = LiquidChromatographSetting()
 43
 44
 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)
125
126
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))
188
189
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))
286
287
288class LCMSCollectionParameters:
289    """LCMSCollectionParameters class is used to store the parameters used for the processing of the LCMS collection
290
291    Each attribute is a class that contains the parameters for the processing of the LCMS collection, 
292    see the corems.encapsulation.factory.processingSetting module for more details.
293
294    Parameters
295    ----------
296    use_defaults: bool, optional
297        if True, the class will be instantiated with the default values, otherwise the current values will be used. 
298        Default is False.
299
300    Attributes
301    -----------
302    lcms_collection: LCMSCollectionSettings
303        LCMSCollectionSettings object
304
305    Notes
306    -----
307    One can use the use_defaults parameter to reset the parameters to the default values.
308    Alternatively, to use the current values - modify the class's contents before instantiating the class.
309    """
310    
311    lcms_collection = LCMSCollectionSettings()
312
313    def __init__(self, use_defaults=False) -> None:
314        if not use_defaults:
315            self.lcms_collection = dataclasses.replace(LCMSCollectionParameters.lcms_collection)
316        else:
317            self.lcms_collection = LCMSCollectionSettings()
318
319    def copy(self):
320        """Create a copy of the LCMSCollectionParameters object"""
321        new_lcms_collection_parameters = LCMSCollectionParameters()
322        new_lcms_collection_parameters.lcms_collection = dataclasses.replace(self.lcms_collection)
323        return new_lcms_collection_parameters
324
325    def __eq__(self, value: object) -> bool:
326        # Check that the object is of the same type
327        if not isinstance(value, LCMSCollectionParameters):
328            return False
329        return self.lcms_collection == value.lcms_collection
330
331def default_parameters(file_location):  # pragma: no cover
332    """Generate parameters dictionary with the default parameters for data processing
333       To gather parameters from instrument data during the data parsing step, a parameters dictionary with the default parameters needs to be generated.
334       This dictionary acts as a placeholder and is later used as an argument for all the class constructor methods during instantiation.
335       The data gathered from the instrument is added to the class properties.
336
337    Parameters
338    ----------
339    file_location: str
340        path to the file
341
342    Returns
343    -------
344    parameters: dict
345        dictionary with the default parameters for data processing
346    """
347
348    parameters = dict()
349
350    parameters["Aterm"] = 0
351
352    parameters["Bterm"] = 0
353
354    parameters["Cterm"] = 0
355
356    parameters["exc_high_freq"] = 0
357
358    parameters["exc_low_freq"] = 0
359
360    parameters["mw_low"] = 0
361
362    parameters["mw_high"] = 0
363
364    parameters["qpd_enabled"] = 0
365
366    parameters["bandwidth"] = 0
367
368    parameters["analyzer"] = "Unknown"
369
370    parameters["acquisition_time"] = None
371
372    parameters["instrument_label"] = "Unknown"
373
374    parameters["sample_name"] = "Unknown"
375
376    parameters["number_data_points"] = 0
377
378    parameters["polarity"] = "Unknown"
379
380    parameters["filename_path"] = str(file_location)
381
382    """scan_number and rt will be need to lc ms"""
383
384    parameters["mobility_scan"] = 0
385
386    parameters["mobility_rt"] = 0
387
388    parameters["scan_number"] = 0
389
390    parameters["rt"] = 0
391
392    return parameters
def hush_output():
18def hush_output():
19    """Toggle all the verbose_processing flags to False on the MSParameters, GCMSParameters and LCMSParameters classes"""
20    MSParameters.molecular_search.verbose_processing = False
21    MSParameters.mass_spectrum.verbose_processing = False
22    GCMSParameters.gc_ms.verbose_processing = False
23    LCMSParameters.lc_ms.verbose_processing = False

Toggle all the verbose_processing flags to False on the MSParameters, GCMSParameters and LCMSParameters classes

def reset_ms_parameters():
25def reset_ms_parameters():
26    """Reset the MSParameter class to the default values"""
27    MSParameters.molecular_search = MolecularFormulaSearchSettings()
28    MSParameters.transient = TransientSetting()
29    MSParameters.mass_spectrum = MassSpectrumSetting()
30    MSParameters.ms_peak = MassSpecPeakSetting()
31    MSParameters.data_input = DataInputSetting()

Reset the MSParameter class to the default values

def reset_gcms_parameters():
34def reset_gcms_parameters():
35    """Reset the GCMSParameters class to the default values"""
36    GCMSParameters.molecular_search = CompoundSearchSettings()
37    GCMSParameters.gc_ms = GasChromatographSetting()

Reset the GCMSParameters class to the default values

def reset_lcms_parameters():
40def reset_lcms_parameters():
41    """Reset the LCMSParameters class to the default values"""
42    reset_ms_parameters()
43    LCMSParameters.lc_ms = LiquidChromatographSetting()

Reset the LCMSParameters class to the default values

class MSParameters:
 46class MSParameters:
 47    """MSParameters class is used to store the parameters used for the processing of the mass spectrum
 48
 49    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.
 50
 51    Parameters
 52    ----------
 53    use_defaults: bool, optional
 54        if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False.
 55
 56    Attributes
 57    -----------
 58    molecular_search: MolecularFormulaSearchSettings
 59        MolecularFormulaSearchSettings object
 60    transient: TransientSetting
 61        TransientSetting object
 62    mass_spectrum: MassSpectrumSetting
 63        MassSpectrumSetting object
 64    ms_peak: MassSpecPeakSetting
 65        MassSpecPeakSetting object
 66    data_input: DataInputSetting
 67        DataInputSetting object
 68
 69    Notes
 70    -----
 71    One can use the use_defaults parameter to reset the parameters to the default values.
 72    Alternatively, to use the current values - modify the class's contents before instantiating the class.
 73    """
 74
 75    molecular_search = MolecularFormulaSearchSettings()
 76    transient = TransientSetting()
 77    mass_spectrum = MassSpectrumSetting()
 78    ms_peak = MassSpecPeakSetting()
 79    data_input = DataInputSetting()
 80
 81    def __init__(self, use_defaults=False) -> None:
 82        if not use_defaults:
 83            self.molecular_search = dataclasses.replace(MSParameters.molecular_search)
 84            self.transient = dataclasses.replace(MSParameters.transient)
 85            self.mass_spectrum = dataclasses.replace(MSParameters.mass_spectrum)
 86            self.ms_peak = dataclasses.replace(MSParameters.ms_peak)
 87            self.data_input = dataclasses.replace(MSParameters.data_input)
 88        else:
 89            self.molecular_search = MolecularFormulaSearchSettings()
 90            self.transient = TransientSetting()
 91            self.mass_spectrum = MassSpectrumSetting()
 92            self.ms_peak = MassSpecPeakSetting()
 93            self.data_input = DataInputSetting()
 94
 95    def copy(self):
 96        """Create a copy of the MSParameters object"""
 97        new_ms_parameters = MSParameters()
 98        new_ms_parameters.molecular_search = dataclasses.replace(self.molecular_search)
 99        new_ms_parameters.transient = dataclasses.replace(self.transient)
100        new_ms_parameters.mass_spectrum = dataclasses.replace(self.mass_spectrum)
101        new_ms_parameters.ms_peak = dataclasses.replace(self.ms_peak)
102        new_ms_parameters.data_input = dataclasses.replace(self.data_input)
103
104        return new_ms_parameters
105
106    def print(self):
107        """Print the MSParameters object"""
108        for k, v in self.__dict__.items():
109            print(k, type(v).__name__)
110
111            for k2, v2 in v.__dict__.items():
112                print("    {}: {}".format(k2, v2))
113
114    def __eq__(self, value: object) -> bool:
115        # Check that the object is of the same type
116        if not isinstance(value, MSParameters):
117            return False
118        equality_check = []
119        equality_check.append(self.molecular_search == value.molecular_search)
120        equality_check.append(self.transient == value.transient)
121        equality_check.append(self.mass_spectrum == value.mass_spectrum)
122        equality_check.append(self.ms_peak == value.ms_peak)
123        equality_check.append(self.data_input == value.data_input)
124
125        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.

MSParameters(use_defaults=False)
81    def __init__(self, use_defaults=False) -> None:
82        if not use_defaults:
83            self.molecular_search = dataclasses.replace(MSParameters.molecular_search)
84            self.transient = dataclasses.replace(MSParameters.transient)
85            self.mass_spectrum = dataclasses.replace(MSParameters.mass_spectrum)
86            self.ms_peak = dataclasses.replace(MSParameters.ms_peak)
87            self.data_input = dataclasses.replace(MSParameters.data_input)
88        else:
89            self.molecular_search = MolecularFormulaSearchSettings()
90            self.transient = TransientSetting()
91            self.mass_spectrum = MassSpectrumSetting()
92            self.ms_peak = MassSpecPeakSetting()
93            self.data_input = DataInputSetting()
transient = TransientSetting(implemented_apodization_function=('Hamming', 'Hanning', 'Blackman', 'Full-Sine', 'Half-Sine', 'Kaiser', 'Half-Kaiser', 'Rectangle'), apodization_method='Hanning', number_of_truncations=0, number_of_zero_fills=1, next_power_of_two=False, kaiser_beta=8.6)
mass_spectrum = MassSpectrumSetting(noise_threshold_method='log', noise_threshold_methods_implemented=('minima', 'signal_noise', 'relative_abundance', 'absolute_abundance', 'log'), noise_threshold_min_std=6, noise_threshold_min_s2n=4.0, noise_threshold_min_relative_abundance=6.0, noise_threshold_absolute_abundance=1000000.0, noise_threshold_log_nsigma=6, noise_threshold_log_nsigma_corr_factor=0.463, noise_threshold_log_nsigma_bins=500, noise_min_mz=50.0, noise_max_mz=1200.0, min_picking_mz=50.0, max_picking_mz=1200.0, picking_point_extrapolate=3, calib_minimize_method='Powell', calib_pol_order=2, max_calib_ppm_error=1.0, min_calib_ppm_error=-1.0, calib_sn_threshold=2.0, calibration_ref_match_method='merged', calibration_ref_match_method_implemented=('legacy', 'merged'), calibration_ref_match_tolerance=0.003, calibration_ref_match_std_raw_error_limit=1.5, do_calibration=True, verbose_processing=True)
ms_peak = MassSpecPeakSetting(kendrick_base={'C': 1, 'H': 2}, kendrick_rounding_method='floor', implemented_kendrick_rounding_methods=('floor', 'ceil', 'round'), peak_derivative_threshold=0.0, peak_min_prominence_percent=0.1, min_peak_datapoints=5.0, peak_max_prominence_percent=0.1, peak_height_max_percent=10.0, legacy_resolving_power=True, legacy_centroid_polyfit=False)
data_input = DataInputSetting(header_translate={'m/z': 'm/z', 'mOz': 'm/z', 'Mass': 'm/z', 'Resolving Power': 'Resolving Power', 'Res.': 'Resolving Power', 'resolution': 'Resolving Power', 'Intensity': 'Peak Height', 'Peak Height': 'Peak Height', 'I': 'Peak Height', 'Abundance': 'Peak Height', 'abs_abu': 'Peak Height', 'Signal/Noise': 'S/N', 'S/N': 'S/N', 'sn': 'S/N'})
def copy(self):
 95    def copy(self):
 96        """Create a copy of the MSParameters object"""
 97        new_ms_parameters = MSParameters()
 98        new_ms_parameters.molecular_search = dataclasses.replace(self.molecular_search)
 99        new_ms_parameters.transient = dataclasses.replace(self.transient)
100        new_ms_parameters.mass_spectrum = dataclasses.replace(self.mass_spectrum)
101        new_ms_parameters.ms_peak = dataclasses.replace(self.ms_peak)
102        new_ms_parameters.data_input = dataclasses.replace(self.data_input)
103
104        return new_ms_parameters

Create a copy of the MSParameters object

def print(self):
106    def print(self):
107        """Print the MSParameters object"""
108        for k, v in self.__dict__.items():
109            print(k, type(v).__name__)
110
111            for k2, v2 in v.__dict__.items():
112                print("    {}: {}".format(k2, v2))

Print the MSParameters object

class GCMSParameters:
128class GCMSParameters:
129    """GCMSParameters class is used to store the parameters used for the processing of the gas chromatograph mass spectrum
130
131    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.
132
133    Parameters
134    ----------
135    use_defaults: bool, optional
136        if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False.
137
138    Attributes
139    -----------
140    molecular_search: MolecularFormulaSearchSettings
141        MolecularFormulaSearchSettings object
142    gc_ms: GasChromatographSetting
143        GasChromatographSetting object
144
145    Notes
146    -----
147    One can use the use_defaults parameter to reset the parameters to the default values.
148    Alternatively, to use the current values - modify the class's contents before instantiating the class.
149    """
150
151    molecular_search = CompoundSearchSettings()
152    gc_ms = GasChromatographSetting()
153
154    def __init__(self, use_defaults=False) -> None:
155        if not use_defaults:
156            self.molecular_search = dataclasses.replace(GCMSParameters.molecular_search)
157            self.gc_ms = dataclasses.replace(GCMSParameters.gc_ms)
158        else:
159            self.molecular_search = CompoundSearchSettings()
160            self.gc_ms = GasChromatographSetting()
161
162    def copy(self):
163        """Create a copy of the GCMSParameters object"""
164        new_gcms_parameters = GCMSParameters()
165        new_gcms_parameters.molecular_search = dataclasses.replace(
166            self.molecular_search
167        )
168        new_gcms_parameters.gc_ms = dataclasses.replace(self.gc_ms)
169
170        return new_gcms_parameters
171
172    def __eq__(self, value: object) -> bool:
173        # Check that the object is of the same type
174        if not isinstance(value, GCMSParameters):
175            return False
176        equality_check = []
177        equality_check.append(self.molecular_search == value.molecular_search)
178        equality_check.append(self.gc_ms == value.gc_ms)
179
180        return all(equality_check)
181
182    def print(self):
183        """Print the GCMSParameters object"""
184        for k, v in self.__dict__.items():
185            print(k, type(v).__name__)
186
187            for k2, v2 in v.__dict__.items():
188                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.

GCMSParameters(use_defaults=False)
154    def __init__(self, use_defaults=False) -> None:
155        if not use_defaults:
156            self.molecular_search = dataclasses.replace(GCMSParameters.molecular_search)
157            self.gc_ms = dataclasses.replace(GCMSParameters.gc_ms)
158        else:
159            self.molecular_search = CompoundSearchSettings()
160            self.gc_ms = GasChromatographSetting()
gc_ms = GasChromatographSetting(use_deconvolution=False, implemented_smooth_method=('savgol', 'hanning', 'blackman', 'bartlett', 'flat', 'boxcar'), smooth_window=5, smooth_method='savgol', savgol_pol_order=2, peak_derivative_threshold=0.0005, peak_height_max_percent=10.0, peak_max_prominence_percent=1.0, min_peak_datapoints=5.0, max_peak_width=0.1, noise_threshold_method='manual_relative_abundance', noise_threshold_methods_implemented=('auto_relative_abundance', 'manual_relative_abundance', 'second_derivative'), std_noise_threshold=3, peak_height_min_percent=0.1, peak_min_prominence_percent=0.1, eic_signal_threshold=0.01, max_rt_distance=0.025, verbose_processing=True)
def copy(self):
162    def copy(self):
163        """Create a copy of the GCMSParameters object"""
164        new_gcms_parameters = GCMSParameters()
165        new_gcms_parameters.molecular_search = dataclasses.replace(
166            self.molecular_search
167        )
168        new_gcms_parameters.gc_ms = dataclasses.replace(self.gc_ms)
169
170        return new_gcms_parameters

Create a copy of the GCMSParameters object

def print(self):
182    def print(self):
183        """Print the GCMSParameters object"""
184        for k, v in self.__dict__.items():
185            print(k, type(v).__name__)
186
187            for k2, v2 in v.__dict__.items():
188                print("    {}: {}".format(k2, v2))

Print the GCMSParameters object

class LCMSParameters:
191class LCMSParameters:
192    """LCMSParameters class is used to store the parameters used for the processing of the liquid chromatograph mass spectrum
193
194    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.
195
196    Parameters
197    ----------
198    use_defaults: bool, optional
199        if True, the class will be instantiated with the default values, otherwise the current values will be used. Default is False.
200
201    Attributes
202    -----------
203    lc_ms: LiquidChromatographSetting
204        LiquidChromatographSetting object
205    mass_spectrum: dict
206        dictionary with the mass spectrum parameters for ms1 and ms2, each value is a MSParameters object
207
208    Notes
209    -----
210    One can use the use_defaults parameter to reset the parameters to the default values.
211    Alternatively, to use the current values - modify the class's contents before instantiating the class.
212    """
213
214    lc_ms = LiquidChromatographSetting()
215    mass_spectrum = {"ms1": MSParameters(), "ms2": MSParameters()}
216
217    def __init__(self, use_defaults=False) -> None:
218        if not use_defaults:
219            self.lc_ms = dataclasses.replace(LCMSParameters.lc_ms)
220            self.mass_spectrum = {
221                "ms1": MSParameters(use_defaults=False),
222                "ms2": MSParameters(use_defaults=False),
223            }
224        else:
225            self.lc_ms = LiquidChromatographSetting()
226            self.mass_spectrum = {
227                "ms1": MSParameters(use_defaults=True),
228                "ms2": MSParameters(use_defaults=True),
229            }
230
231    def copy(self):
232        """Create a copy of the LCMSParameters object"""
233        new_lcms_parameters = LCMSParameters()
234        new_lcms_parameters.lc_ms = dataclasses.replace(self.lc_ms)
235        for key in self.mass_spectrum:
236            new_lcms_parameters.mass_spectrum[key] = self.mass_spectrum[key].copy()
237
238        return new_lcms_parameters
239
240    def __eq__(self, value: object) -> bool:
241        # Check that the object is of the same type
242        if not isinstance(value, LCMSParameters):
243            return False
244        equality_check = []
245        equality_check.append(self.lc_ms == value.lc_ms)
246
247        # Check that the mass_spectrum dictionary has the same keys
248        equality_check.append(self.mass_spectrum.keys() == value.mass_spectrum.keys())
249
250        # Check that the values of the mass_spectrum dictionary are equal
251        for key in self.mass_spectrum.keys():
252            equality_check.append(
253                self.mass_spectrum[key].mass_spectrum
254                == value.mass_spectrum[key].mass_spectrum
255            )
256            equality_check.append(
257                self.mass_spectrum[key].ms_peak == value.mass_spectrum[key].ms_peak
258            )
259            equality_check.append(
260                self.mass_spectrum[key].molecular_search
261                == value.mass_spectrum[key].molecular_search
262            )
263            equality_check.append(
264                self.mass_spectrum[key].transient == value.mass_spectrum[key].transient
265            )
266            equality_check.append(
267                self.mass_spectrum[key].data_input
268                == value.mass_spectrum[key].data_input
269            )
270
271        return all(equality_check)
272
273    def print(self):
274        """Print the LCMSParameters object"""
275        # Print the lcms paramters
276        for k, v in self.__dict__.items():
277            if k == "lc_ms":
278                print(k, type(v).__name__)
279
280        for k2, v2 in self.mass_spectrum.items():
281            """Print the MSParameters object"""
282            for k3, v3 in v2.__dict__.items():
283                print("{} - {}: {}".format(k2, k3, type(v3).__name__))
284
285                for k4, v4 in v3.__dict__.items():
286                    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.

LCMSParameters(use_defaults=False)
217    def __init__(self, use_defaults=False) -> None:
218        if not use_defaults:
219            self.lc_ms = dataclasses.replace(LCMSParameters.lc_ms)
220            self.mass_spectrum = {
221                "ms1": MSParameters(use_defaults=False),
222                "ms2": MSParameters(use_defaults=False),
223            }
224        else:
225            self.lc_ms = LiquidChromatographSetting()
226            self.mass_spectrum = {
227                "ms1": MSParameters(use_defaults=True),
228                "ms2": MSParameters(use_defaults=True),
229            }
lc_ms = LiquidChromatographSetting(scans=(-1, -1), eic_tolerance_ppm=5.0, smooth_window=5, smooth_method='savgol', implemented_smooth_method=('savgol', 'hanning', 'blackman', 'bartlett', 'flat', 'boxcar'), savgol_pol_order=2, consecutive_scan_min=0, peak_height_max_percent=10.0, peak_max_prominence_percent=1.0, peak_derivative_threshold=0.0005, min_peak_datapoints=5.0, noise_threshold_method='manual_relative_abundance', noise_threshold_methods_implemented=('auto_relative_abundance', 'manual_relative_abundance', 'second_derivative'), peak_height_min_percent=0.1, eic_signal_threshold=0.01, dispersity_index_window=3.0, noise_window_factor=2.0, remove_redundant_mass_features=False, redundant_scan_frequency_min=0.1, redundant_feature_retain_n=3, remove_mass_features_by_peak_metrics=False, mass_feature_attribute_filter_dict={'noise_score_max': {'value': 0.8, 'operator': '>='}, 'noise_score_min': {'value': 0.5, 'operator': '>='}}, peak_picking_method='persistent homology', implemented_peak_picking_methods=('persistent homology', 'centroided_persistent_homology'), mass_feature_cluster_mz_tolerance_rel=5e-06, mass_feature_cluster_rt_tolerance=0.3, ms1_scans_to_average=1, ms1_deconvolution_corr_min=0.8, ms2_dda_rt_tolerance=0.15, ms2_dda_mz_tolerance=0.05, ms2_min_fe_score=0.2, search_as_lipids=False, include_fragment_types=False, export_profile_spectra=False, export_eics=True, export_unprocessed_ms1=False, export_only_relevant_mass_spectra=False, verbose_processing=True)
mass_spectrum = {'ms1': <MSParameters object>, 'ms2': <MSParameters object>}
def copy(self):
231    def copy(self):
232        """Create a copy of the LCMSParameters object"""
233        new_lcms_parameters = LCMSParameters()
234        new_lcms_parameters.lc_ms = dataclasses.replace(self.lc_ms)
235        for key in self.mass_spectrum:
236            new_lcms_parameters.mass_spectrum[key] = self.mass_spectrum[key].copy()
237
238        return new_lcms_parameters

Create a copy of the LCMSParameters object

def print(self):
273    def print(self):
274        """Print the LCMSParameters object"""
275        # Print the lcms paramters
276        for k, v in self.__dict__.items():
277            if k == "lc_ms":
278                print(k, type(v).__name__)
279
280        for k2, v2 in self.mass_spectrum.items():
281            """Print the MSParameters object"""
282            for k3, v3 in v2.__dict__.items():
283                print("{} - {}: {}".format(k2, k3, type(v3).__name__))
284
285                for k4, v4 in v3.__dict__.items():
286                    print("    {}: {}".format(k4, v4))

Print the LCMSParameters object

class LCMSCollectionParameters:
289class LCMSCollectionParameters:
290    """LCMSCollectionParameters class is used to store the parameters used for the processing of the LCMS collection
291
292    Each attribute is a class that contains the parameters for the processing of the LCMS collection, 
293    see the corems.encapsulation.factory.processingSetting module for more details.
294
295    Parameters
296    ----------
297    use_defaults: bool, optional
298        if True, the class will be instantiated with the default values, otherwise the current values will be used. 
299        Default is False.
300
301    Attributes
302    -----------
303    lcms_collection: LCMSCollectionSettings
304        LCMSCollectionSettings object
305
306    Notes
307    -----
308    One can use the use_defaults parameter to reset the parameters to the default values.
309    Alternatively, to use the current values - modify the class's contents before instantiating the class.
310    """
311    
312    lcms_collection = LCMSCollectionSettings()
313
314    def __init__(self, use_defaults=False) -> None:
315        if not use_defaults:
316            self.lcms_collection = dataclasses.replace(LCMSCollectionParameters.lcms_collection)
317        else:
318            self.lcms_collection = LCMSCollectionSettings()
319
320    def copy(self):
321        """Create a copy of the LCMSCollectionParameters object"""
322        new_lcms_collection_parameters = LCMSCollectionParameters()
323        new_lcms_collection_parameters.lcms_collection = dataclasses.replace(self.lcms_collection)
324        return new_lcms_collection_parameters
325
326    def __eq__(self, value: object) -> bool:
327        # Check that the object is of the same type
328        if not isinstance(value, LCMSCollectionParameters):
329            return False
330        return self.lcms_collection == value.lcms_collection

LCMSCollectionParameters class is used to store the parameters used for the processing of the LCMS collection

Each attribute is a class that contains the parameters for the processing of the LCMS collection, 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
  • lcms_collection (LCMSCollectionSettings): LCMSCollectionSettings 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.

LCMSCollectionParameters(use_defaults=False)
314    def __init__(self, use_defaults=False) -> None:
315        if not use_defaults:
316            self.lcms_collection = dataclasses.replace(LCMSCollectionParameters.lcms_collection)
317        else:
318            self.lcms_collection = LCMSCollectionSettings()
lcms_collection = LCMSCollectionSettings(cores=1, drop_isotopologues=False, _mass_feature_anchor_technique=['relative_intensity'], mass_feature_anchor_techniques_available=('deconvoluted_mass_spectra', 'absolute_intensity', 'relative_intensity'), mass_feature_anchor_absolute_intensity_threshold=10000, mass_feature_anchor_relative_intensity_threshold=0.6, alignment_minimum_matches=5, alignment_hold_out_fraction=0.3, _alignment_acceptance_technique=['fraction_improved', 'mean_squared_error_improved'], alignment_acceptance_techniques_available=('fraction_improved', 'mean_squared_error_improved'), alignment_acceptance_fraction_improved_threshold=0.5, alignment_mz_tol_ppm=5, alignment_rt_tol=0.4, consensus_mz_tol_ppm=5, consensus_rt_tol=0.3, consensus_partition_size=10000, filter_consensus_mass_features=True, consensus_min_sample_fraction=0.5, gap_fill_expand_on_miss=True, consensus_representative_metric='intensity_prefer_ms2', consensus_representative_metrics_available=('intensity', 'intensity_prefer_ms2'))
def copy(self):
320    def copy(self):
321        """Create a copy of the LCMSCollectionParameters object"""
322        new_lcms_collection_parameters = LCMSCollectionParameters()
323        new_lcms_collection_parameters.lcms_collection = dataclasses.replace(self.lcms_collection)
324        return new_lcms_collection_parameters

Create a copy of the LCMSCollectionParameters object

def default_parameters(file_location):
332def default_parameters(file_location):  # pragma: no cover
333    """Generate parameters dictionary with the default parameters for data processing
334       To gather parameters from instrument data during the data parsing step, a parameters dictionary with the default parameters needs to be generated.
335       This dictionary acts as a placeholder and is later used as an argument for all the class constructor methods during instantiation.
336       The data gathered from the instrument is added to the class properties.
337
338    Parameters
339    ----------
340    file_location: str
341        path to the file
342
343    Returns
344    -------
345    parameters: dict
346        dictionary with the default parameters for data processing
347    """
348
349    parameters = dict()
350
351    parameters["Aterm"] = 0
352
353    parameters["Bterm"] = 0
354
355    parameters["Cterm"] = 0
356
357    parameters["exc_high_freq"] = 0
358
359    parameters["exc_low_freq"] = 0
360
361    parameters["mw_low"] = 0
362
363    parameters["mw_high"] = 0
364
365    parameters["qpd_enabled"] = 0
366
367    parameters["bandwidth"] = 0
368
369    parameters["analyzer"] = "Unknown"
370
371    parameters["acquisition_time"] = None
372
373    parameters["instrument_label"] = "Unknown"
374
375    parameters["sample_name"] = "Unknown"
376
377    parameters["number_data_points"] = 0
378
379    parameters["polarity"] = "Unknown"
380
381    parameters["filename_path"] = str(file_location)
382
383    """scan_number and rt will be need to lc ms"""
384
385    parameters["mobility_scan"] = 0
386
387    parameters["mobility_rt"] = 0
388
389    parameters["scan_number"] = 0
390
391    parameters["rt"] = 0
392
393    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